|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apfloat.internal.DoubleElementaryModMath
org.apfloat.internal.DoubleModMath
org.apfloat.internal.DoubleTableFNTStrategy
org.apfloat.internal.DoubleParallelFNTStrategy
public abstract class DoubleParallelFNTStrategy
Common methods to calculate Fast Number Theoretic Transforms in parallel using multiple threads.
Note that to get any performance gain from running many threads in parallel, the JVM must be executing native threads. If the JVM is running in green threads mode, there is no advantage of having multiple threads, as the JVM will in fact execute just one thread and divide its time to multiple simulated threads.
Constructor Summary | |
---|---|
protected |
DoubleParallelFNTStrategy()
Default constructor. |
Method Summary | |
---|---|
protected static Object |
getSharedMemoryLockKey(long length)
Get an object on which to synchronize data storage access. |
protected static void |
lock(Object key)
Start the synchronization for the given lock key. |
protected void |
multiplyElements(Object key,
ArrayAccess arrayAccess,
int startRow,
int rows,
int columns,
double w,
double scaleFactor)
Multiply each matrix element (i, j) by wi * j * scaleFactor . |
protected void |
transformRows(Object key,
int length,
int count,
boolean isInverse,
ArrayAccess arrayAccess,
double[] wTable,
int[] permutationTable)
Transform the rows of the data matrix. |
protected static void |
unlock(Object key)
Finish the synchronization for the given lock key. |
Methods inherited from class org.apfloat.internal.DoubleTableFNTStrategy |
---|
getTransformLength, inverseTableFNT, inverseTransform, tableFNT, transform |
Methods inherited from class org.apfloat.internal.DoubleModMath |
---|
createWTable, getForwardNthRoot, getInverseNthRoot, modDivide, modInverse, modPow, negate |
Methods inherited from class org.apfloat.internal.DoubleElementaryModMath |
---|
getModulus, modAdd, modMultiply, modSubtract, setModulus |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected DoubleParallelFNTStrategy()
Method Detail |
---|
protected static Object getSharedMemoryLockKey(long length)
length
is more than the shared memory treshold, then use shared memory,
otherwise create a dummy key that will not cause any real synchronization.
The shared memory threshold is determined using
ApfloatContext.getSharedMemoryTreshold()
.
length
- The length of data that will be accessed.
protected static void lock(Object key)
unlock(Object)
method,
in the finally
block of the immediately following
try
block, just like for concurrency locks.
The number of processors is taken from ApfloatContext.getNumberOfProcessors()
.
key
- The lock key for synchronization.protected static void unlock(Object key)
lock(Object)
method.
key
- The lock key for synchronization.protected void multiplyElements(Object key, ArrayAccess arrayAccess, int startRow, int rows, int columns, double w, double scaleFactor) throws ApfloatRuntimeException
(i, j)
by wi * j * scaleFactor
.
The matrix size is n1 x n2.
key
- The lock key for synchronization.arrayAccess
- The memory array to multiply.startRow
- Which row in the whole matrix the starting row in the arrayAccess
is.rows
- The number of rows in the arrayAccess
to multiply.columns
- The number of columns in the matrix (= n2).w
- The n:th root of unity (where n = n1 * n2).scaleFactor
- An extra factor by which all elements are multiplied.
ApfloatRuntimeException
protected void transformRows(Object key, int length, int count, boolean isInverse, ArrayAccess arrayAccess, double[] wTable, int[] permutationTable) throws ApfloatRuntimeException
ApfloatContext.getNumberOfProcessors()
.
key
- The lock key for synchronization.length
- Length of one transform (one row).count
- Number of rows.isInverse
- true
if an inverse transform is performed, false
if a forward transform is performed.arrayAccess
- The memory array to split to rows and to transform.wTable
- Table of powers of n:th root of unity (where n is the transform length
).permutationTable
- Table of permutation indexes, or null
if no permutation should be done.
ApfloatRuntimeException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |