Skip to content
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

OpenACC implementation requires GCC 6 and patch #17

Open
jeffhammond opened this issue Nov 26, 2016 · 3 comments
Open

OpenACC implementation requires GCC 6 and patch #17

jeffhammond opened this issue Nov 26, 2016 · 3 comments

Comments

@jeffhammond
Copy link
Contributor

The OpenACC implementation requires GCC 6+ to compile, but then only with a patch.

Please rename the patch to remove the .txt suffix, which Github forced me to add.
0001-use-restrict-instead-of-restrict-which-is-not-a-.patch.txt

Unfortunately, my version of CUDA only supports GCC 5, so I'm kludging them together like this (the important piece is -ccbin):

cmake \
-DCMAKE_CXX_COMPILER=g++-6.2 \
-DCMAKE_C_COMPILER=gcc-6.2 \
-DCMAKE_CXX_FLAGS="-g -O3 -std=gnu++11 -fopenmp -fopenacc -Wall -Wextra" \
-DCMAKE_C_FLAGS="-g -O3 -std=gnu11 -fopenmp -fopenacc -Wall -Wextra" \
-DCUDA_NVCC_FLAGS="-gencode arch=compute_20,code=sm_20 \
                   -gencode arch=compute_30,code=sm_30 \
                   -gencode arch=compute_35,code=sm_35 \
                   -gencode arch=compute_37,code=sm_37 \
                   -gencode arch=compute_50,code=sm_50 \
                   -gencode arch=compute_52,code=sm_52 \
                   -ccbin gcc-5.4 "  ..

GCC 5.4

