Preprocessor define for when code is being compiled for compute?

Open
#894 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
csharp

Research direction

No file, test, or entry point is named. Start by tracing how ComputeSharp distinguishes CPU compilation from GPU shader generation and whether that distinction is exposed to user code; done means the supported way to select the appropriate CPU or GPU implementation is clear.

Written by the indexing model from the issue text.

Description

question :question: untriaged :toolbox:

Is there a preprocessor define enabled for when the code is being compiled for compute vs. the normal CPU compiler?

I would like to be able to re-use as much code as I can, but the HLSL intrinsics don't do anything on the CPU side, whereas the System.Math equivalents won't work on the GPU. I would prefer to write a wrapper function around the couple of intrinsics I am using that conditionally points to the appropriate function, rather than maintain parallel versions of all the code that uses these intrinsics.

Thanks!

Dominant language
C#
Stars
3.2k
Forks
148
Avg merge
4h 32m
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Sergio0694/ComputeSharp

All issues in Sergio0694/ComputeSharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.