On Monday, 27 August 2018 at 09:57:18 UTC, Sobaya wrote:
On Monday, 27 August 2018 at 09:41:34 UTC, 9il wrote:
On Monday, 27 August 2018 at 08:25:14 UTC, Sobaya wrote:
I'm using dcompute(https://github.com/libmir/dcompute).

In the development, I have got to use math functions such as sqrt in @compute function.

But LDC says "can only call functions from other @compute modules in @compute code", so can't I call any math functions with dcompute?

Is there any way to use predefined math functions in dcompute?

Thanks.

You may want to try ldc.intrinsics / mir.math.common

Do you mean llvm_sqrt in ldc.intrinsics?

These functions are also not @compute code, so they cause the same error.

Thanks for bringing this to my attention, will fix soon. In the meantime you may declare your own intrinsics in a @compute module and it should work. as in

@compute module mymath;

pragma(LDC_intrinsic, "llvm.sqrt.f#")
    T llvm_sqrt(T)(T val)
        if (__traits(isFloating, T));


This will work if you are targeting CUDA, SPIRV may not like it because the backend is less... mature.

Reply via email to