Alpaka: error: no template named 'AccCpuOmp2Blocks' in namespace 'alpaka::acc' (mac os)

Created on 30 Jun 2020  路  15Comments  路  Source: alpaka-group/alpaka

[edit from @sbastrakov : this issue concerns not the alpaka/example/helloWorld, but the helloWorld from alpaka workshop].

Hello,

When building helloWorld I get some error:

Marks-MBP-2:build markhodgkinson$ cmake --build . --config Release
Scanning dependencies of target helloWorld
[ 50%] Building CXX object CMakeFiles/helloWorld.dir/src/helloWorld.cpp.o
/Users/markhodgkinson/alpaka-workdir/helloWorld/src/helloWorld.cpp:51:22: error: no template named 'AccCpuOmp2Blocks' in namespace 'alpaka::acc'
using Acc = acc::AccCpuOmp2Blocks;
~^
/Users/markhodgkinson/alpaka-workdir/helloWorld/src/helloWorld.cpp:62:43: error: use of undeclared identifier 'Acc'; did you mean 'acc'?
auto const device = pltf::getDevByIdx(0u);
^~~
acc
/usr/local/include/alpaka/kernel/TaskKernelCpuThreads.hpp:303:15: note: 'acc' declared here
namespace acc
^
/Users/markhodgkinson/alpaka-workdir/helloWorld/src/helloWorld.cpp:62:43: error: unexpected namespace name 'acc': expected expression
auto const device = pltf::getDevByIdx(0u);
^
/Users/markhodgkinson/alpaka-workdir/helloWorld/src/helloWorld.cpp:67:32: error: use of undeclared identifier 'Acc'; did you mean 'acc'?
using Queue = queue::Queue;
^~~
acc
/usr/local/include/alpaka/kernel/TaskKernelCpuThreads.hpp:303:15: note: 'acc' declared here
namespace acc
^
/Users/markhodgkinson/alpaka-workdir/helloWorld/src/helloWorld.cpp:67:32: error: unexpected namespace name 'acc': expected expression
using Queue = queue::Queue;
^
/Users/markhodgkinson/alpaka-workdir/helloWorld/src/helloWorld.cpp:69:18: error: use of undeclared identifier 'Queue'; did you mean 'kqueue'?
auto queue = Queue{device};
^~~
kqueue
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/event.h:379:9: note: 'kqueue' declared here
int kqueue(void);
^
/Users/markhodgkinson/alpaka-workdir/helloWorld/src/helloWorld.cpp:69:23: error: expected ';' at end of declaration
auto queue = Queue{device};
^
;
/Users/markhodgkinson/alpaka-workdir/helloWorld/src/helloWorld.cpp:83:51: error: use of undeclared identifier 'Acc'; did you mean 'acc'?
auto taskRunKernel = kernel::createTaskKernel(workDiv, helloWorldKernel);
^

acc
/usr/local/include/alpaka/kernel/TaskKernelCpuThreads.hpp:303:15: note: 'acc' declared here
namespace acc
^
/Users/markhodgkinson/alpaka-workdir/helloWorld/src/helloWorld.cpp:83:51: error: unexpected namespace name 'acc': expected expression
auto taskRunKernel = kernel::createTaskKernel(workDiv, helloWorldKernel);
^
/Users/markhodgkinson/alpaka-workdir/helloWorld/src/helloWorld.cpp:92:5: error: reference to 'wait' is ambiguous
wait::wait(queue);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/wait.h:194:7: note: candidate found by name lookup is 'wait'
union wait {
^
/usr/local/include/alpaka/dev/cpu/Wait.hpp:19:15: note: candidate found by name lookup is 'alpaka::wait'
namespace wait

I installed things via:

git clone -b release-0.5.0 https://github.com/alpaka-group/alpaka.git
sudo port install boost
cd alpaka/build
cmake ../
sudo cmake --install .
cmake -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --parallel 1 --config Release
ctest -C Release

yesterday, and it all worked as far as I could see.

Today I installed the examples with:

git clone https://github.com/alpaka-group/alpaka-workshop-examples.git
Copied helloWorld to a different location and created build there.
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release

I am on mac os 10.15.5

Cheers,

Mark

OpenMP macOS Question

Most helpful comment

Yes it runs fine now! :)

