1

I have testing some GPU computing samples with cudafy

I have code which compute/creta colection of data, and each loop i want do on every object in collection some GPU operation CODE:

public override void CountData(List<IData<int>> datas)
{
        for (int i = 0; i < datas.Count; i++)
        {
           Execute(datas[i]);
        }          
}
public static void Execute(IData<int> data)
{
        CudafyModule km = CudafyTranslator.Cudafy();

        GPGPU gpu = CudafyHost.GetDevice(CudafyModes.Target, CudafyModes.DeviceId);
        gpu.LoadModule(km);

        int c;
        int[] dev_c = gpu.Allocate<int>(); // cudaMalloc one Int32
        gpu.Launch().add(data.IntData[0], data.IntData[1], dev_c); // or gpu.Launch(1, 1, "add", 2, 7, dev_c);
        gpu.CopyFromDevice(dev_c, out c);


        Console.WriteLine(c + ";");

        gpu.Free(dev_c);
        chromozome.Result= c;

}
[Cudafy]
public static void add(int a, int b, int[] c)
{
        c[0] = a + b;
}

This code works for first call of CountData,but after Count data loop end program will stuck and console output says

The thread 0xf50 has exited with code 259 (0x103). The thread 0x10c has exited with code 259 (0x103). The thread 0xc30 has exited with code 259 (0x103). The thread 0xcc0 has exited with code 0 (0x0). The thread 0x548 has exited with code 0 (0x0).

Have enybody clue where could be problem? i try gpu.Synchronize, CudafyHost.ClearDevices() , but it always end in this error Thanks for help

Edit: after some test i found that

gpu.Launch().add(5, 3, dev_c);

works but:

 gpu.Launch().add(data.IntData[0], data.IntData[1], dev_c);

is not

kronas
  • 71
  • 2
  • 6
  • 1
    It is a bug in the debugger included with VS2013. When you see 259 then you can safely assume that the thread ended normally with an exit code of 0. Debug deadlock by starting from the Debug > Windows > Threads window to ensure you are looking at the right thread. Ensure you enabled unmanaged debugging. The Call Stack window content is crucial and must be posted in the question to have any odds for help. – Hans Passant Aug 04 '16 at 08:37
  • Ah ok i was worried that there is problem elsewhere. When i found that this is not tha main issue i sucessfuly found problem in another part of code. – kronas Aug 04 '16 at 09:46

1 Answers1

0

Tahnks to Hans Passant who pinted that this is not problem at all and that gpu card should work wihtou problem. I find error in other part of code. So code above works fine.

kronas
  • 71
  • 2
  • 6