Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run C# code on GPU

Tags:

c#

gpu

I have no knowledge of GPU programming concepts and APIs. I have a few questions:

  1. Is it possible to write a piece of managed C# code and compile/translate it to some kind of module, which can be executed on the GPU? Or am I doomed to have two implementations, one for managed on the CPU and one for the GPU (I understand that there will be restrictions on what can be executed on the GPU)?
  2. Does there exist a decent and mature API to program independently against various GPU hardware vendors (i.e. a common API)?
  3. Are there any best practices if one wants to develop applications that run on a CPU, written in managed language, and also provide speed optimizations if suitable GPU hardware is present?

I would also be glad for links to any kind of documentation with appropriate learning resources.

Best, Jozef

like image 502
jojovilco Avatar asked Nov 07 '10 21:11

jojovilco


People also ask

What is run C?

runC is a CLI tool for spawning and running containers according to the OCI specification. It was released by Docker container platform in 2015 as part of spinning out plumbing components. As expressed by the announcement: runC is a lightweight, portable container runtime.

Can we run C program online?

C Language online compilerWrite, Run & Share C Language code online using OneCompiler's C online compiler for free. It's one of the robust, feature-rich online compilers for C language, running the latest C version which is C18. Getting started with the OneCompiler's C editor is really simple and pretty fast.

Can you run C on Windows?

Two options. Great, now that Visual Studio Community is installed, you have two options for developing and running C programs on Windows. The first option involves using any text editor you like to write your source code, and using the "cl" command within the Developer Command Prompt to compile your code.


1 Answers

1) No - not for the general case of C# - obviously anything can be created for some subset of the language

2) Yes - HLSL using Direct X or Open GL

3) Not generally possible - CPU and GPU coding are fundamentally different

Basically you can't think of CPU and GPU coding as being comparable. A GPU is a highly specialised parallel processing tool - for lots of parallel simple calculations.

Trying to write a general progam in a GPU with lots of branches etc just won't be efficient - maybe not even possible.

Their memory access architectures are totally different.

You should write for the CPU but farm out appropriate parallel computations to the GPU.

like image 144
James Gaunt Avatar answered Sep 22 '22 12:09

James Gaunt