compiles and runs correctly with the deb package installation of 2.1. However,
using make to enable gpu access and compiling it produces the following error message:
CHPL_HOME/modules/internal/ChapelStandard.chpl:24: error: Could not find C function for csin; perhaps it is missing or is a macro?
I checked with Paulo Laba (my MS student) and it happens in his gpu-enabled Chapel in his computer as well ...
Thanks for the bug report. I have a patch that I will work on to make it a more complete solution. But before I do that, I also wanted to check whether you want to do complex math on device or on host. Currently, we don't support complex types on code that will execute on the GPU, which is an issue we are aware of, but haven't gotten the chance to prioritize, yet. If that's something that you need, please let us know.
Meanwhile, your small reproducer should work as it is not using the GPU. I believe I can get that working relatively soon. If you have some specific complex functions that you want to use, feel free to let me know, so I can make sure that we have them all working if we can.
If sin on 128-bit complex values is all you need, the following diff should get you unblocked while we get the fix on the main branch:
diff --git a/modules/standard/Math.chpl b/modules/standard/Math.chpl
index 920b56b14b..3a67618681 100644
--- a/modules/standard/Math.chpl
+++ b/modules/standard/Math.chpl
@@ -1215,8 +1215,8 @@ module Math {
inline proc sin(x: complex(128)): complex(128) {
pragma "fn synchronization free"
pragma "codegen for CPU and GPU"
- extern proc csin(z: complex(128)): complex(128);
- return csin(x);
+ extern proc chpl_csin(z: complex(128)): complex(128);
+ return chpl_csin(x);
}
/*
diff --git a/runtime/include/chplmath.h b/runtime/include/chplmath.h
index 93be0bb0dd..8945638205 100644
--- a/runtime/include/chplmath.h
+++ b/runtime/include/chplmath.h
@@ -53,6 +53,8 @@ MAYBE_GPU static inline float chpl_sqrt32(float x) { return sqrtf(x); }
MAYBE_GPU static inline double chpl_fabs64(double x) { return fabs(x); }
MAYBE_GPU static inline float chpl_fabs32(float x) { return fabsf(x); }
+MAYBE_GPU static inline _complex128 chpl_csin(_complex128 x) { return __builtin_csin(x); }
+
// 32-bit Bessel functions aren't available on all platforms. For cases where
// we know they're available use them since they should be faster, but in other
// cases default to using the 64-bit versions and casting.
Hi Engin: thanks for the superfast reply! Short answer is that I do not need complex math
in the GPU. I just stumbled across this issue while preparing next semester's class notes.
For the time being, using the deb installation (non-gpu) will be good enough.
Thanks for the context, Nelson. Given that, I am not as panicked as I was before. Not to say that we'll ignore this, but fix may land later than I first suggested. Let me know if your sense of priorities change w.r.t. this issue.
As I'll stop looking at this for the time being, I created the following bug report on your behalf: