Archive for the ‘CUDA.NET’ Category

Advanced data types with CUDA

Sunday, September 13th, 2009

Following with CUDA.NET 2.3.6 release, this article is meant to show you so of the more advanced constructs .NET can offer developers willing to get advanced interoperability with native code.
As most of you ar familiar, CUDA.NET offers to copy many types of arrays and data types to the GPU memory (through the different memcpy functions). These are based on well defined data types, mostly for numerical purposes.

Consider a basic data type of float, the corresponding array is declared as: float[], in C# or otherwise in different languages, but the principle is the same. In addition to these primitives (byte, short, int, long, float, double) there is also support for vector data types that CUDA support, such as Float2, where it is composed of 2 consequtive float elements.

What happens when you want to pass more complex data types that are not supported by CUDA.NET?

In this case, there are several techniques to achieve this goal, some maybe more complex to empploy than others, and it mostly depend on your expected usage.

1. Declaring a new copy function

Well, that’s always an option if you wish to extend the API of functions. In such case, the developer declares a new copy function to use, with expected parameters and consumes it.

The following example can show a little more:

// This is a dummy, complex data type
struct Test
{
public int value1;
public float value2;
}

// Define a new copy function to use with CUDA, assuming running under Linux
[DllImport("cuda")]
public static extern CUResult cuMemcpyHtoD(CUdeviceptr dst, Test[] src, uint bytes);

The definition above is for a function, to use, capable of copying data from an array of Test objects to device memory.
But, it may not always be convenient.

2. The dynamic, simpler way

Well, .NET offers one more possibility to convert .NET objects into native representation, without using “unsafe” mechanisms.

For this purpose, there is an object called “GCHandle” to use. This object provides an advanced control over the garbage collector of .NET to lock objects in memory and get their native pointer (IntPtr in .NET).

Since all copy functions in CUDA.NET support the IntPtr data type, one can use this mechanism as a generic way to copy data to the GPU. In practice, when a user calls one of the existing copy functions, the exact process is performed.

Again, consider the Test structure we created before.

// Getting native handle from an array
Test[] data = new Test[100];
// Fill in the array values...
GCHandle ptr = GCHandle.Alloc(data, GCHandleType.Pinned);
IntPtr src = ptr.AddrOfPinnedObject();
// Now copy to the GPU memory from this pointer...
....
// When finished, don't forget to free the GCHandle!
ptr.Free();

This is a simple process for exposing complex .NET data types to CUDA and CUDA.NET to be processed by the GPU.

In the next article we will present the new SizeT object we added for portability between 32 and 64 bit systems.

New CUDA.NET Release (2.3.6)

Sunday, September 13th, 2009

Hi Everyone,

We’ve just released the latest version (2.3.6) of CUDA.NET library.

Beside supporting the latest features of CUDA 2.3 (double precision FFT, advanced memory allocation and more) we added more features to the API of the runtime and graphics (DX/GL) to better support 32/64 systems and be portable.

Following this article we will publish a few series of articles presenting the new constructus we added, and native interoperability, which is always an issue with .NET code and advanced demands for applications. They intend to show how to create portable code between systems and using complex structures an data types passed to the GPU.

Enjoy!

CUDA.NET – Case studies, call for contribution

Friday, May 22nd, 2009

We are pleased to announce a call for contribution for case studies and customer stories using CUDA.NET to be presented in our web site.

We invite organizations, research institutes and privates to tell us about about their use of CUDA.NET for different purposes – developing a product, researching variety of scientific fields and more.

Users willing to contribute their story are invited to send their details to the following address: cuda.net@gass-ltd.co.il and we will contact them soon.

Thank you for your cooperation.

CUDA.NET 2.2 released

Thursday, May 21st, 2009

We are happy to announce the release of CUDA.NET version 2.2.

This release aligns with CUDA 2.2 API and features, and provides further improvements with CUDA.NET.
To download page.

Few of the additions/changes:

  • Supporting CUDA 2.2 API (zero copy etc.)
  • CUDA class supports all driver functions, adding few missing texture functions into the API
  • Removing double precision FFT routines from CUFFT – the functions were there for future support, but are no longer available
  • Adding MSDN/CHM based documentation for the library
  • Extending the runtime API support to allow various memory copies and the latest 2.2 API

We you will all find that release useful.

You are invited to provide us comments for usage and in general about the library to improve it.
You can send all that information to cuda.net@gass-ltd.co.il.

CUDA.NET 2.1 Released

Thursday, February 5th, 2009

We are pleased to announce that a new version of CUDA.NET is out, following the release of CUDA 2.1.

The new release of CUDA.NET, provides support for new DirectX 10 API interoperability, and JIT compiler.

To download click here.

DirectX 10 interoperability

The new API by NVIDIA allows to integrate existing DirectX 10 applications with CUDA, to provide another level of computing, if for post-processing, image processing or other computations to perform.

DirectX 9 API is still supported.

JIT Compiler

A new compiler support is provided by NVIDIA, through the API. This allows to generate CUDA kernel code in runtime and compile it on demand using this new facility.

In addition, it allows to attach kernel source code to an application, and compile it at the site, using specific configuration: maximum register usage, specific hardware support and more.

FIXes

This release of CUDA.NET 2.1, fixes an issue with CUDAExecution class. When running a computation on the GPU using the class, an then calling the Clear method, didn’t clear the parameters state. As with this release the issue was fixed.

Next CUDA.NET release (2.1)

Thursday, January 1st, 2009

CUDA 2.1 is already in a beta version and expected to add some of the more interesting features up to date.

One first feature is the newly added support for DirectX 10 API interoperability with through CUDA.

Another interesting features is by allowing to compile (JIT – Just In Time) CUDA PTX code to match a specific GPU architecture. This feature allows to generate CUDA kernels on demand and compile them directly to the GPU architecture available in the running system. Just like using a compiler.

CUDA.NET 2.1 is expected to be released on early February, adding support for all new features of CUDA 2.1 and extended functionality as we add it incrementaly

Welcome to CUDA.NET

Wednesday, December 24th, 2008

This is the 1st post from CUDA.NET team about the library.

The blogs will contain material and publications about the library, code samples and general how-to’s for the community.