<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55501>55501</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang -cl-std=clc++2021 --target spirv64 *.cpp failed
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jonasbhjulstad
</td>
</tr>
</table>
<pre>
Note: I'm fairly new to OpenCL-kernel programming, especially with clc++2021.
It might be issues with the kernel code, allthough it compiles fine on Compiler-Explorer:
https://godbolt.org/z/xn4eM58nn
I'm trying to compile the following kernel file:
```
void addVec(float* a, const float*b, const int Nx)
{
for (int i = 0; i < Nx; i++)
{
a[i] += b[i];
}
}
template <int Nstage_ERK, class f_ODE>
struct impl_ERK {
constexpr static int NX = f_ODE::NX;
impl_ERK(const float* _A, const float* _b, const float* _c): p_A(_A), p_b(_b), p_c(_c){}
void solve(constant float* xk, float* xk_1, float t, float dt, const float* P)
{
float K[Nstage_ERK * NX];
float xk_stage[NX];
for (int j = 0; j < NX; j++)
{
xk_stage[j] = xk[j];
}
f_ODE::solve(t, xk_stage, K, P);
for (int i = 1; i < Nstage_ERK; i++) {
float* k_i = &K[i * NX];
float c_i = p_c[i];
float ak_sum[NX];
for (int j = 0; j < NX; j++) {
ak_sum[j] = xk[j];
}
for (int j = 0; j < i; j++) {
ak_sum[j] += p_A[i * Nstage_ERK + j] * K[j * NX];
xk_stage[j] = xk[j] + dt*ak_sum[j];
}
f_ODE::solve(t + c_i * dt, xk_stage, k_i, P);
for (int j = 0; j < NX; j++) {
xk_1[j] += dt * p_b[i] * k_i[j];
}
}
}
private:
const float* p_A;
const float* p_b;
const float* p_c;
};
template <class f_ODE>
struct ERK4 : public impl_ERK<4,f_ODE>
{
ERK4(const float* _A, const float* _b, const float* _c) : impl_ERK<4,f_ODE>(_A, _b, _c){}
};
struct f_ODE_1
{
constexpr static int NX = 3;
constexpr static int NP = 3;
static void solve(const float t, const float* xk, float* xdot, const float* P)
{
float alpha = P[0];
float beta = P[1];
float N_pop = P[2];
xdot[0] = -beta*xk[0]*xk[1]/N_pop;
xdot[1] = beta*xk[0]*xk[1]/N_pop - alpha*xk[1];
xdot[2] = alpha*xk[1];
}
};
// Example that uses find_min in a kernel with array of int4.
__kernel void compute(constant float* x0, global float* x1)
{
const float A[4*4] = {.0f,.0f,.0f,.0f,
.5f,.0f,.0f,.0f,
.0f,.5f,.0f,.0f,
.0f,.0f,1.f,.0f};
const float b[4] = {1.f/6, 1.f/3, 1.f/3, 1.f/6};
const float c[4] = {.0f,.5f,.5f,1.f};
const float dt = .5f;
const float t = .0f;
const float R0 = 1.2;
const float alpha = .9;
const float beta = R0*alpha;
const float N_pop = 1e6;
const float P[f_ODE_1::NP] = {alpha, beta, N_pop};
float res[3];
ERK4<f_ODE_1> integrator(A, b, c);
integrator.solve(x0, res, t, dt, P);
}
```
with the following command:
```
clang -cl-std=clc++2021 --target spirv64 ERK.cpp
```
output:
```
llvm-spirv: /usr/local/include/llvm/IR/Type.h:384: llvm::Type* llvm::Type::getNonOpaquePointerElementType() const: Assertion `NumContainedTys && "Attempting to get element type of opaque pointer"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /usr/local/bin/llvm-spirv /tmp/ERK-355e4b.bc -o /tmp/ERK-ad4368.o
1. Running pass 'Adapt OCL types for SPIR-V' on module '/tmp/ERK-355e4b.bc'.
#0 0x0000563161da86c5 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x0000563161da6324 SignalHandler(int) Signals.cpp:0:0
#2 0x00007fa4841eb420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007fa483c5600b raise /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#4 0x00007fa483c35859 abort /build/glibc-SzIz7B/glibc-2.31/stdlib/abort.c:81:7
#5 0x00007fa483c35729 get_sysdep_segment_value /build/glibc-SzIz7B/glibc-2.31/intl/loadmsgcat.c:509:8
#6 0x00007fa483c35729 _nl_load_domain /build/glibc-SzIz7B/glibc-2.31/intl/loadmsgcat.c:970:34
#7 0x00007fa483c46fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x000056316171bf10 llvm::Type::getNonOpaquePointerElementType() const (/usr/local/bin/llvm-spirv+0x135f10)
#9 0x00005631617db900 llvm::Type::getPointerElementType() const (/usr/local/bin/llvm-spirv+0x1f5900)
#10 0x00005631618126c8 SPIRV::isPointerToOpaqueStructType(llvm::Type*) (/usr/local/bin/llvm-spirv+0x22c6c8)
#11 0x00005631619ced33 SPIRV::OCLTypeToSPIRVBase::adaptArgumentsByMetadata(llvm::Function*) (/usr/local/bin/llvm-spirv+0x3e8d33)
#12 0x00005631619cdac5 SPIRV::OCLTypeToSPIRVBase::runOCLTypeToSPIRV(llvm::Module&) (/usr/local/bin/llvm-spirv+0x3e7ac5)
#13 0x00005631619cd86d SPIRV::OCLTypeToSPIRVLegacy::runOnModule(llvm::Module&) (/usr/local/bin/llvm-spirv+0x3e786d)
#14 0x0000563161cc7b74 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/local/bin/llvm-spirv+0x6e1b74)
#15 0x0000563161860631 llvm::writeSpirv(llvm::Module*, SPIRV::TranslatorOpts const&, std::ostream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) (/usr/local/bin/llvm-spirv+0x27a631)
#16 0x00005631616fac0b convertLLVMToSPIRV(SPIRV::TranslatorOpts const&) llvm-spirv.cpp:0:0
#17 0x00005631616fe91b main (/usr/local/bin/llvm-spirv+0x11891b)
#18 0x00007fa483c37083 __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:342:3
#19 0x00005631616f77de _start (/usr/local/bin/llvm-spirv+0x1117de)
clang-15: error: unable to execute command: Aborted (core dumped)
clang-15: error: llvm-spirv command failed due to signal (use -v to see invocation)
clang version 15.0.0 (https://github.com/llvm/llvm-project.git f6366ef7f4f3cf1182fd70e0c50a9fa54374b612)
Target: spirv64
Thread model: posix
InstalledDir: /usr/local/bin
clang-15: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-15: note: diagnostic msg: /tmp/ERK-53bdca.cpp
clang-15: note: diagnostic msg: /tmp/ERK-53bdca.sh
clang-15: note: diagnostic msg:
********************
```
[ERK-53bdca.sh.txt](https://github.com/llvm/llvm-project/files/8699431/ERK-53bdca.sh.txt)
[ERK-53bdca.cpp.txt](https://github.com/llvm/llvm-project/files/8699432/ERK-53bdca.cpp.txt)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytWl1zo7wO_jXpjScM35CLXqRp-m7n7baZtmfP3jEGnIQuAQ6Ybrq__kgyBMhX293NpHzYsvRYkiXZaZjHb5f3uRQja8puR6a3YUuelOkby8RPJnP2UIhsdjf-IcpMpKwo81XJN5skW43MGRNVIaKEp0D-M5FrFqXRyLyCr6mbhsZG-vVIn95KtklWa8lCwZKqqkWliOVasIZtlMcC-QEnuc7r1ZolEho3RZIC9TLJBMszNlMN5Xi-LdK8FCVgViLWUhYVvpk38F3lcZinUstLAHnzC_62mS2-On6WKfIGF81Wlm8wGZxpI49wLfM0zX9iR4NwCT07cSNXb770-ponMeNx_E3A7P1lmnM5MqeM44yiPKska9vCrinJJLvfjsxJw9K7Ug8MPsu8ZMAJSRI2sq6ZPrKu6HGGY_BZqXk3HEcNWOCHj5yrZORcM6QELmHzDgz6o65bBNd97UixKVIuBQolrJXkKxHMH_-lOaS8AsMED9fzkTVXIypZ1hEghnFI1uHphNHUxbYoGXCTSaS08J3m2DCbwvf--wBiyxFUMlQnC6aHOmZBeKwxQl2Bjxc4xsfLBMkKpPbx0ryiCRUxwG9VgijIylWevooWB896ArY_cHzvNTB2DUx2j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