CUDA On C#

Hey guys I’m new to this forum and I wanted to ask is there any possible way I can run CUDA through C# as I am trying to make this massive calculation run through CUDA to speed up the process running on the GPU, so I am trying to convert this C# program into C which is a task in itself and I am struggling atm as in C# I have helper classes to help make certain calculations easier that I don’t have to hard Code any of the calculations in, these helper classes would be useful later on if I could get it working as I will definatley use it in more programs. So I am asking is there any way to run CUDA through C# (I have tried ManagedCUDA using: https://github.com/kunzmi/managedCuda/wiki/Setup-a-managedCuda-project
and having difficulty with it)

Any advice would be of great thanks.

Jack

Some common methods for using CUDA on C# are using managedCuda as well as Cudafy. Since you’ve already tried managedCuda, you may want to look at Cudafy.

If you google these, you’ll find lots more information including tutorials. There is even a youtube Cudafy tutorial:

https://www.youtube.com/watch?v=MEXEhAT1i_I

I usually make a bridge between C#(.NET) and C++ with C++/CLI.

Hi Episteme,

Would you be so kind to share a sample code on how to do this. So far I’ve gotten to this, but is not compiling into a DLL.

#pragma once
#include <cuda_runtime.h>
#include <cublasXt.h>
#include <helper_cuda.h>



namespace cuBLASXT
{

	void cublasXTMxMul(double *h_A, double *h_B, double *h_C, int M, int K, int N, double alpha, double beta)
	{
		cublasXtHandle_t handle;
		cublasStatus_t status;

		status = cublasXtCreate(&handle);

		cublasXtDgemm(handle, CUBLAS_OP_N, CUBLAS_OP_N, M, N, K, &alpha, h_A, M, h_B, K, &beta, h_C, M);

		
	}

	void cuBLASXTDeviceSelect(int DeviceQty, int *DeviceID)
	{
		cublasXtHandle_t handle;
		cublasStatus_t status;

		status = cublasXtCreate(&handle);

		cublasXtDeviceSelect(handle, DeviceQty, DeviceID);

	}

}

Thanks in advance.

Regards,

Pepe