• Stars
    star
    99
  • Rank 341,883 (Top 7 %)
  • Language
    C#
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A compiler for NET CIL for GP-GPU computing in .NET languages.

Campy

NB: Development of Campy has been suspended until I port a complete NET runtime to C#. --Ken

Welcome! Campy is a compiler, framework, and API for GP-GPU computing in .NET languages. With Campy, one writes GP-GPU code without the usual boilerplate code you see in CUDA/OpenCL, but instead use a simplified model of a multiprocessor GPU/CPU computer, freeing the developer to focus exclusively on the algorithm. The API compiles and runs CIL code into native GPU code using LLVM. Supported are value types, reference types, methods, generics, lambdas, delegates, and closures. Other C#/GPU projects exist, but do not offer a clean, boilerplate-free interface, nor support C# beyond value types. Campy provides a base class library (BCL) for the GPU, implementing strings, arrays, generics, exceptions, delegates, dynamically memory allocation, reflection, and native calls.

This project is in the early stage of development. Releases are currently for demonstration purposes. The only available method is essentially Campy.Parallel.For(), and it will undergo wild changes in signature as I refine the programming model. There are also several debugging output switches (see example below).

public static void Campy.Parallel.For(int number_of_threads, _Kernel_type kernel)
public delegate void Campy.Types._Kernel_type(Index idx);

Targets

  • Windows 10 (x64), Ubuntu 16.04 (x64), Net Framework >= 4.6.1, Net Core 2.0; CUDA GPU Toolkit 9.2.148; Maxwell or better GPU.

Campy under a minute

(Make sure to install Net Core 2.0, https://www.microsoft.com/net/learn/get-started/windows.)

One step install: copy and paste the following code in a Bash shell.


#!/bin/bash
mkdir test
cd test
dotnet new console
cat - << HERE > Program.cs
namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 4;
            int[] x = new int[n];
            Campy.Parallel.For(n, i => x[i] = i);
            for (int i = 0; i < n; ++i)
                System.Console.WriteLine(x[i]);
        }
    }
}
HERE
dotnet add package Campy
dotnet build
unameOut="$(uname -s)"
case "${unameOut}" in
    Linux*)
	dotnet publish -r ubuntu.16.04-x64
	cd bin/Debug/netcoreapp2.1/ubuntu.16.04-x64/publish/
        ./test
	;;
    Darwin*)
	echo Cannot target Mac yet.
	exit 1
	;;
    CYGWIN*)
	dotnet publish -r win-x64
	cd bin/Debug/netcoreapp2.1/win-x64/publish/
        ./test.exe
	;;
    MINGW*)
	dotnet publish -r win-x64
	cd bin/Debug/netcoreapp2.1/win-x64/publish/
        ./test.exe
	;;
    *)
	echo Unknown machine.
	exit 1
	;;
esac
echo Output should be four lines of integers, 0 to 3.
Once an app is "published" as a self-contained deployment, it is completely sufficient.

Additional examples in Campy test area (https://github.com/kaby76/Campy/tree/master/Tests), including Reduction, various sorting algorithms, FFT, etc.

Notes on Building Campy from Scratch

  • Make sure to install VS 2017 15.8.4.
  • Net SDK 2.1.402
  • Make sure to install NVIDIA GPU Toolkit 9.2.148.
  • Through VS 2017, build Runtime.sln DEBUG first. It will prompt to upgrade--do not! Click on cancel and continue.
  • Through VS 2017, build Campy.sln DEBUG.

More Repositories

1

AntlrVSIX

AntlrVSIX is a language server for use with Visual Studio 2019, Visual Studio Code, and Gnu Emacs to support Antlr, Bison, and W3C EBNF grammars. In addition to the IDE extensions provided here, a command-line tool is available to refactor grammars in order to make them cleaner, more readable, and more efficient.
Java
89
star
2

Antlr4BuildTasks

Third-party build tool for 'Official' Antlr4 tool and runtime parsers using .Net. Drop-in replacement for 'Antlr4cs' Antlr4 tool and build rules.
C#
74
star
3

Trash

Toolkit for grammars
C#
72
star
4

Piggy

A transformational system for ASTs, including generation of a p/invoke API from C++ headers.
C#
32
star
5

lsp-types

A replacement for Microsoft.VisualStudio.LanguageServer.Protocol
C#
31
star
6

uni-vscode

From an Antlr4 grammar to a VSCode extension in less than a minute.
C#
25
star
7

AntlrExamples

Some examples of parsing with Antlr
ANTLR
16
star
8

Antlr4Templates

Third-party "dotnet new" templates for Antlr.
CMake
9
star
9

Domemtech.StringTemplate4

C# StringTemplate, v4
C#
8
star
10

swigged.llvm

A SWIG-generated wrapper of LLVM-C for C#. http://domemtech.com/_site/api/Swigged.LLVM.html
HTML
6
star
11

swigged.cuda

A SWIG-generated wrapper of the CUDA Driver API.
C#
5
star
12

cs-codebuff

Codebuff is a formatting tool that uses a machine learning algorithm.
C#
5
star
13

ZhangShashaCSharp

An implementation of Zhang/Shasha in C#, including a list of operations.
C#
4
star
14

AntlrTreeEditing

A library for editing Antlr parse trees.
C#
3
star
15

scrape-c-plus-plus-spec

A program to scrape the grammar from Annex A of one of the ISO148822 specs
C++
3
star
16

ScrapeDartSpec

TeX
2
star
17

re2cs

Port of the regular expression engine re2j https://github.com/google/re2j
C#
2
star
18

LspTools

A simple proxy LSP server.
C#
2
star
19

g4-scripts

Shell
2
star
20

DartGrammar

ANTLR
1
star
21

Domemtech.TrashBase

C#
1
star
22

g4-3840-using-sub-parser

HTML
1
star
23

dllexport-of-kernels

Hello World in CUDA with kernel in a DLL. I didn't know if it would work, but it does.
Cuda
1
star
24

PiggyHW

A basic "Hello world" CUDA example using Piggy.
C#
1
star
25

vs2019-java-lsp

Extension for VS2019 to run the Eclipse LSP server.
C#
1
star
26

RoslynCompileAndRun

An example of how to compile, link, and run C# code with Roslyn under either Net Core or Net Framework.
C#
1
star
27

cuda-waste

C
1
star
28

XamForms-Roslyn-Example

This is a Xamarin Forms/Roslyn example application, demonstrating that a PCL Xamarin Form app can directly link with the Roslyn compiler.
C#
1
star
29

gohack

Go
1
star
30

kaby76

1
star
31

ScrapeJavaSpec

ANTLR
1
star