-
Notifications
You must be signed in to change notification settings - Fork 418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clang error compiling included C++ headers with GPU locale model #19754
Comments
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Based on today's discussion over on #19891, I'm wondering whether the right thing to do here would be to remove the code from compiler/llvm/clang.cpp that adds the Something that's unclear to me in the case of the |
We might need to provide a flag or something so that you can indicate if a header file is a C or C++ header. Or, maybe, we just need to |
The solution to the immediate problem is to put some However, this'll bump into lack of complex support in the GPU locale model after adding missing diff --git a/runtime/include/atomics/cstdlib/chpl-atomics.h b/runtime/include/atomics/cstdlib/chpl-atomics.h
index 962a90e6cd..76d3322db6 100644
--- a/runtime/include/atomics/cstdlib/chpl-atomics.h
+++ b/runtime/include/atomics/cstdlib/chpl-atomics.h
@@ -32,6 +32,7 @@
#endif
#if defined(__cplusplus)
+extern "C++" {
#if __cplusplus >= 201103L
#include <atomic>
#define Atomic(T) std::atomic<T>
@@ -55,9 +56,12 @@
#else
#error "The cstdlib atomics need at least C++11. Use intrinsics or locks."
#endif
+}
#elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__)
+extern "C++" {
#include <stdatomic.h>
#define Atomic(T) _Atomic T
+}
#else
#error "The cstdlib atomics need at least C11. Use intrinsics or locks."
#endif
diff --git a/runtime/include/chpltypes.h b/runtime/include/chpltypes.h
index ebb21c82fb..ab2b3de379 100644
--- a/runtime/include/chpltypes.h
+++ b/runtime/include/chpltypes.h
@@ -36,9 +36,11 @@
typedef float complex _complex64;
typedef double complex _complex128;
#else
+extern "C++" {
#include <complex>
typedef std::complex<float> _complex64;
typedef std::complex<double> _complex128;
+}
#endif
#ifdef __cplusplus This patch makes I don't think the lack of complex support is something too challenging to handle, but it is not near the top of our priorities. We can make it a priority, though. Is this a blocker @milthorpe and/or @hokiegeek2 ? |
@e-kayrakli thanks for the follow-up! Um, I'd really appreciate getting this issue resolved as I am trying to prototype Arkouda on GPUs where downselected pdarrays can be shared with Python tools such as Ray and RAPIDS vi locales being on GPUs. Even if it's just a code change I need to grab and patch my 1.27.0 codebase, that would be awesome! |
Fix some issues with the GPU support to enable simple Arkouda builds This branch makes bunch of small-ish changes in an attempt to get Arkouda to compile with the GPU locale model. I can separate this into multiple PRs, but I want to test it some more as a whole. Fixes with this PR: - Resolves #19754 - Stops adding `extern "C"` in the C headers included at the command line. This was proposed by @milthorhpe. - Fixes an interop test broken by this. - To be able to do that makes runtime's generated code interface for complex numbers C-based even if we're compiling with C++. (A prior PR that made some improvements in that direction is #16847) - This enables defining `c_string_to_complex*` functions to be included in the generated executable, because their return types are no longer `std::complex<>` which you can't link with C linkage. - Adds a `no gpu codegen` pragma to thwart gpuization within some internal functions. Currently this only applies to: - `chpl__initCopy_shapeHelp`: Has PRIM_ASSIGN that gets normalized after gpuization, but not resolved. We probably need this function, and the lack might be preventing us from using loop expressions to initialize arrays on gpus. - Fixes `.name` implementation of the `GPULocale` type. - Adds a relevant test. - Adds support for `BitOps` module. - Adds a relevant test. - While there, cleans up `gpuTransforms.cpp` a bit. [Reviewed by @stonea] Test: - [x] gpu/native - [x] gpu/interop - [x] `make check` + spot checks in `types/complex` with `intel` as the host+target compiler - [x] `make check` + spot checks in `types/complex` with `cray` as the host+target compiler
Summary of Problem
A Chapel package module (ZMQ) that includes C++ code does not compile with the GPU locale model.
Steps to Reproduce
If I try to compile the arkouda code to check for ZeroMQ, which requires a C library wrapper, it works fine with the regular locale model:
but crashes when compiled with the GPU locale model:
The clang error indicates that the
extern "C"
in the generated filecommand-line-includes.h
is the problem. If I remove the extern declaration, I can compile and run with the GPU locale model, but I'm not sure if this is the correct solution.From what I can see,
command-line-includes.h
is including a bunch of mostly-C header files, but one include chain runs frommodules/packages/ZMQHelper/zmq_helper.h
down toruntime/include/chpltypes.h
, which includes a C++ header fileclang/13.0.0/include/cuda_wrappers/complex
that includes templated functions. This won't compile in the context of anextern "C"
include, but I'm not sure of the best solution to ensure C++ code is correctly included as such.The compiler function
isCHeader
just checks whether the filename suffix is.h
, which won't work for files like the runtime headerschpltypes.h
,chplcast.h
which function either as C or C++ headers depending on how they're compiled (#ifdef __cplusplus
).Configuration Information
chpl --version
:$CHPL_HOME/util/printchplenv --anonymize
:gcc --version
orclang --version
:The text was updated successfully, but these errors were encountered: