oneapi-src / oneCCL

oneAPI Collective Communications Library (oneCCL)
https://oneapi-src.github.io/oneCCL
Other
193 stars 70 forks source link

Issue on page /introduction/sample.html #66

Closed aditikau closed 2 years ago

aditikau commented 2 years ago

Getting error while compiling the given oneCCL code.

sample.cpp:52:9: error: use of class template 'host_accessor' requires template arguments host_accessor send_buf_acc(send_buf, write_only); ^

Full Trace: DUT683-CYP-Mell:/home/gta/ksatya/tests # clang++ -I${CCL_ROOT}/examples/include/ -I/opt/intel/oneapi/compiler/2021.4.0/liycl/ -I${CCL_ROOT}/include -L${CCL_ROOT}/lib/ -lsycl -lccl -o sample sample.cpp sample.cpp:52:9: error: use of class template 'host_accessor' requires template arguments host_accessor send_buf_acc(send_buf, sycl::write_only); ^ /opt/intel/oneapi/compiler/2021.4.0/linux/include/sycl/CL/sycl/accessor.hpp:2134:7: note: template is declared here class host_accessor ^ sample.cpp:53:9: error: use of class template 'host_accessor' requires template arguments host_accessor recv_buf_acc(recv_buf, sycl::write_only); ^ /opt/intel/oneapi/compiler/2021.4.0/linux/include/sycl/CL/sycl/accessor.hpp:2134:7: note: template is declared here class host_accessor ^ sample.cpp:62:9: error: use of class template 'accessor' requires template arguments accessor send_buf_acc(send_buf, h, write_only); ^ /opt/intel/oneapi/compiler/2021.4.0/linux/include/sycl/CL/sycl/accessor.hpp:784:7: note: template is declared here class accessor : ^ sample.cpp:75:9: error: use of class template 'accessor' requires template arguments accessor recv_buf_acc(recv_buf, h, write_only); ^ /opt/intel/oneapi/compiler/2021.4.0/linux/include/sycl/CL/sycl/accessor.hpp:784:7: note: template is declared here class accessor : ^ sample.cpp:88:9: error: use of class template 'host_accessor' requires template arguments host_accessor recv_buf_acc(recv_buf, read_only); ^ /opt/intel/oneapi/compiler/2021.4.0/linux/include/sycl/CL/sycl/accessor.hpp:2134:7: note: template is declared here class host_accessor ^ In file included from sample.cpp:1: In file included from /opt/intel/oneapi/ccl/2021.4.0/examples/include/sycl_base.hpp:17: In file included from /opt/intel/oneapi/compiler/2021.4.0/linux/include/sycl/CL/sycl.hpp:15: In file included from /opt/intel/oneapi/compiler/2021.4.0/linux/include/sycl/CL/sycl/backend.hpp:25: /opt/intel/oneapi/compiler/2021.4.0/linux/include/sycl/CL/sycl/queue.hpp:226:12: error: no matching member function for ct_impl' return submit_impl(CGF, CodeLoc); ^~~ sample.cpp:61:7: note: in instantiation of function template specialization 'sycl::queue::submit<(lambda at sample.cpp:61ted here q.submit([&](auto &h) { ^ /opt/intel/oneapi/compiler/2021.4.0/linux/include/sycl/CL/sycl/queue.hpp:948:9: note: candidate function not viable: no kon from '(lambda at sample.cpp:61:14)' to 'std::function<void (handler &)>' for 1st argument event submit_impl(std::function<void(handler &)> CGH, ^ /opt/intel/oneapi/compiler/2021.4.0/linux/include/sycl/CL/sycl/queue.hpp:951:9: note: candidate function not viable: requnts, but 2 were provided event submit_impl(std::function<void(handler &)> CGH, queue secondQueue, ^ /opt/intel/oneapi/compiler/2021.4.0/linux/include/sycl/CL/sycl/queue.hpp:226:12: error: no matching member function for ct_impl' return submit_impl(CGF, CodeLoc); ^~~ sample.cpp:74:7: note: in instantiation of function template specialization 'sycl::queue::submit<(lambda at sample.cpp:74ted here q.submit([&](auto &h) { ^ /opt/intel/oneapi/compiler/2021.4.0/linux/include/sycl/CL/sycl/queue.hpp:948:9: note: candidate function not viable: no kon from '(lambda at sample.cpp:74:14)' to 'std::function<void (handler &)>' for 1st argument event submit_impl(std::function<void(handler &)> CGH, ^ /opt/intel/oneapi/compiler/2021.4.0/linux/include/sycl/CL/sycl/queue.hpp:951:9: note: candidate function not viable: requnts, but 2 were provided event submit_impl(std::function<void(handler &)> CGH, queue secondQueue, ^ 7 errors generated.

alex-anenkov commented 2 years ago

Hi @aditikau Thanks. It looks like there are some issues in this guide.

It will be easier if you just do:

source /opt/intel/oneapi/compiler/latest/env/vars.sh
source <ccl_install_dir>/env/setvars.sh
dpcpp sample.cpp -o sample -I<ccl_src_dir>/examples/include -lccl -lmpi
aditikau commented 2 years ago

