Intel® oneAPI Base Toolkit
Support for the core tools and libraries within the base toolkit that are used to build and deploy high-performance data-centric applications.
417 Discussions

dpct/dpct.hpp (device.hpp) requires c++17 feature

yhmtsai
Beginner
2,036 Views

Hi,

Is C++17 in the dpct requirement?

If I compile the following codes with -std=c++14 or -std=c++17 on devcloud, compilation will fail.

#include <CL/sycl.hpp>
#include <dpct/dpct.hpp>
#include <iostream>

int main() {
    std::cout << "Hello Devcloud" << std::endl;
    return 0;
}


The compile command:

dpcpp hello.dp.cpp -std=c++11
dpcpp hello.dp.cpp -std=c++14
dpcpp hello.dp.cpp -std=c++17



dpct/device.hpp uses std::max_element which is introduced in C++17.

The error message:

In file included from hello.dp.cpp:2:
In file included from /glob/development-tools/versions/oneapi/beta09/inteloneapi/dpcpp-ct/2021.1-beta09/include/dpct/dpct.hpp:27:
/glob/development-tools/versions/oneapi/beta09/inteloneapi/dpcpp-ct/2021.1-beta09/include/dpct/device.hpp:218:16: error: no member named 'max_element' in namespace 'std'
          std::max_element(sub_group_sizes.begin(), sub_group_sizes.end());
          ~~~~~^
1 error generated.

 

Thanks,
Mike

0 Kudos
1 Solution
GouthamK_Intel
Moderator
2,015 Views

Hi Mike,

Yes, dpct headers require C++17, as some of the std algorithms in those dpct header files are based on C++17 standard.


And regarding "If I compile the following codes with -std=c++14 or -std=c++17 on devcloud, compilation will fail."

we assume that you meant -std=c++11 and -std=c++14 gives compilation error.

We have compiled your code on devcloud with c++11, c++14, c++17 and we observed that c++11 and c++14 gives errors. Whereas, code compiles, and executes successfully with -std=c++17.

Also, by default devcloud uses c++17 standard, so there is no need to use --std flag.


If you are facing this issue with -std=c++17 itself then please provide the error logs.


Have a Good day!


Regards

Goutham


View solution in original post

0 Kudos
5 Replies
GouthamK_Intel
Moderator
2,016 Views

Hi Mike,

Yes, dpct headers require C++17, as some of the std algorithms in those dpct header files are based on C++17 standard.


And regarding "If I compile the following codes with -std=c++14 or -std=c++17 on devcloud, compilation will fail."

we assume that you meant -std=c++11 and -std=c++14 gives compilation error.

We have compiled your code on devcloud with c++11, c++14, c++17 and we observed that c++11 and c++14 gives errors. Whereas, code compiles, and executes successfully with -std=c++17.

Also, by default devcloud uses c++17 standard, so there is no need to use --std flag.


If you are facing this issue with -std=c++17 itself then please provide the error logs.


Have a Good day!


Regards

Goutham


0 Kudos
yhmtsai
Beginner
2,005 Views

Hi Goutham,

"
If I compile the following codes with -std=c++14 or -std=c++17 on devcloud, compilation will fail."
Yes, I wrote wrong statement here, sorry. it is failed with -std=c++11 and -std=c++14.

I see.
The reason behind this problem is that our project currently is on -std=c++14.
We would like to keep same requirement among different module.
If the requirement is c++17, we probably need to compile whole project with c++17 when enabling intel.
or, compile intel with c++17 and others with c++14. I am not sure whether it work or not.

Thanks,
Mike

0 Kudos
GouthamK_Intel
Moderator
1,967 Views

Hi Mike,

As dpct requires std=C++17, you can try either one of the mentioned methods by you as per your project requirement/ flexibility.

If you face any further challenges or errors, please feel free to raise a new thread.


Could please confirm If we have answered all your queries in the current thread and lets us know if we can close this thread from our side.


Have a Good day!


Thanks & Regards

Goutham


0 Kudos
yhmtsai
Beginner
1,960 Views

Hi Goutham,

Yes, you have answered my questions in this current thread.
Thanks a lot!

Regards,
Mike

0 Kudos
GouthamK_Intel
Moderator
1,951 Views

Hi Mike,

Thanks for the confirmation!

As this issue has been resolved, we will no longer respond to this thread. 

If you require any additional assistance from Intel, please start a new thread. 

Any further interaction in this thread will be considered community only. 


Have a Good day!


Thanks & Regards

Goutham


0 Kudos
Reply