static void Main() { cuda = new CUDA(true); cublas = new CUBLAS(cuda); //allocate vector on cuda device in main thread CudaManager.CallMethod(AllocateVectors); //changing first vector from other thread Thread changeThread = new Thread(ChangeVectorOnDevice_ThreadRun) { IsBackground = false }; changeThread.Start(); //wait for changeThread to finish autoResetEvent.WaitOne(); //getting vector from device in another one thread Thread getThread = new Thread(GetVectorFromDevice_ThreadRun) { IsBackground = false }; getThread.Start(); //wait for getThread to finish autoResetEvent.WaitOne(); Console.WriteLine("({0}, {1}, {2}, {3}, {4})", vector2[0], vector2[1], vector2[2], vector2[3], vector2[4]); Console.ReadKey(true); }
private static void GetVectorFromDevice_ThreadRun() { CudaManager.CallMethod(GetVectorFromDevice); //releasing main thread autoResetEvent.Set(); }
private static void ChangeVectorOnDevice_ThreadRun() { CudaManager.CallMethod(ChangeVectorOnDevice); //releasing main thread autoResetEvent.Set(); }