Skip to content

Commit

Permalink
Added new test case for improved IfConversion transformation.
Browse files Browse the repository at this point in the history
  • Loading branch information
m4rs-mt committed Sep 4, 2023
1 parent 5281588 commit 817eecf
Showing 1 changed file with 45 additions and 8 deletions.
53 changes: 45 additions & 8 deletions Src/ILGPU.Tests/BasicJumps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,59 @@ internal static void BasicNestedLoopJumpKernel(
}

[Theory]
[InlineData(32, 0, 67)]
[InlineData(32, 2, 25)]
[InlineData(1024, 0, 67)]
[InlineData(1024, 2, 25)]
[InlineData(0, 67)]
[InlineData(2, 25)]
[KernelMethod(nameof(BasicNestedLoopJumpKernel))]
public void BasicNestedLoopJump(int length, int c, int res)
public void BasicNestedLoopJump(int c, int res)
{
using var buffer = Accelerator.Allocate1D<int>(length);
using var source = Accelerator.Allocate1D<int>(64);
const int Length = 64;
using var buffer = Accelerator.Allocate1D<int>(Length);
using var source = Accelerator.Allocate1D<int>(Length);
var sourceData = Enumerable.Range(0, (int)source.Length).ToArray();
sourceData[57] = 23;
source.CopyFromCPU(Accelerator.DefaultStream, sourceData);

Execute(buffer.Length, buffer.View, source.View, c);

var expected = Enumerable.Repeat(res, length).ToArray();
var expected = Enumerable.Repeat(res, Length).ToArray();
Verify(buffer.View, expected);
}

private static void BasicNestedLoopJumpKernel2(
Index1D index,
ArrayView1D<int, Stride1D.Dense> target,
ArrayView1D<int, Stride1D.Dense> source)
{
int k = 0;
entry:
for (int i = 0; i < source.Length; ++i)
{
goto exit;
}

target[index] = 42;
return;

nested:

Check failure on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / test-library (ubuntu-latest, ILGPU, net6.0)

This label has not been referenced

Check failure on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / test-library (ubuntu-latest, ILGPU, net7.0)

This label has not been referenced

Check failure on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / test-library (ubuntu-latest, ILGPU.Algorithms, net7.0)

This label has not been referenced

Check failure on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / test-library (ubuntu-latest, ILGPU.Algorithms, net6.0)

This label has not been referenced

Check failure on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / test-library (cuda, ILGPU, net6.0)

This label has not been referenced

Check failure on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / test-library (cuda, ILGPU, net7.0)

This label has not been referenced

Check failure on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / test-library (cuda, ILGPU.Algorithms, net6.0)

This label has not been referenced

Check failure on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / test-library (cuda, ILGPU.Algorithms, net7.0)

This label has not been referenced

Check failure on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / test-library (windows-latest, ILGPU, net6.0)

This label has not been referenced

Check failure on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / build (Src)

This label has not been referenced

Check failure on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / build (Src)

This label has not been referenced

Check failure on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / test-library (windows-latest, ILGPU, net7.0)

This label has not been referenced

Check failure on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / build (Src)

This label has not been referenced

Check failure on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / build (Src)

This label has not been referenced

Check failure on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / test-library (windows-latest, ILGPU.Algorithms, net6.0)

This label has not been referenced

Check failure on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / test-library (windows-latest, ILGPU.Algorithms, net7.0)

This label has not been referenced

Check warning on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / Analyze (Src/ILGPU.sln, net6.0)

This label has not been referenced

Check warning on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / Analyze (Src/ILGPU.sln, net7.0)

This label has not been referenced

Check warning on line 200 in Src/ILGPU.Tests/BasicJumps.cs

View workflow job for this annotation

GitHub Actions / Analyze (Src/ILGPU.sln, net7.0)

This label has not been referenced
k = 43;

exit:
if (k++ < 1)
goto entry;
target[index] = 23 + k;
}

[Fact]
[KernelMethod(nameof(BasicNestedLoopJumpKernel2))]
public void BasicNestedLoopJump2()
{
const int Length = 32;
using var buffer = Accelerator.Allocate1D<int>(Length);
using var source = Accelerator.Allocate1D<int>(Length);

Execute(buffer.Length, buffer.View, source.View);

var expected = Enumerable.Repeat(25, Length).ToArray();
Verify(buffer.View, expected);
}
}
Expand Down

0 comments on commit 817eecf

Please sign in to comment.