本文整理汇总了C#中GThread.vadd2方法的典型用法代码示例。如果您正苦于以下问题:C# GThread.vadd2方法的具体用法?C# GThread.vadd2怎么用?C# GThread.vadd2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GThread
的用法示例。
在下文中一共展示了GThread.vadd2方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public static void Execute()
{
_gpu = CudafyHost.GetDevice(eGPUType.Cuda);
CudafyModule km = CudafyTranslator.Cudafy(ePlatform.Auto, _gpu.GetArchitecture(), typeof(SIMDFunctions));
//CudafyModule km = CudafyTranslator.Cudafy(ePlatform.Auto, eArchitecture.sm_12, typeof(SIMDFunctions));
_gpu.LoadModule(km);
int w = 1024;
int h = 1024;
for (int loop = 0; loop < 3; loop++)
{
uint[] a = new uint[w * h];
Fill(a);
uint[] dev_a = _gpu.CopyToDevice(a);
uint[] b = new uint[w * h];
Fill(b);
uint[] dev_b = _gpu.CopyToDevice(b);
uint[] c = new uint[w * h];
uint[] dev_c = _gpu.Allocate(c);
_gpu.StartTimer();
_gpu.Launch(h, w, "SIMDFunctionTest", dev_a, dev_b, dev_c);
_gpu.CopyFromDevice(dev_c, c);
float time = _gpu.StopTimer();
Console.WriteLine("Time: {0}", time);
if (loop == 0)
{
bool passed = true;
GThread thread = new GThread(1, 1, null);
for (int i = 0; i < w * h; i++)
{
uint exp = thread.vadd2(a[i], b[i]);
if (exp != c[i])
passed = false;
}
Console.WriteLine("Test {0}", passed ? "passed. " : "failed!");
}
_gpu.FreeAll();
}
}
示例2: unitTest_vadd2
public static void unitTest_vadd2(GThread thread, uint[] a, uint[] b, uint[] c)
{
c[0] = thread.vadd2(a[0], b[0]);
}
示例3: SIMDFunctionTest
private static void SIMDFunctionTest(GThread thread, uint[] a, uint[] b, uint[] c)
{
int i = thread.get_global_id(0);
c[i] = thread.vadd2(a[i], b[i]);
}