dcompute icon indicating copy to clipboard operation
dcompute copied to clipboard

cmd line option -checkaction=context triggers 'can only call functions ...' error

Open bcarneal opened this issue 4 years ago • 2 comments

Using ldc 1.26.0 and the command line option '-checkaction=context' an assert(0) within dcompute.std.index.d was flagged with:

Error: can only call functions from other '@compute' modules in '@compute' code.

If this is hard to fix the workaround is simple enough, use another checkaction. -checkaction=C works for me.

It is understood that assert() on devices is a dcompute TODO but the above should be a host-side-only problem.

bcarneal avatar Apr 30 '21 19:04 bcarneal

Hmm. So that assert is guarded by a special codegen time conditional. and it seems that assert(0) is transformed into something else by -checkaction=context which errors on the semantic pass that it run before codegen. I guess the fix there is to make the semantic pass take into account the codegen time conditional.

Could you post a reduced test case?

thewilsonator avatar May 04 '21 04:05 thewilsonator

@compute(CompileFor.deviceOnly) module ktstk;

// compiling this with -checkaction=C succeeds // compiling this with -checkaction=context fails on line 88 of dcompute.std.index with: // Error: can only call functions from other @compute modules in @compute code

pragma(LDC_no_moduleinfo);

import ldc.dcompute; import dcompute.std.index : GlobalIndex;

@kernel void gizero(GlobalPointer!(size_t) dst) { dst[GlobalIndex.x] = 0; }

bcarneal avatar May 04 '21 18:05 bcarneal

https://github.com/ldc-developers/ldc/pull/4497

thewilsonator avatar Sep 20 '23 12:09 thewilsonator

fixed by https://github.com/dlang/dmd/pull/15625 this will take bit of time to wind up in an LDC release

thewilsonator avatar Oct 01 '23 00:10 thewilsonator