Cheers,

Mark

All 15 comments

Thanks for submitting the issue and providing the output @shefmarkh , looking into it.

I think the difference from yesterday may be that the vectorAdd example in the main alpaka repository (this one) that we built and ran in yesterday's slides by default uses the sequential accelerator, as it does not have any dependencies. However, the helloWorld example uses the OpenMP 2.0 backend and so should be compiled with OpenMP support.

To check this hypothesis, could you please try changing this line to
using Acc = acc::AccCpuSerial<Dim, Idx>;, and then build again?

This is just to check if OpenMP is indeed somehow causing the issue, or something else. After it is all resolved, we will of course go back to enabling actual parallel execution.

Thanks, yes it gets further now.

cmake --build . --config Release
Scanning dependencies of target helloWorld
[ 50%] Building CXX object CMakeFiles/helloWorld.dir/src/helloWorld.cpp.o
/Users/markhodgkinson/alpaka-workdir/helloWorld/src/helloWorld.cpp:93:5: error: reference to 'wait' is ambiguous
wait::wait(queue);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/wait.h:194:7: note: candidate found by name lookup is 'wait'
union wait {
^
/usr/local/include/alpaka/dev/cpu/Wait.hpp:19:15: note: candidate found by name lookup is 'alpaka::wait'
namespace wait
^
1 error generated.

I was able to fix this by explicitly adding the alpaka namespace at line 93:

// This call is redundant for a blocking queue
alpaka::wait::wait(queue);

Cheers,

Mark

Thanks, so apparently this wait() issue is a shortcoming of the example. We normally do alpaka:: explicitly everywhere, however for the workshop decided to make it more simple with using namespace alpaka; and did not have a macOS-based developer to reveal this problem. I will fix it in the examples repository.

Now, coming back to the original OpenMP issue. So by default we are trying to find all supported platforms visible to cmake (OpenMP, CUDA, TBB, etc.). It seems like cmake did not find an OpenMP-capable compiler, and so the respective alpaka accelerator is not available, as shown in your original error message. Again, I am not sure how it is all done on macOS, but perhaps you know how to enable it?

@prometheusPi, perhaps you have an idea on the question in the previous message?

Hello,

I did not really know how to enable openmp. Some googling suggested the default apple clang does not support openmp, and that instead I should use mac ports clang.

So I installed that, and forced cmake to use it via:
alias cmake="CXX=\"/opt/local/bin/clang\" CC=\"/opt/local/bin/clang\" cmake"

I found out I should also set:

export CPLUS_INCLUDE_PATH=/opt/local/libexec/llvm-10/include/c++/v1:/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include

now I do have openmp support:

-- Optional alpaka dependency TBB could not be found! TBB grid block back-end disabled!
-- Found OpenMP_CXX: -fopenmp=libomp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")

but still cannot compile alpaka:

[ 2%] Building CXX object test/analysis/headerCheck/CMakeFiles/headerCheck.dir/src/acc/AccCpuOmp2Blocks.hpp.cpp.o
In file included from /Users/markhodgkinson/alpaka/build/test/analysis/headerCheck/src/acc/AccCpuOmp2Blocks.hpp.cpp:1:
In file included from /Users/markhodgkinson/alpaka/include/alpaka/acc/AccCpuOmp2Blocks.hpp:32:
In file included from /Users/markhodgkinson/alpaka/include/alpaka/time/TimeOmp.hpp:19:
/opt/local/include/libomp/omp.h:16:12: error: macro name is a reserved identifier [-Werror,-Wreserved-id-macro]

define __OMP_H

       ^

/opt/local/include/libomp/omp.h:41:16: error: macro name is a reserved identifier [-Werror,-Wreserved-id-macro]

define __KAI_KMPC_CONVENTION

