A Unity package supporting a variety of parallel computations. The package includes:
- SumJob - computes the sum of the elements of an array
- ProductJob - computes the element-wise product of two arrays
- PccJob - computes the Pearson correlation coefficient of two arrays
Here is a brief example that illustrates the usage. Refer to Runtime/Pcc.cs
to see how SumJob
and ProductJob
may be combined to form more complex computations.
using Imagibee.Parallel;
var x = new float[] { 1, 2, 3, 4, 5 };
var y = new float[] { -1, -2, -3, -4, -5 };
var pccJob = new PccJob()
{
Allocator = Allocator.Persistent,
Length = x.Length,
Width = x.Length / 2
};
pccJob.Allocate();
pccJob.X.CopyFrom(x);
pccJob.Y.CopyFrom(x);
pccJob.Schedule().Complete();
var pccXX = pccJob.Result.Value;
pccJob.Y.CopyFrom(y);
pccJob.Schedule().Complete();
var pccYY = pccJob.Result.Value;
pccJob.Dispose();
Assert.AreEqual(1f, pccXX);
Assert.AreEqual(-1f, pccYY);
This package uses semantic versioning. Tags on the main branch indicate versions. It is recomended to use a tagged version. The latest version on the main branch should be considered under development when it is not tagged.
This package is intended to be used from an existing Unity project. Using the Package Manager select Add package from git URL... and provide the URL to the version you want in this git repository.
The package includes Functional and Performance tests. To run the tests open the Test Runner. Select the Imagibee.Parallel.Tests.dll
and Run Selected. If the tests do not show up in the Test Runner you might need to add the following entry to your manifest file.
"testables": [
"com.imagibee.parallel"
]
Report and track issues here.
Minor changes such as bug fixes and performance improvements are welcome any time. Simply make a pull request. Please discuss more significant changes prior to making the pull request by opening a new issue that describes the change.