AdaptiveCpp / AdaptiveCpp/AdaptiveCpp
--hipsycl-platform=cpu problems with CMake
- Linguagem predominante
- C++
- Estrelas
- 1.9k
- Forks
- 228
- Merge médio
- 4d 1h
- PRs com merge (30d)
- 25
Descrição
I've installed hipSYCL stable using the spack package.
Setting following options before compiling:
```
source /home/marcel/Programs/spack/share/spack/setup-env.sh
spack load hipsycl@master
spack load cmake@3.18.1
export PATH=/home/marcel/Programs/spack/opt/spack/linux-linuxmint19-zen/gcc-8.4.0/hipsycl-master-44bjhhamjo3w4k74hsanb73ulhc27now/bin/syclcc-clang:$PATH
```
After that syclcc-clang outputs the following:
```
$ syclcc-clang --version
clang version 10.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/marcel/Programs/spack/opt/spack/linux-linuxmint19-zen/gcc-8.4.0/llvm-10.0.0-uxnrorpisttivegjr4eqshrdva3heg55/bin
```
The default C++ compiler is GCC 8.4.0.
Given the following "hello world" code snipped:
```
#include
#include
class vector_addition;
int main(int, char**) {
cl::sycl::float4 a = { 1.0, 2.0, 3.0, 4.0 };
cl::sycl::float4 b = { 4.0, 3.0, 2.0, 1.0 };
cl::sycl::float4 c = { 0.0, 0.0, 0.0, 0.0 };
cl::sycl::default_selector device_selector;
cl::sycl::queue queue(device_selector);
std::cout << "Running on "
<< queue.get_device().get_info()
<< "\n";
{
cl::sycl::buffer a_sycl(&a, cl::sycl::range<1>(1));
cl::sycl::buffer b_sycl(&b, cl::sycl::range<1>(1));
cl::sycl::buffer c_sycl(&c, cl::sycl::range<1>(1));
queue.submit([&] (cl::sycl::handler& cgh) {
auto a_acc = a_sycl.get_access(cgh);
auto b_acc = b_sycl.get_access(cgh);
auto c_acc = c_sycl.get_access(cgh);
cgh.single_task([=] () {
c_acc[0] = a_acc[0] + b_acc[0];
});
});
}
std::cout << " A { " << a.x() << ", " << a.y() << ", " << a.z() << ", " << a.w() << " }\n"
<< "+ B { " << b.x() << ", " << b.y() << ", " << b.z() << ", " << b.w() << " }\n"
<< "------------------\n"
<< "= C { " << c.x() << ", " << c.y() << ", " << c.z() << ", " << c.w() << " }"
<< std::endl;
return 0;
}
```
Compiling it on the command line using ```syclcc-clang -v --hipsycl-platform=cpu -O3 main.cpp -o a.out``` works perfectly fine (verbose output: [command_line_verbose.txt](https://github.com/illuhad/hipSYCL/files/5298293/command_line_verbose.txt)).
However using CMake it fails miserabelly.
Using the following CMake file:
```
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_COMPILER syclcc-clang)
project(LANGUAGES CXX)
# create executable
add_executable(prog main.cpp)
target_compile_options(prog PRIVATE --hipsycl-platform=cpu)
target_link_options(prog PRIVATE -fopenmp)
```
and calling ```cmake -DCMAKE_BUILD_TYPE=Release .. && make``` results in a tremendous number of linking errors (linker errors: [cmake_linker_errors.txt](https://github.com/illuhad/hipSYCL/files/5298315/cmake_linker_errors.txt), verbose output: [cmake_linker_errors_verbose.txt](https://github.com/illuhad/hipSYCL/files/5298320/cmake_linker_errors_verbose.txt)).
Setting the environment variable ```HIPSYCL_CPU_CXX``` to the clang++ installation, which comes with the hipSYCL installation via spack, the linker errors are gone.
However running the hello world code then results in a segmentation fault during runtime:
```
$ ./prog
Running on hipCPU OpenMP host device
[1] 25241 segmentation fault (core dumped) ./prog
```
(GDB output: [gdb_output.txt](https://github.com/illuhad/hipSYCL/files/5298332/gdb_output.txt))
Targeting NVIDIA GPUs using the above CMake file does work.
My guess is that CMake doesn't propagate somce compiler and/or linker flags correctly when targeting the CPU platform. Is there a way to fix this?
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.