dcompute
dcompute copied to clipboard
cmd line option -checkaction=context triggers 'can only call functions ...' error
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.
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?
@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; }
https://github.com/ldc-developers/ldc/pull/4497
fixed by https://github.com/dlang/dmd/pull/15625 this will take bit of time to wind up in an LDC release