Altimesh.Hybridizer.Runtime.CUDAImports 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Altimesh.Hybridizer.Runtime.CUDAImports --version 2.0.0
NuGet\Install-Package Altimesh.Hybridizer.Runtime.CUDAImports -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Altimesh.Hybridizer.Runtime.CUDAImports" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Altimesh.Hybridizer.Runtime.CUDAImports --version 2.0.0
#r "nuget: Altimesh.Hybridizer.Runtime.CUDAImports, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Altimesh.Hybridizer.Runtime.CUDAImports as a Cake Addin
#addin nuget:?package=Altimesh.Hybridizer.Runtime.CUDAImports&version=2.0.0

// Install Altimesh.Hybridizer.Runtime.CUDAImports as a Cake Tool
#tool nuget:?package=Altimesh.Hybridizer.Runtime.CUDAImports&version=2.0.0

Hybridizer Essentials is a compiler targeting CUDA-enabled GPUS from .Net. Using parallelization patterns, such as Parallel.For, or ditributing parallel work by hand, the user can benefit from the compute power of GPUS without entering the learning curve of CUDA, all within Visual Studio.

hybridizer-basic-samples

This repo illustrates a few samples for Hybridizer

These samples may be used with Hybridizer Essentials. However, C# code can run with any version of Hybridizer. They illustrate features of the solution and are a good starting point for experimenting and developing software based on Hybridizer.

All new code is added to the repo of the latest CUDA version (currently 10.0). Older CUDA versions are still supported, but don't get the new samples.

WARNING

CUDA 9/9.1/9.2 and the latest update of visual studio do not work together (v141 toolset). see <a href="https://devtalk.nvidia.com/default/topic/1027209/cuda-9-0-does-not-work-with-the-latest-vs-2017-update/" target="_blank">devtalk.nvidia.com</a>. Install the v140 toolset before trying to compile samples with visual 2017, or use CUDA 10.0

Requirements

Before you start, you first need to check if you have the right environment. You need an install of Visual Studio (2012 or later). You need a CUDA-enabled GPU and CUDA (8.0 or later) installed (with the CUDA driver). Obviously, you need to install <a href="https://marketplace.visualstudio.com/items?itemName=altimesh.AltimeshHybridizerExtensionEssentials" target="_blank">Hybridizer Essentials</a>.

Run

Checkout repository, and open Visual Studio. Require and validate license from Hybridizer->License Settings Tool window. Open HybridizerBasicSamples solution. Build solution and run example of your choice. After an update, you might need to reload the solution.

Example

using System;
using System.Linq;
using System.Threading.Tasks;

using Hybridizer.Runtime.CUDAImports;

namespace HybridizerExample
{
    class Program
    {
        [EntryPoint]
        public static void Add(float[] a, float[] b, int N)
        {
            Parallel.For(0, N, i => a[i] += b[i]);
        }

        static void Main(string[] args)
        {
            // Arrange
            const int N = 1024 * 1024 * 32;
            float[] a = Enumerable.Range(0, N).Select(i => (float)i).ToArray();
            float[] b = Enumerable.Range(0, N).Select(i => 1.0F).ToArray();

            // Run
            HybRunner.Cuda().Wrap(new Program()).Add(a, b, N);

            cuda.DeviceSynchronize();


            // Assert
            for(int i = 0; i < N; ++i)
            {
                if(a[i] != (float)i + 1.0F)
                {
                    Console.Error.WriteLine("Error at {0} : {1} != {2}", i, a[i], (float)i + 1.0F);
                    Environment.Exit(6); // abort
                }
            }

            Console.Out.WriteLine("OK");
        }
    }
}
hybridizer-cuda Program.cs -o a.exe -run

OK

Documentation

Samples are explained in the wiki.

You can find API documentation in our DocFX generated documentation

Notes

After building the csproj, you have to build the generated vcxproj manually or put it in your build dependencies using the configuration manager. After installing an update, you may need to unload/reload the solution, or even close and restart visual studio.

Product Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Altimesh.Hybridizer.Runtime.CUDAImports:

Repository Stars
altimesh/hybridizer-basic-samples
Examples of C# code compiled to GPU by hybridizer
Version Downloads Last updated
2.1.4 338 10/13/2023
2.1.3 466 3/14/2023
2.1.2 251 3/13/2023
2.0.2 344 1/28/2023
2.0.1 594 11/20/2022
2.0.0 433 9/23/2022

Added VS2022 and CUDA 11+