This file contains hidden or 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
| using System; | |
| using Cudafy; | |
| using Cudafy.Host; | |
| using Cudafy.Translator; | |
| namespace TestProject | |
| { | |
| class Program | |
| { | |
| public static void Main() |
This file contains hidden or 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
| CudafyModule km = CudafyTranslator.Cudafy(); |
This file contains hidden or 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
| gpu.Launch().thekernel(); |
This file contains hidden or 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
| [Cudafy] | |
| public static void thekernel() | |
| { | |
| } |
This file contains hidden or 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
| [Cudafy] | |
| public struct VectorStruct | |
| { | |
| public int x; | |
| public int y; | |
| public int z; | |
| } | |
| class Program | |
| { |
This file contains hidden or 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
| VectorStruct[] dev_a = gpu.Allocate<VectorStruct>(N); |
This file contains hidden or 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
| VectorStruct[] dev_c = gpu.Allocate<VectorStruct>(c); |
This file contains hidden or 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
| gpu.CopyToDevice(a, dev_a); |
This file contains hidden or 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
| [Cudafy] | |
| public static void thekernel(GThread thread, VectorStruct[] a, VectorStruct[] b, VectorStruct[] c) | |
| { | |
| int tid = thread.threadIdx.x; | |
| if (tid < N) | |
| { | |
| c[tid].x = a[tid].x + b[tid].x; | |
| c[tid].y = a[tid].y + b[tid].y; | |
| c[tid].z = a[tid].z + b[tid].z; | |
| } |