Skip to content

Instantly share code, notes, and snippets.

View pawelKondzior's full-sized avatar
😀

Paweł pawelKondzior

😀
  • TTMS
  • Białystok
View GitHub Profile
using System;
using Cudafy;
using Cudafy.Host;
using Cudafy.Translator;
namespace TestProject
{
class Program
{
public static void Main()
CudafyModule km = CudafyTranslator.Cudafy();
gpu.Launch().thekernel();
[Cudafy]
public static void thekernel()
{
}
[Cudafy]
public struct VectorStruct
{
public int x;
public int y;
public int z;
}
class Program
{
VectorStruct[] dev_a = gpu.Allocate<VectorStruct>(N);
VectorStruct[] dev_c = gpu.Allocate<VectorStruct>(c);
gpu.CopyToDevice(a, dev_a);
[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;
}