Hi @alex-anenkov, I ran the steps given by you, but added the header path to mpi as well, as it was throwing mpi errors. ( Why we need to specify the headers separately, shouldn't they be available with just /oneapi/setvars.sh ? )

  1. source /opt/intel/oneapi/compiler/latest/env/vars.sh
  2. source /opt/intel/oneapi/ccl/latest/env/vars.sh
  3. dpcpp sample.cpp -o sample -I/opt/intel/oneapi/ccl/2021.4.0/examples/include -I/opt/intel/oneapi/mpi/2021.4.0/include/ -lccl -lmpi

I'm getting linking error now -

`DUT683-CYP-Mell:/home/gta/ksatya/tests # dpcpp sample.cpp -o sample -I/opt/intel/oneapi/ccl/2021.4.0/examples/include -I/opt/intel/oneapi/mpi/2021.4.0/include/ -lccl -lmpi

/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: cannot find -lmpi
dpcpp: error: linker command failed with exit code 1 (use -v to see invocation)
DUT683-CYP-Mell:/home/gta/ksatya/tests #`
aditikau commented 2 years ago

So, I tried it again after source mpi separately.

  1. source /opt/intel/oneapi/compiler/latest/env/vars.sh
  2. source /opt/intel/oneapi/ccl/latest/env/vars.sh
  3. source /opt/intel/oneapi/mpi/latest/env/vars.sh
  4. dpcpp sample.cpp -o sample -I/opt/intel/oneapi/ccl/2021.4.0/examples/include -I/opt/intel/oneapi/mpi/2021.4.0/include/ -lccl -lmpi

It worked fine.

Now, my question is, why do we need to source ccl and mpi separately ?

DUT683-CYP-Mell:/home/gta/ksatya/tests # source /opt/intel/oneapi/compiler/latest/env/vars.sh
DUT683-CYP-Mell:/home/gta/ksatya/tests # source /opt/intel/oneapi/ccl/latest/env/vars.sh
DUT683-CYP-Mell:/home/gta/ksatya/tests # source /opt/intel/oneapi/mpi/latest/env/vars.sh
DUT683-CYP-Mell:/home/gta/ksatya/tests # dpcpp sample.cpp -o sample -I/opt/intel/oneapi/ccl/2021.4.0/examples/include -I/opt/intel/oneapi/mpi/2021.4.0/include/ -lccl -lmpi
DUT683-CYP-Mell:/home/gta/ksatya/tests # mpirun -n 2 ./sample gpu
2021:11:02-03:23:07:(63366) |WARN| loaded MPI version (2021) is higher or equal to minimal expected version (2019) but kind (release) doesn't match with expected kind (release_mt), consider to switch to Intel(R) MPI Library 2019 (min version) release_mt

2021:11:02-03:23:07:(63367) |WARN| loaded MPI version (2021) is higher or equal to minimal expected version (2019) but kind (release) doesn't match with expected kind (release_mt), consider to switch to Intel(R) MPI Library 2019 (min version) release_mt

preferred platform: [Intel(R) Level-Zero]
platform: [Intel(R) Level-Zero]
-- device [Intel(R) Graphics [0x020a]] should provide 2 sub-devices
-- device [Intel(R) Graphics [0x020a]] provides 2 sub-devices
---- sub-device 0: [Intel(R) Graphics [0x020a]]
---- sub-device 1: [Intel(R) Graphics [0x020a]]
found: 2 GPU device(s)
Created context from devices of type: gpu
Devices [1]:
[0]: [Intel(R) Graphics [0x020a]]
preferred platform: [Intel(R) Level-Zero]
platform: [Intel(R) Level-Zero]
-- device [Intel(R) Graphics [0x020a]] should provide 2 sub-devices
-- device [Intel(R) Graphics [0x020a]] provides 2 sub-devices
---- sub-device 0: [Intel(R) Graphics [0x020a]]
---- sub-device 1: [Intel(R) Graphics [0x020a]]
found: 2 GPU device(s)
Created context from devices of type: gpu
Devices [1]:
[0]: [Intel(R) Graphics [0x020a]]
PASSED
PASSED
DUT683-CYP-Mell:/home/gta/ksatya/tests #
`
alex-anenkov commented 2 years ago

Now, my question is, why do we need to source ccl and mpi separately ?

This is because you are using the oneAPI package. In this case, it is easier to use source /opt/intel/oneapi/setvars.sh https://www.intel.com/content/www/us/en/develop/documentation/get-started-with-intel-oneapi-base-linux/top/run-a-sample-project-using-the-command-line.html. Also oneCCL can be used as a standalone product (from the repository), then it has its own setvars.sh with all dependencies.

aditikau commented 2 years ago

Also oneCCL can be used as a standalone product (from the repository), then it has its own setvars.sh with all dependencies.

Noted, @alex-anenkov.

I was thinking as both MPI and CCL are a part of oneAPI, only oneAPI sourcing should be enough. But it looks like we need separate sourcing here. Also, can you please update the commands in page as well.

alex-anenkov commented 2 years ago

Also, can you please update the commands in page as well.

Do you mean this page https://oneapi-src.github.io/oneCCL/introduction/sample.html ? I have reported this issue.

I was thinking as both MPI and CCL are a part of oneAPI, only oneAPI sourcing should be enough. But it looks like we need separate sourcing here.

For oneAPI if you want all inclusive:

source /opt/intel/oneapi/setvars.sh

For oneAPI if you want separately:

source /opt/intel/oneapi/compiler/latest/env/vars.sh
source /opt/intel/oneapi/mpi/latest/env/vars.sh
source /opt/intel/oneapi/ccl/latest/env/vars.sh

For standalone oneCCL from the repo:

source /opt/intel/oneapi/compiler/latest/env/vars.sh
source <ccl_install_dir>/env/setvars.sh
mshiryaev commented 2 years ago

@aditikau - sample page was updated https://oneapi-src.github.io/oneCCL/introduction/sample.html

aditikau commented 2 years ago

Thanks @mshiryaev 👍