public void SumScanJobTest() { int[] array = new int[ARRAY_COUNT]; for (int i = 0; i < ARRAY_COUNT; i++) { array[i] = GenerateRandomInt(); } NativeArray <int> na_array = new NativeArray <int>(array, Allocator.TempJob); SumScanJob sumScanJob = new SumScanJob(ref na_array); sumScanJob.InclusiveSumScan(); // using serial inclusive sum scan method to make sure that the parallel method works int sum = 0; for (int i = 0; i < ARRAY_COUNT; i++) { sum += array[i]; Assert.AreEqual(sum, na_array[i]); } na_array.Dispose(); sumScanJob.Dispose(); }
public RadixSortJob(ref NativeArray <uint> na_values, ref NativeArray <int> na_indices) { this._valueCount = na_values.Length; this.na_values = na_values; this.na_indices = na_indices; this.na_sortedValues = new NativeArray <uint>(na_values, Allocator.Persistent); this.na_sortedIndices = new NativeArray <int>(na_indices, Allocator.Persistent); this.na_bit = new NativeArray <bool>(_valueCount, Allocator.Persistent); this.na_truePrefixSum = new NativeArray <int>(_valueCount, Allocator.Persistent); this.na_falsePrefixSum = new NativeArray <int>(_valueCount, Allocator.Persistent); this.radixBitCheckJob = new RadixBitCheckJob( ref na_values, ref na_bit, ref na_truePrefixSum, ref na_falsePrefixSum ); this.radixSortShuffleJob = new RadixSortShuffleJob( ref na_values, ref na_indices, ref na_sortedValues, ref na_sortedIndices, ref na_bit, ref na_truePrefixSum, ref na_falsePrefixSum ); this.trueSumScanJob = new SumScanJob(ref na_truePrefixSum); this.falseSumScanJob = new SumScanJob(ref na_falsePrefixSum); }