-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved performance of unit tests using shared contexts.
- Loading branch information
Showing
38 changed files
with
229 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using ILGPU.IR.Transformations; | ||
using ILGPU.Runtime.CPU; | ||
using System; | ||
|
||
namespace ILGPU.Tests.CPU | ||
{ | ||
public abstract class CPUTestContext : TestContext | ||
{ | ||
private static int NumThreads = Math.Max(Math.Min( | ||
Environment.ProcessorCount, 4), 2); | ||
|
||
public CPUTestContext(OptimizationLevel optimizationLevel) | ||
: base( | ||
optimizationLevel, | ||
context => new CPUAccelerator(context, NumThreads)) | ||
{ } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 6 additions & 7 deletions
13
Src/ILGPU.Tests.Cuda/ContextProvider.cs → Src/ILGPU.Tests.Cuda/TestContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
using ILGPU.IR.Transformations; | ||
using ILGPU.Runtime; | ||
using ILGPU.Runtime.Cuda; | ||
using System; | ||
|
||
namespace ILGPU.Tests.Cuda | ||
{ | ||
sealed class CudaContextProvider : ContextProvider | ||
public abstract class CudaTestContext : TestContext | ||
{ | ||
public CudaContextProvider(OptimizationLevel optimizationLevel) | ||
: base(optimizationLevel) | ||
{ } | ||
|
||
public override Accelerator CreateAccelerator(Context context) | ||
private static CudaAccelerator CreateAccelerator(Context context) | ||
{ | ||
if (CudaAccelerator.CudaAccelerators.Length < 1) | ||
throw new NotSupportedException(); | ||
return new CudaAccelerator(context); | ||
} | ||
|
||
public CudaTestContext(OptimizationLevel optimizationLevel) | ||
: base(optimizationLevel, CreateAccelerator) | ||
{ } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 6 additions & 7 deletions
13
Src/ILGPU.Tests.OpenCL/ContextProvider.cs → Src/ILGPU.Tests.OpenCL/TestContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
using ILGPU.IR.Transformations; | ||
using ILGPU.Runtime; | ||
using ILGPU.Runtime.OpenCL; | ||
using System; | ||
|
||
namespace ILGPU.Tests.OpenCL | ||
{ | ||
sealed class OpenCLContextProvider : ContextProvider | ||
public abstract class CLTestContext : TestContext | ||
{ | ||
public OpenCLContextProvider(OptimizationLevel optimizationLevel) | ||
: base(optimizationLevel) | ||
{ } | ||
|
||
public override Accelerator CreateAccelerator(Context context) | ||
private static CLAccelerator CreateAccelerator(Context context) | ||
{ | ||
if (CLAccelerator.CLAccelerators.Length < 1) | ||
throw new NotSupportedException(); | ||
var mainAccelerator = CLAccelerator.CLAccelerators[0]; | ||
return new CLAccelerator(context, mainAccelerator); | ||
} | ||
|
||
public CLTestContext(OptimizationLevel optimizationLevel) | ||
: base(optimizationLevel, CreateAccelerator) | ||
{ } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.