cuda.net

Hello-world for CUDA.Net

女生的网名这么多〃 提交于 2019-12-12 08:46:15
问题 I'm trying to write a childish app with CUDA.Net, but I'm out of luck. I've figured out to: using GASS.CUDA; // ... var c = new CUDA(); // c.Launch(myfunc); // ???? how ??? myfunc apparently should be of type GASS.CUDA.Types.CUfunction but I didn't find how to define one. 回答1: First you need a .cu file with your kernel (function to be executed on a GPU). Let's have a file mykernel.cu : extern "C" __global__ void fooFunction(float4* data) { // there can be some CUDA code ... } This have to be

Passing an array within a structure in CUDAfy

自闭症网瘾萝莉.ら 提交于 2019-12-06 10:15:48
问题 Using VS 2012, .NET 4.5, 64bit and CUDAfy 1.12 and I have the following proof of concept using System; using System.Runtime.InteropServices; using Cudafy; using Cudafy.Host; using Cudafy.Translator; namespace Test { [Cudafy(eCudafyType.Struct)] [StructLayout(LayoutKind.Sequential)] public struct ChildStruct { [MarshalAs(UnmanagedType.LPArray)] public float[] FArray; public long FArrayLength; } [Cudafy(eCudafyType.Struct)] [StructLayout(LayoutKind.Sequential)] public struct ParentStruct {

Hello-world for CUDA.Net

不羁的心 提交于 2019-12-04 06:21:44
I'm trying to write a childish app with CUDA.Net, but I'm out of luck. I've figured out to: using GASS.CUDA; // ... var c = new CUDA(); // c.Launch(myfunc); // ???? how ??? myfunc apparently should be of type GASS.CUDA.Types.CUfunction but I didn't find how to define one. First you need a .cu file with your kernel (function to be executed on a GPU). Let's have a file mykernel.cu : extern "C" __global__ void fooFunction(float4* data) { // there can be some CUDA code ... } This have to be compiled into a .cubin file with the nvcc compiler. In order to let the compiler know of the Visual C++

CUDA Driver API vs. CUDA runtime

こ雲淡風輕ζ 提交于 2019-12-03 00:33:55
问题 When writing CUDA applications, you can either work at the driver level or at the runtime level as illustrated on this image (The libraries are CUFFT and CUBLAS for advanced math): (source: tomshw.it) I assume the tradeoff between the two are increased performance for the low-evel API but at the cost of increased complexity of code. What are the concrete differences and are there any significant things which you cannot do with the high-level API? I am using CUDA.net for interop with C# and it

CUDA Driver API vs. CUDA runtime

蓝咒 提交于 2019-12-02 14:10:12
When writing CUDA applications, you can either work at the driver level or at the runtime level as illustrated on this image (The libraries are CUFFT and CUBLAS for advanced math): (source: tomshw.it ) I assume the tradeoff between the two are increased performance for the low-evel API but at the cost of increased complexity of code. What are the concrete differences and are there any significant things which you cannot do with the high-level API? I am using CUDA.net for interop with C# and it is built as a copy of the driver API. This encourages writing a lot of rather complex code in C#

Allocate constant memory

廉价感情. 提交于 2019-11-30 21:37:11
I'm trying to set my simulation params in constant memory but without luck (CUDA.NET). cudaMemcpyToSymbol function returns cudaErrorInvalidSymbol. The first parameter in cudaMemcpyToSymbol is string... Is it symbol name? actualy I don't understand how it could be resolved. Any help appreciated. //init, load .cubin float[] arr = new float[1]; arr[0] = 0.0f; int size = Marshal.SizeOf(arr[0]) * arr.Length; IntPtr ptr = Marshal.AllocHGlobal(size); Marshal.Copy(arr, 0, ptr, arr.Length); var error = CUDARuntime.cudaMemcpyToSymbol("param", ptr, 4, 0, cudaMemcpyKind.cudaMemcpyHostToDevice); my .cu

Allocate constant memory

给你一囗甜甜゛ 提交于 2019-11-30 17:18:44
问题 I'm trying to set my simulation params in constant memory but without luck (CUDA.NET). cudaMemcpyToSymbol function returns cudaErrorInvalidSymbol. The first parameter in cudaMemcpyToSymbol is string... Is it symbol name? actualy I don't understand how it could be resolved. Any help appreciated. //init, load .cubin float[] arr = new float[1]; arr[0] = 0.0f; int size = Marshal.SizeOf(arr[0]) * arr.Length; IntPtr ptr = Marshal.AllocHGlobal(size); Marshal.Copy(arr, 0, ptr, arr.Length); var error