Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ipynb-kotlin/ffx.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"jakarta.activation-api-2.1.3.jar",
"jakarta.xml.bind-api-4.0.2.jar",
"javaparser-core-3.26.4.jar",
"javaparser-core-3.27.0.jar",
"javax.annotation-api-1.3.2.jar",
"jaxb-core-4.0.3.jar",
"jaxb-runtime-4.0.3.jar",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ class BAR extends AlgorithmsScript {
private boolean sortedArc = false

@Option(names = ["--ss", "--startSnapshot"], paramLabel = "0",
description = "Start at this snapshot when reading in Tinker BAR files.")
description = "Start at this snapshot when reading in Tinker BAR files (indexed from 0).")
private int startingSnapshot = 0

@Option(names = ["--es", "--endSnapshot"], paramLabel = "0",
description = "End at this snapshot when reading in Tinker BAR files.")
description = "End at this snapshot when reading in Tinker BAR files (indexed from 0).")
private int endingSnapshot = 0

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ public Complex3DParallel(int nX, int nY, int nZ, ParallelTeam parallelTeam,
useSIMD = false;
}

// Do not pack FFTs by default for now.
packFFTs = false;
String pack = System.getProperty("fft.packFFTs", Boolean.toString(packFFTs));
try {
Expand Down Expand Up @@ -360,11 +361,13 @@ public Complex3DParallel(int nX, int nY, int nZ, ParallelTeam parallelTeam,
fftZ[i] = new Complex(nZ, dataLayout1D, internalImZ, nY);
fftZ[i].setUseSIMD(useSIMD);
}
if (!localZTranspose) {
work3D = new double[2 * nX * nY * nZ];
} else {

if (localZTranspose) {
work3D = null;
} else {
work3D = new double[2 * nX * nY * nZ];
}

fftRegion = new FFTRegion();
ifftRegion = new IFFTRegion();
convRegion = new ConvolutionRegion();
Expand Down Expand Up @@ -488,6 +491,7 @@ public void initTiming() {

/**
* Get the timing string.
*
* @return The timing string.
*/
public String timingString() {
Expand Down Expand Up @@ -1030,11 +1034,15 @@ private class TransposeLoop extends IntegerForLoop {
public void run(final int lb, final int ub) {
for (int x = lb; x <= ub; x++) {
for (int z = 0; z < nZ; z++) {
int inputOffset = x * nextX + z * nextZ;
int workOffset = x * trNextX + z * trNextZ;
for (int y = 0; y < nY; y++) {
double real = input[x * nextX + y * nextY + z * nextZ];
double imag = input[x * nextX + y * nextY + z * nextZ + im];
work3D[y * trNextY + z * trNextZ + x * trNextX] = real;
work3D[y * trNextY + z * trNextZ + x * trNextX + internalImZ] = imag;
int inputIndex = inputOffset + y * nextY;
double real = input[inputIndex];
double imag = input[inputIndex + im];
int workIndex = workOffset + y * trNextY;
work3D[workIndex] = real;
work3D[workIndex + internalImZ] = imag;
}
}
}
Expand Down Expand Up @@ -1082,11 +1090,15 @@ private class UnTransposeLoop extends IntegerForLoop {
public void run(final int lb, final int ub) {
for (int x = 0; x < nX; x++) {
for (int y = 0; y < nY; y++) {
int workOffset = x * trNextX + y * trNextY;
int inputOffset = x * nextX + y * nextY;
for (int z = lb; z <= ub; z++) {
double real = work3D[y * trNextY + z * trNextZ + x * trNextX];
double imag = work3D[y * trNextY + z * trNextZ + x * trNextX + internalImZ];
input[x * nextX + y * nextY + z * nextZ] = real;
input[x * nextX + y * nextY + z * nextZ + im] = imag;
int workIndex = workOffset + z * trNextZ;
double real = work3D[workIndex];
double imag = work3D[workIndex + internalImZ];
int inputIndex = inputOffset + z * nextZ;
input[inputIndex] = real;
input[inputIndex + im] = imag;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.util.Random;

import ffx.utilities.FFXTest;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -101,6 +102,11 @@ public void setUp() {
}
}

@After
public void after() throws Exception {
parallelTeam.shutdown();
}

/** Test of convolution method, of class Complex3D. */
@Test
public void testConvolution() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.util.Random;

import ffx.utilities.FFXTest;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -108,6 +109,11 @@ public void setUp() {
}
}

@After
public void after() throws Exception {
parallelTeam.shutdown();
}

/** Test of convolution method, of class Real3DParallel. */
@Test
public void testConvolution() {
Expand Down
7 changes: 6 additions & 1 deletion modules/pj/src/main/java/edu/rit/pj/KillRegion.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,14 @@
* @author Jacob Litman
*/
public class KillRegion extends ParallelRegion {

/** {@inheritDoc} */
@Override
public void run() throws Exception {
// Does precisely nothing save exist.
// Empty run method.
ParallelTeamThread currentThread = getCurrentThread();
Thread thread = currentThread.getThread();
long totalThreads = ParallelTeamThread.totalThreads.getAndDecrement();
// System.out.printf(" Killing team %s thread %s of %d\n", currentThread.myTeam, thread, totalThreads);
}
}
20 changes: 20 additions & 0 deletions modules/pj/src/main/java/edu/rit/pj/PJProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,26 @@ public static int getPjNt() {
return k;
}

/**
* Determine whether a {@linkplain ParallelTeam} should use virtual threads.
* <p>
* If the <code>"pj.vt"</code> Java system property is true, then virtual threads
* will be used. If the property is false or not specified, then the
* program will use platform threads.
* <p>
* The default is false, meaning that the program will use platform threads.
* <p>
* @return true if the program should use virtual threads, false otherwise.
*/
public static boolean getPjVt() {
String pjVtProperty = System.getProperty("pj.vt");
if (pjVtProperty != null) {
return Boolean.parseBoolean(pjVtProperty);
} else {
return false; // Default is false
}
}

/**
* Determine the schedule for a parallel loop in an SMP parallel program.
* This is the schedule that will be used if the parallel for loop has a
Expand Down
15 changes: 6 additions & 9 deletions modules/pj/src/main/java/edu/rit/pj/ParallelConstruct.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,13 @@ ParallelTeamThread getCurrentThread() {
if (myTeam == null) {
throw new IllegalStateException("ParallelConstruct.getCurrentThread(): No parallel team executing");
}
try {
ParallelTeamThread current = (ParallelTeamThread) Thread.currentThread();
if (current.myTeam != this.myTeam) {
throw new IllegalStateException("ParallelConstruct.getCurrentThread(): Current thread is not executing this parallel construct");
Thread currentThread = Thread.currentThread();
for (ParallelTeamThread teamThread : myTeam.myThread) {
if (teamThread.getThread() == currentThread) {
return teamThread;
}
return current;
} catch (ClassCastException exc) {
throw new IllegalStateException("ParallelConstruct.getCurrentThread(): Current thread is not a parallel team thread",
exc);
}
throw new IllegalStateException("ParallelConstruct.getCurrentThread(): Current thread is not executing this parallel construct");
}

}
}
2 changes: 1 addition & 1 deletion modules/pj/src/main/java/edu/rit/pj/ParallelTeam.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public final void execute(ParallelRegion theRegion)

// Record parallel region.
myRegion = theRegion;
myExceptionMap = new ConcurrentHashMap<Integer, Throwable>(K, 0.75f, K);
myExceptionMap = new ConcurrentHashMap<>(K, 0.75f, K);
theRegion.myTeam = this;

try {
Expand Down
50 changes: 44 additions & 6 deletions modules/pj/src/main/java/edu/rit/pj/ParallelTeamThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
//******************************************************************************
package edu.rit.pj;

import edu.rit.pj.reduction.SharedLong;
import java.util.concurrent.Semaphore;

/**
Expand All @@ -54,9 +55,9 @@
* @version 20-Dec-2007
*/
class ParallelTeamThread
extends Thread {
implements Runnable {

// Hidden data members.
// Hidden data members.
// Reference to the parallel team.
ParallelTeam myTeam;

Expand Down Expand Up @@ -86,29 +87,64 @@ class ParallelTeamThread
// Exception thrown while setting up a parallel construct, or null if none.
volatile Throwable myConstructException;

// The thread instance
private final Thread thread;

/**
* Number of threads created by the ParallelTeamThread constructor.
*/
public static SharedLong totalThreads = new SharedLong(0);

// 128 bytes of extra padding to avert cache interference.
private long p0, p1, p2, p3, p4, p5, p6, p7;
private long p8, p9, pa, pb, pc, pd, pe, pf;

// Exported constructors.

/**
* Construct a new parallel team thread.
*
* @param theTeam Parallel team to which this thread belongs.
* @param theTeam Parallel team to which this thread belongs.
* @param theIndex Index of this thread within the team.
*/
public ParallelTeamThread(ParallelTeam theTeam,
int theIndex) {
int theIndex) {
myTeam = theTeam;
myIndex = theIndex;
setDaemon(true);
start();

String name = "ParallelTeamThread-" + theIndex;

boolean isVirtual = PJProperties.getPjVt();
if (isVirtual) {
// Create a virtual thread (all virtual threads are daemon threads).
thread = Thread.ofVirtual().name(name).unstarted(this);
} else {
// Create a new thread for this parallel team thread.
thread = Thread.ofPlatform().name(name).unstarted(this);
thread.setDaemon(true);
}

long numThreads = totalThreads.incrementAndGet();
// System.out.printf(" Creating team %s thread %s out of %d.\n", myTeam, name, numThreads);

thread.start();
}

// Exported operations.

/**
* Get the underlying thread.
*
* @return The Thread instance
*/
public Thread getThread() {
return thread;
}

/**
* Run this parallel team thread.
*/
@Override
public void run() {
for (;;) {
// Wait until released by the main thread.
Expand All @@ -120,6 +156,8 @@ public void run() {
} catch (Exception ex) {
System.err.printf("Error exiting parallel team thread: %s%n", ex);
}

// Exit the for loop and run method, which will allow threads to be garbage collected.
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ class PrepareSpaceGroups extends PotentialScript {
continue
}

logger.info(format("\n Preparing %s (CSD percent: %7.4f, PDB Rank: %d)",
spacegroup2.shortName, getCCDCPercent(num), getPDBRank(spacegroup)))
logger.info(format("\n Preparing %d %s (CSD percent: %7.4f, PDB Rank: %d)",
num, spacegroup2.shortName, getCCDCPercent(num), getPDBRank(spacegroup)))

// Create the directory.
String sgDirName = spacegroup2.shortName.replace('/', '_')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public class ExtendedSystem implements Potential {
*/
private final double LYStitrBiasMag;
private final List<Constraint> constraints;
public final boolean useTotalChargeCorrection;
private final boolean doBias;
private final boolean doElectrostatics;
private final boolean doPolarization;
Expand Down Expand Up @@ -317,6 +318,7 @@ public ExtendedSystem(MolecularAssembly mola, double pH, final File esvFile) {
doElectrostatics = properties.getBoolean("esv.elec", true);
doBias = properties.getBoolean("esv.bias", true);
doPolarization = properties.getBoolean("esv.polarization", true);
useTotalChargeCorrection = properties.getBoolean("esv.total.charge.correction", false);
thetaFriction = properties.getDouble("esv.friction", ExtendedSystem.THETA_FRICTION);
thetaMass = properties.getDouble("esv.mass", ExtendedSystem.THETA_MASS);

Expand Down
Loading