digitalmars.D.learn - How to use math functions in dcompute?
- Sobaya (8/8) Aug 27 2018 I'm using dcompute(https://github.com/libmir/dcompute).
- 9il (2/10) Aug 27 2018 You may want to try ldc.intrinsics / mir.math.common
- Sobaya (4/18) Aug 27 2018 Do you mean llvm_sqrt in ldc.intrinsics?
- 9il (2/21) Aug 27 2018 Ah, interesting
- Nicholas Wilson (10/29) Aug 27 2018 Thanks for bringing this to my attention, will fix soon. In the
- Sobaya (9/41) Aug 30 2018 Thank you for replaying.
- Nicholas Wilson (19/66) Aug 31 2018 SPIR-V or CUDA?
- Sobaya (28/99) Sep 06 2018 Sorry for being late for reply.
- Nicholas Wilson (5/32) Sep 07 2018 I'll be adding these to DCompute soon (probably Sunday), LLVM7.0
- Sobaya (5/12) Sep 07 2018 I understand about the release.
- Sobaya (6/21) Sep 17 2018 I'm waiting for the update. How's your progress?
- Nicholas Wilson (4/27) Sep 17 2018 Sorry you need to add a size for the argument "llvm.nvvm.cos.f32"
- Nicholas Wilson (3/4) Sep 17 2018 I t appears I have broke SPIR-V completely somewhere along the
- Sobaya (7/12) Sep 17 2018 I declared like:
- Nicholas Wilson (9/22) Sep 18 2018 pragma(LDC_intrinsic, "llvm.nvvm.cos.f#") // note the # in place
- Nicholas Wilson (3/33) Sep 18 2018 And if they don't work, use
- Sobaya (7/43) Sep 19 2018 "llvm.nvvm.cos.f#" and "llvm.nvvm.cos.f32" don't work.
- Nicholas Wilson (2/47) Sep 20 2018 Hmm, I can reproduce. Will look into it.
- Nicholas Wilson (5/6) Sep 20 2018 pragma(LDC_intrinsic, "llvm.nvvm.cos.approx.f")
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.
Aug 27 2018
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
Aug 27 2018
On Monday, 27 August 2018 at 09:41:34 UTC, 9il wrote:On Monday, 27 August 2018 at 08:25:14 UTC, Sobaya wrote:Do you mean llvm_sqrt in ldc.intrinsics? These functions are also not compute code, so they cause the same error.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
Aug 27 2018
On Monday, 27 August 2018 at 09:57:18 UTC, Sobaya wrote:On Monday, 27 August 2018 at 09:41:34 UTC, 9il wrote:Ah, interestingOn Monday, 27 August 2018 at 08:25:14 UTC, Sobaya wrote:Do you mean llvm_sqrt in ldc.intrinsics? These functions are also not compute code, so they cause the same error.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
Aug 27 2018
On Monday, 27 August 2018 at 09:57:18 UTC, Sobaya wrote:On Monday, 27 August 2018 at 09:41:34 UTC, 9il wrote: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; 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.On Monday, 27 August 2018 at 08:25:14 UTC, Sobaya wrote:Do you mean llvm_sqrt in ldc.intrinsics? These functions are also not compute code, so they cause the same error.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
Aug 27 2018
On Monday, 27 August 2018 at 12:47:45 UTC, Nicholas Wilson wrote:On Monday, 27 August 2018 at 09:57:18 UTC, Sobaya wrote:Thank you for replaying. Surely the definition you told me works for "sqrt". But "cos" and "sin" does not work. The error message is LLVM ERROR: Cannot select: 0xd76ffd8: f32 = fcos ConstantFP:f32<0.000000e+00> 0xd76ff70: f32 = ConstantFP<0.000000e+00> What's wrong?On Monday, 27 August 2018 at 09:41:34 UTC, 9il wrote: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; 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.On Monday, 27 August 2018 at 08:25:14 UTC, Sobaya wrote:Do you mean llvm_sqrt in ldc.intrinsics? These functions are also not compute code, so they cause the same error.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
Aug 30 2018
On Thursday, 30 August 2018 at 10:34:33 UTC, Sobaya wrote:On Monday, 27 August 2018 at 12:47:45 UTC, Nicholas Wilson wrote:SPIR-V or CUDA? for SPIR-V try pragma(mangle, "_Z3sinf") float sin(float); pragma(mangle, "_Z3cosf") float cos(float); more generally see https://github.com/KhronosGroup/SPIR-Tools/wiki/SPIR-2.0-built-in-functions If this is a problem with CUDA you could try using the NVPTX intrinsics pragma(LDC_intrinsic, "llvm.nvvm.namegoeshere") T namegoeshere(Args a); If you need to use both SPIR-V and CUDA then see the hackery e.g. https://github.com/libmir/dcompute/blob/master/source/dcompute/std/index.d#L45 LLVM will be released on September 5th I will fix up this shortly after. Sorry for the alpha state of things right now. NicOn Monday, 27 August 2018 at 09:57:18 UTC, Sobaya wrote:Thank you for replaying. Surely the definition you told me works for "sqrt". But "cos" and "sin" does not work. The error message is LLVM ERROR: Cannot select: 0xd76ffd8: f32 = fcos ConstantFP:f32<0.000000e+00> 0xd76ff70: f32 = ConstantFP<0.000000e+00> What's wrong?On Monday, 27 August 2018 at 09:41:34 UTC, 9il wrote: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; 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.On Monday, 27 August 2018 at 08:25:14 UTC, Sobaya wrote:Do you mean llvm_sqrt in ldc.intrinsics? These functions are also not compute code, so they cause the same error.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
Aug 31 2018
On Friday, 31 August 2018 at 13:30:10 UTC, Nicholas Wilson wrote:On Thursday, 30 August 2018 at 10:34:33 UTC, Sobaya wrote:Sorry for being late for reply. I'm using CUDA for back-end. So you mean if required function is "cos", pragma(LDC_intrinsic, "llvm.nvv.cos") T cos(T a); Is it right? I tried this declaration, but I got an error diffrent from previous one: dcompute.driver.error.DComputeDriverException ../../.dub/packages/dcompute-master/dcompute/source/dcompute/ river/error.d(172): cast(Status)218 ---------------- ??:? [0x48739e] ??:? [0x48f8aa] ??:? [0x47942d] error.d:172 [0x42fe61] error.d:167 [0x42fdb4] error.d:187 [0x42feca] program.d:30 [0x42fc00] app.d:13 [0x417bea] ??:? [0x47908f] ??:? [0x478f85] __entrypoint.d:8 [0x4289f4] ??:? __libc_start_main [0x2b85f455282f] ??:? [0x405c08] Program exited with code 1 My declaration is wrong? Or fixed LLVM(LDC?) is already released? How can I use it ?On Monday, 27 August 2018 at 12:47:45 UTC, Nicholas Wilson wrote:SPIR-V or CUDA? for SPIR-V try pragma(mangle, "_Z3sinf") float sin(float); pragma(mangle, "_Z3cosf") float cos(float); more generally see https://github.com/KhronosGroup/SPIR-Tools/wiki/SPIR-2.0-built-in-functions If this is a problem with CUDA you could try using the NVPTX intrinsics pragma(LDC_intrinsic, "llvm.nvvm.namegoeshere") T namegoeshere(Args a); If you need to use both SPIR-V and CUDA then see the hackery e.g. https://github.com/libmir/dcompute/blob/master/source/dcompute/std/index.d#L45 LLVM will be released on September 5th I will fix up this shortly after. Sorry for the alpha state of things right now. NicOn Monday, 27 August 2018 at 09:57:18 UTC, Sobaya wrote:Thank you for replaying. Surely the definition you told me works for "sqrt". But "cos" and "sin" does not work. The error message is LLVM ERROR: Cannot select: 0xd76ffd8: f32 = fcos ConstantFP:f32<0.000000e+00> 0xd76ff70: f32 = ConstantFP<0.000000e+00> What's wrong?On Monday, 27 August 2018 at 09:41:34 UTC, 9il wrote: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; 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.On Monday, 27 August 2018 at 08:25:14 UTC, Sobaya wrote:Do you mean llvm_sqrt in ldc.intrinsics? These functions are also not compute code, so they cause the same error.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
Sep 06 2018
On Friday, 7 September 2018 at 06:45:32 UTC, Sobaya wrote:Sorry for being late for reply. I'm using CUDA for back-end. So you mean if required function is "cos", pragma(LDC_intrinsic, "llvm.nvv.cos") T cos(T a); Is it right?You're missing an "m" in "nvvm", dunno if that will fix it.I tried this declaration, but I got an error diffrent from previous one: dcompute.driver.error.DComputeDriverException ../../.dub/packages/dcompute-master/dcompute/source/dcompute/ river/error.d(172): cast(Status)218 ---------------- ??:? [0x48739e] ??:? [0x48f8aa] ??:? [0x47942d] error.d:172 [0x42fe61] error.d:167 [0x42fdb4] error.d:187 [0x42feca] program.d:30 [0x42fc00] app.d:13 [0x417bea] ??:? [0x47908f] ??:? [0x478f85] __entrypoint.d:8 [0x4289f4] ??:? __libc_start_main [0x2b85f455282f] ??:? [0x405c08] Program exited with code 1 My declaration is wrong? Or fixed LLVM(LDC?) is already released? How can I use it ?I'll be adding these to DCompute soon (probably Sunday), LLVM7.0 has just been released and I've been waiting on that to do testing.
Sep 07 2018
On Friday, 7 September 2018 at 10:17:47 UTC, Nicholas Wilson wrote:On Friday, 7 September 2018 at 06:45:32 UTC, Sobaya wrote:I understand about the release. But missing "m" is just my typo here. I wrote "llvm.nvvm.cos" correctly on my code, and error occurred.[...]You're missing an "m" in "nvvm", dunno if that will fix it.[...]I'll be adding these to DCompute soon (probably Sunday), LLVM7.0 has just been released and I've been waiting on that to do testing.
Sep 07 2018
On Friday, 7 September 2018 at 10:53:25 UTC, Sobaya wrote:On Friday, 7 September 2018 at 10:17:47 UTC, Nicholas Wilson wrote:I'm waiting for the update. How's your progress? Still it doesn't work well in my environment. If you know temporary solution for use "cos" or "sin", I want to try it. Thank you.On Friday, 7 September 2018 at 06:45:32 UTC, Sobaya wrote:I understand about the release. But missing "m" is just my typo here. I wrote "llvm.nvvm.cos" correctly on my code, and error occurred.[...]You're missing an "m" in "nvvm", dunno if that will fix it.[...]I'll be adding these to DCompute soon (probably Sunday), LLVM7.0 has just been released and I've been waiting on that to do testing.
Sep 17 2018
On Tuesday, 18 September 2018 at 00:25:33 UTC, Sobaya wrote:On Friday, 7 September 2018 at 10:53:25 UTC, Sobaya wrote:Sorry you need to add a size for the argument "llvm.nvvm.cos.f32" for float or copy what is done in ldc/intrinsics.di with aOn Friday, 7 September 2018 at 10:17:47 UTC, Nicholas Wilson wrote:I'm waiting for the update. How's your progress? Still it doesn't work well in my environment. If you know temporary solution for use "cos" or "sin", I want to try it. Thank you.On Friday, 7 September 2018 at 06:45:32 UTC, Sobaya wrote:I understand about the release. But missing "m" is just my typo here. I wrote "llvm.nvvm.cos" correctly on my code, and error occurred.[...]You're missing an "m" in "nvvm", dunno if that will fix it.[...]I'll be adding these to DCompute soon (probably Sunday), LLVM7.0 has just been released and I've been waiting on that to do testing.
Sep 17 2018
On Tuesday, 18 September 2018 at 00:25:33 UTC, Sobaya wrote:I'm waiting for the update. How's your progress?I t appears I have broke SPIR-V completely somewhere along the line, I may release a v0.2 with out it, hopefully within the week.
Sep 17 2018
On Tuesday, 18 September 2018 at 01:39:51 UTC, Nicholas Wilson wrote:On Tuesday, 18 September 2018 at 00:25:33 UTC, Sobaya wrote:I declared like: pragma(LDC_intrinsic, "llvm.nvvm.cos.f32") T cos(T)(T val) if (__traits(isFloating, T)); It also doesn't work.I'm waiting for the update. How's your progress?I t appears I have broke SPIR-V completely somewhere along the line, I may release a v0.2 with out it, hopefully within the week.
Sep 17 2018
On Tuesday, 18 September 2018 at 06:25:33 UTC, Sobaya wrote:On Tuesday, 18 September 2018 at 01:39:51 UTC, Nicholas Wilson wrote:of 32 T cos(T)(T val) if (__traits(isFloating, T)); (Just don't use real with it.) OR pragma(LDC_intrinsic, "llvm.nvvm.cos.f32") float cos(float val)On Tuesday, 18 September 2018 at 00:25:33 UTC, Sobaya wrote:I declared like: pragma(LDC_intrinsic, "llvm.nvvm.cos.f32") T cos(T)(T val) if (__traits(isFloating, T)); It also doesn't work.I'm waiting for the update. How's your progress?I t appears I have broke SPIR-V completely somewhere along the line, I may release a v0.2 with out it, hopefully within the week.
Sep 18 2018
On Wednesday, 19 September 2018 at 00:11:13 UTC, Nicholas Wilson wrote:On Tuesday, 18 September 2018 at 06:25:33 UTC, Sobaya wrote:And if they don't work, useOn Tuesday, 18 September 2018 at 01:39:51 UTC, Nicholas Wilson wrote:place of 32 T cos(T)(T val) if (__traits(isFloating, T)); (Just don't use real with it.) OR pragma(LDC_intrinsic, "llvm.nvvm.cos.f32") float cos(float val)On Tuesday, 18 September 2018 at 00:25:33 UTC, Sobaya wrote:I declared like: pragma(LDC_intrinsic, "llvm.nvvm.cos.f32") T cos(T)(T val) if (__traits(isFloating, T)); It also doesn't work.I'm waiting for the update. How's your progress?I t appears I have broke SPIR-V completely somewhere along the line, I may release a v0.2 with out it, hopefully within the week.32 T cos(T)(T val) if (__traits(isFloating, T)); (Just don't use real with it.)
Sep 18 2018
On Wednesday, 19 September 2018 at 00:22:44 UTC, Nicholas Wilson wrote:On Wednesday, 19 September 2018 at 00:11:13 UTC, Nicholas Wilson wrote:LLVM ERROR: Cannot select: 0xe0d4798: f32 = fcos ConstantFP:f32<0.000000e+00> 0xe0b9db0: f32 = ConstantFP<0.000000e+00>On Tuesday, 18 September 2018 at 06:25:33 UTC, Sobaya wrote:And if they don't work, useOn Tuesday, 18 September 2018 at 01:39:51 UTC, Nicholas Wilson wrote:place of 32 T cos(T)(T val) if (__traits(isFloating, T)); (Just don't use real with it.) OR pragma(LDC_intrinsic, "llvm.nvvm.cos.f32") float cos(float val)On Tuesday, 18 September 2018 at 00:25:33 UTC, Sobaya wrote:I declared like: pragma(LDC_intrinsic, "llvm.nvvm.cos.f32") T cos(T)(T val) if (__traits(isFloating, T)); It also doesn't work.I'm waiting for the update. How's your progress?I t appears I have broke SPIR-V completely somewhere along the line, I may release a v0.2 with out it, hopefully within the week.of 32 T cos(T)(T val) if (__traits(isFloating, T)); (Just don't use real with it.)
Sep 19 2018
On Thursday, 20 September 2018 at 05:16:04 UTC, Sobaya wrote:On Wednesday, 19 September 2018 at 00:22:44 UTC, Nicholas Wilson wrote:Hmm, I can reproduce. Will look into it.On Wednesday, 19 September 2018 at 00:11:13 UTC, Nicholas Wilson wrote:LLVM ERROR: Cannot select: 0xe0d4798: f32 = fcos ConstantFP:f32<0.000000e+00> 0xe0b9db0: f32 = ConstantFP<0.000000e+00>On Tuesday, 18 September 2018 at 06:25:33 UTC, Sobaya wrote:And if they don't work, useOn Tuesday, 18 September 2018 at 01:39:51 UTC, Nicholas Wilson wrote:place of 32 T cos(T)(T val) if (__traits(isFloating, T)); (Just don't use real with it.) OR pragma(LDC_intrinsic, "llvm.nvvm.cos.f32") float cos(float val)On Tuesday, 18 September 2018 at 00:25:33 UTC, Sobaya wrote:I declared like: pragma(LDC_intrinsic, "llvm.nvvm.cos.f32") T cos(T)(T val) if (__traits(isFloating, T)); It also doesn't work.I'm waiting for the update. How's your progress?I t appears I have broke SPIR-V completely somewhere along the line, I may release a v0.2 with out it, hopefully within the week.of 32 T cos(T)(T val) if (__traits(isFloating, T)); (Just don't use real with it.)
Sep 20 2018
On Thursday, 20 September 2018 at 12:43:02 UTC, Nicholas Wilson wrote:Hmm, I can reproduce. Will look into it.pragma(LDC_intrinsic, "llvm.nvvm.cos.approx.f") float cos(float val); does work but is an approximation.
Sep 20 2018
On Thursday, 20 September 2018 at 12:48:14 UTC, Nicholas Wilson wrote:On Thursday, 20 September 2018 at 12:43:02 UTC, Nicholas Wilson wrote:It works for me. I'll use it currently. Thanks!Hmm, I can reproduce. Will look into it.pragma(LDC_intrinsic, "llvm.nvvm.cos.approx.f") float cos(float val); does work but is an approximation.
Sep 24 2018
On Tuesday, 25 September 2018 at 05:18:55 UTC, Sobaya wrote:On Thursday, 20 September 2018 at 12:48:14 UTC, Nicholas Wilson wrote:FYI: Using of 32 T cos(T)(T val) if (__traits(isFloating, T)); seems to work now.On Thursday, 20 September 2018 at 12:43:02 UTC, Nicholas Wilson wrote:It works for me. I'll use it currently. Thanks!Hmm, I can reproduce. Will look into it.pragma(LDC_intrinsic, "llvm.nvvm.cos.approx.f") float cos(float val); does work but is an approximation.
Feb 24 2019