Skip to content

Commit

Permalink
add test for 3D buffers and 3D collapsed for loops
Browse files Browse the repository at this point in the history
  • Loading branch information
computablee committed Nov 26, 2023
1 parent ffc09ad commit b5dc84c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions DotMP-Tests/GPUTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,17 @@ public void Collapse_works()
else
iters_hit[i, j].Should().Be(0);

/*iters_hit = null;
iters_hit = null;

int[,,] iters_hit_3 = new int[128, 128, 64];

DotMP.Parallel.ParallelForCollapse((35, 64), (16, 100), (10, 62), num_threads: 8, chunk_size: 3, schedule: Schedule.Dynamic, action: (i, j, k) =>
using (var buf = new Buffer<int>(iters_hit_3, DotMP.GPU.Buffer.Behavior.ToFrom))
{
DotMP.Atomic.Inc(ref iters_hit_3[i, j, k]);
});
DotMP.GPU.Parallel.ParallelForCollapse((35, 64), (16, 100), (10, 62), buf, action: (i, j, k, iters_hit_3) =>
{
iters_hit_3[i, j, k]++;
});
}

for (int i = 0; i < 128; i++)
for (int j = 0; j < 128; j++)
Expand All @@ -112,9 +115,14 @@ public void Collapse_works()
else
iters_hit_3[i, j, k].Should().Be(0);

iters_hit_3 = null;*/
iters_hit_3 = null;
}

/// <summary>
/// Randomly initialize an array of type T.
/// </summary>
/// <typeparam name="T">The type to initialize to.</typeparam>
/// <param name="arr">The allocated array to store values into.</param>
private void random_init<T>(T[] arr)
{
Random r = new Random();
Expand Down

0 comments on commit b5dc84c

Please sign in to comment.