           ^

/opt/local/include/libomp/omp.h:43:20: error: macro name is a reserved identifier [-Werror,-Wreserved-id-macro]

define __KMP_IMP

               ^

/opt/local/include/libomp/omp.h:358:11: error: macro name is a reserved identifier [-Werror,-Wreserved-id-macro]

undef __KAI_KMPC_CONVENTION

      ^

/opt/local/include/libomp/omp.h:359:11: error: macro name is a reserved identifier [-Werror,-Wreserved-id-macro]

undef __KMP_IMP

so far I could not find an answer from google searches. The problem is in the mac ports install of clang though I think (/opt/local is where the mac ports stuff is put),so its not an alpaka issue.

Cheers,

Mark

I did not really know how to enable openmp. Some googling suggested the default apple clang does not support openmp, and that instead I should use mac ports clang.

Yes. so that looks in line with the error in your very first message.

So now OpenMP is found and your errors indeed seem to come from your compiler/system and not alpaka. But no worries, we will help, it just takes a little longer as none of core alpaka developers use macOS at the moment, but some of our colleagues from other groups do, and we will investigate with their help.

Just as a naive suggestion to try quickly: when doing build now, did you clean the build directory (fully, or CMakeFiles and CMakeCache)? If not, there could be a mix of old and new settings that causes errors.

Hello,

Yes I cleaned the build directory. I found a suggestion just now, to change "cmake .." to "cmake -E env CXXFLAGS="-Wno-reserved-id-macro" cmake .."

Now I am making progress...

Scanning dependencies of target headerCheck
[ 1%] Building CXX object test/analysis/headerCheck/CMakeFiles/headerCheck.dir/src/acc/AccCpuFibers.hpp.cpp.o
[ 2%] Building CXX object test/analysis/headerCheck/CMakeFiles/headerCheck.dir/src/acc/AccCpuOmp2Blocks.hpp.cpp.o
[ 2%] Building CXX object test/analysis/headerCheck/CMakeFiles/headerCheck.dir/src/acc/AccCpuOmp2Threads.hpp.cpp.o
[ 2%] Building CXX object test/analysis/headerCheck/CMakeFiles/headerCheck.dir/src/acc/AccCpuOmp4.hpp.cpp.o
[ 3%] Building CXX object test/analysis/headerCheck/CMakeFiles/headerCheck.dir/src/acc/AccCpuSerial.hpp.cpp.o

Hopefully now the whole thing builds :)

Cheers,

Mark

Oh, nice! To make it quicker, you can skip building of tests (these may take a while, depending on the machine) and just do the example directly

Thanks, yes that is faster. Initially I had linker errors, which I solved by updating the linker flags, as well as the cmake alias.

So overall I could compile HelloWorld with:

sudo port select --set clang mp-clang-10
alias cmake="CXX=\"/opt/local/bin/clang++\" CC=\"/opt/local/bin/clang\" cmake"
export CPLUS_INCLUDE_PATH=/opt/local/libexec/llvm-10/include/c++/v1:/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include
cmake -E env CXXFLAGS="-Wno-reserved-id-macro" LDFLAGS="-stdlib=libc++" cmake -DCMAKE_BUILD_TYPE=RELEASE ..
cmake --build . --config Release

Cheers,

Mark

Great! And does it run now?

Just a side note: It should be CMAKE_BUILD_TYPE=Release, not RELEASE. In your case it doesn't matter since this flag is ignored by Xcode (Xcode only evaluates the --config Release) but if you run the command on Linux in the future you might encounter some trouble.

Yes it runs fine now! :)

Cheers,

Mark

Great! I will close this one now, as the issue is resolved. Please feel free to submit questions or report bugs in other issues, or re-open this one if related.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mxmlnkn picture mxmlnkn  路  5Comments

BenjaminW3 picture BenjaminW3  路  3Comments

jkelling picture jkelling  路  3Comments

kloppstock picture kloppstock  路  3Comments

SimeonEhrig picture SimeonEhrig  路  5Comments