jrhammon@klondike:~/Work/GPU/GPU-STREAM/build$ /opt/gcc/5.4.0/bin/g++-5.4   -DACC -I/home/jrhammon/Work/GPU/GPU-STREAM/build  -g -O3 -std=gnu++11 -fopenmp -fopenacc -Wall -Wextra -O3 -DNDEBUG   -std=gnu++11 -o CMakeFiles/gpu-stream-acc.dir/main.cpp.o -c /home/jrhammon/Work/GPU/GPU-STREAM/main.cpp
In file included from /home/jrhammon/Work/GPU/GPU-STREAM/ACCStream.h:15:0,
                 from /home/jrhammon/Work/GPU/GPU-STREAM/main.cpp:32:
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:69:40: error: expected primary-expression before ‘)’ token
 int acc_get_num_devices (acc_device_t) __GOACC_NOTHROW;
                                        ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:70:41: error: expected primary-expression before ‘)’ token
 void acc_set_device_type (acc_device_t) __GOACC_NOTHROW;
                                         ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:71:41: error: expected primary-expression before ‘)’ token
 acc_device_t acc_get_device_type (void) __GOACC_NOTHROW;
                                         ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:72:45: error: expected primary-expression before ‘)’ token
 void acc_set_device_num (int, acc_device_t) __GOACC_NOTHROW;
                                             ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:73:39: error: expected primary-expression before ‘)’ token
 int acc_get_device_num (acc_device_t) __GOACC_NOTHROW;
                                       ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:74:26: error: expected primary-expression before ‘)’ token
 int acc_async_test (int) __GOACC_NOTHROW;
                          ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:75:31: error: expected primary-expression before ‘)’ token
 int acc_async_test_all (void) __GOACC_NOTHROW;
                               ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:76:21: error: expected primary-expression before ‘)’ token
 void acc_wait (int) __GOACC_NOTHROW;
                     ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:77:32: error: expected primary-expression before ‘)’ token
 void acc_wait_async (int, int) __GOACC_NOTHROW;
                                ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:78:26: error: expected primary-expression before ‘)’ token
 void acc_wait_all (void) __GOACC_NOTHROW;
                          ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:79:31: error: expected primary-expression before ‘)’ token
 void acc_wait_all_async (int) __GOACC_NOTHROW;
                               ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:80:30: error: expected primary-expression before ‘)’ token
 void acc_init (acc_device_t) __GOACC_NOTHROW;
                              ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:81:34: error: expected primary-expression before ‘)’ token
 void acc_shutdown (acc_device_t) __GOACC_NOTHROW;
                                  ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:82:34: error: expected primary-expression before ‘)’ token
 int acc_on_device (acc_device_t) __GOACC_NOTHROW;
                                  ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:83:27: error: expected primary-expression before ‘)’ token
 void *acc_malloc (size_t) __GOACC_NOTHROW;
                           ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:84:24: error: expected primary-expression before ‘)’ token
 void acc_free (void *) __GOACC_NOTHROW;
                        ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:87:35: error: expected primary-expression before ‘)’ token
 void *acc_copyin (void *, size_t) __GOACC_NOTHROW;
                                   ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:88:46: error: expected primary-expression before ‘)’ token
 void *acc_present_or_copyin (void *, size_t) __GOACC_NOTHROW;
                                              ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:89:35: error: expected primary-expression before ‘)’ token
 void *acc_create (void *, size_t) __GOACC_NOTHROW;
                                   ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:90:46: error: expected primary-expression before ‘)’ token
 void *acc_present_or_create (void *, size_t) __GOACC_NOTHROW;
                                              ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:91:35: error: expected primary-expression before ‘)’ token
 void acc_copyout (void *, size_t) __GOACC_NOTHROW;
                                   ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:92:34: error: expected primary-expression before ‘)’ token
 void acc_delete (void *, size_t) __GOACC_NOTHROW;
                                  ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:93:41: error: expected primary-expression before ‘)’ token
 void acc_update_device (void *, size_t) __GOACC_NOTHROW;
                                         ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:94:39: error: expected primary-expression before ‘)’ token
 void acc_update_self (void *, size_t) __GOACC_NOTHROW;
                                       ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:95:44: error: expected primary-expression before ‘)’ token
 void acc_map_data (void *, void *, size_t) __GOACC_NOTHROW;
                                            ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:96:30: error: expected primary-expression before ‘)’ token
 void acc_unmap_data (void *) __GOACC_NOTHROW;
                              ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:97:30: error: expected primary-expression before ‘)’ token
 void *acc_deviceptr (void *) __GOACC_NOTHROW;
                              ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:98:28: error: expected primary-expression before ‘)’ token
 void *acc_hostptr (void *) __GOACC_NOTHROW;
                            ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:99:37: error: expected primary-expression before ‘)’ token
 int acc_is_present (void *, size_t) __GOACC_NOTHROW;
                                     ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:100:52: error: expected primary-expression before ‘)’ token
 void acc_memcpy_to_device (void *, void *, size_t) __GOACC_NOTHROW;
                                                    ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:101:54: error: expected primary-expression before ‘)’ token
 void acc_memcpy_from_device (void *, void *, size_t) __GOACC_NOTHROW;
                                                      ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:109:42: error: expected primary-expression before ‘)’ token
 void *acc_get_current_cuda_device (void) __GOACC_NOTHROW;
                                          ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:110:43: error: expected primary-expression before ‘)’ token
 void *acc_get_current_cuda_context (void) __GOACC_NOTHROW;
                                           ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:111:33: error: expected primary-expression before ‘)’ token
 void *acc_get_cuda_stream (int) __GOACC_NOTHROW;
                                 ^
/opt/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/openacc.h:112:39: error: expected primary-expression before ‘)’ token
 int acc_set_cuda_stream (int, void *) __GOACC_NOTHROW;
                                       ^

GCC 6.2

jrhammon@klondike:~/Work/GPU/GPU-STREAM/build$ g++-6.2   -DACC -I/home/jrhammon/Work/GPU/GPU-STREAM/build  -g -O3 -std=gnu++11 -fopenmp -fopenacc -Wall -Wextra -O3 -DNDEBUG   -std=gnu++11 -o CMakeFiles/gpu-stream-acc.dir/main.cpp.o -c /home/jrhammon/Work/GPU/GPU-STREAM/main.cpp
@tomdeakin
Copy link
Contributor

The restrict / __restrict__ issue is a nuicense. For some compilers, we require restrict for correct parallelism, on others we must *not have * restrict for correct parallelism.

I also do not think restrict is standard C++ either.

One option is to define our own RESTRICT and set it to nothing, restrict or __restrict__ based on the compiler. I'm not sure this is satisfactory though.

@jeffhammond
Copy link
Contributor Author

If restrict is used correctly, any incorrectness you see with it is a compiler bug.

And no, restrict isn't ISO C++. It's just supported by every widely used C++ compiler.

@tomdeakin
Copy link
Contributor

Should be fixed in #202

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants