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.

dpc++

wugang
Beginner
1,343 Views

We learned that the new DPC compiler has better performance,So we wanted to try DPC。 However, we encountered some problems. The new compiler was more strict with syntax checking, resulting in many code compilation errors, and ICC had different compilation options than DPC; I don't know how to get the compiler to ignore these errors;

 

for example: ./pl_rx_pub/PUSCH/src/fde_sch_const.c:1919:117: error: constant expression evaluates to 50311 which cannot be narrowed to type 'Sshort' (aka 'short') [-Wc++11-narrowing] 0x7fff, 0x7fff, 0x7856, 0x6885, 0x58b0, 0x48e4, 0x392f, 0x299e, 0x1a3c, 0x0b18, 0xfc3c, 0xedb5, 0xdf8d, 0xd1d0, 0xc487, 0xb7be,

 

This error is just one of a number of grammar errors that would normally be ignored

0 Kudos
6 Replies
ShivaniK_Intel
Moderator
1,312 Views

Hi,

 

Thanks for reaching out to us.

 

Could you please provide the OS details and Intel one API DPC++ version you are using?

  

Could you also provide the sample reproducer code and the steps to reproduce the issue from our side?

  

Can we also have the complete error log/screenshot to understand better?

 

Meanwhile, you can refer to the below link for the compilation options in DPCPP

 

https://software.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compiler-reference/compiler-options/alphabetical-list-of-compiler-options.html

  

Thanks & Regards

Shivani

 

0 Kudos
wugang
Beginner
1,301 Views

Thank you for your reply,my os version is centos7,and oneapi version is 2021.03;
My error code is as follows:

Sshort Gxxxx[20] = {0x7fff, 0x7fff, 0x7856, 0x6885, 0x58b0, 0x48e4, 0x392f, 0x299e, 0x1a3c, 0x0b18, 0xfc3c, 0xedb5, 0xdf8d, 0xd1d0, 0xc487, 0xb7be};

The error message is:
./pl_rx_pub/PUSCH/src/fde_sch_const.c:1919:117: error: constant expression evaluates to 50311 which cannot be narrowed to type 'Sshort' (aka 'short') [-Wc++11-narrowing] 0x7fff, 0x7fff, 0x7856, 0x6885, 0x58b0, 0x48e4, 0x392f, 0x299e, 0x1a3c, 0x0b18, 0xfc3c, 0xedb5, 0xdf8d, 0xd1d0, 0xc487, 0xb7be,

the 0xc487 is 50311,The compiler might think that this number is +50311, which cannot be represented by Sshort;
If I changed the code like this:
Sshort Gxxxx[20] = {(Sshort)0x7fff, (Sshort)0x7fff....

I might not get an error, but there's a lot of it, and I hope the compiler can ignore it


This code does not report an error in ICC;

 

0 Kudos
ShivaniK_Intel
Moderator
1,224 Views

Hi,

 

 

Thanks for providing the requested details.

 

We can see that you are using CentOS 7 which is not listed under DPC++ supported OS. Please refer to the below system requirements page for more details.

 

https://software.intel.com/content/www/us/en/develop/articles/intel-oneapi-dpcpp-system-requirements.html 

 

Regarding the new compiler: DPCPP Compiler(Clang) is a stricter compiler than ICC and the errors(syntax errors) which you are facing are expected. Currently, there are no flags to suppress these errors and there is no way to avoid them. 

 

We suggest you refine the code and try running it.

 

Please let us know if you face any further issues. 

 

Thanks & Regards

Shivani

 

0 Kudos
Viet_H_Intel
Moderator
1,216 Views

You can try  -Wno-c++11-narrowing,

$ dpcpp foo.cpp -c

foo.cpp:4:17: error: constant expression evaluates to 50311 which cannot be narrowed to type 'short'

    short a[2] = { 0xc487, 0xb7be};

            ^~~~~~

foo.cpp:4:17: note: insert an explicit cast to silence this issue

    short a[2] = { 0xc487, 0xb7be};

            ^~~~~~

            static_cast<short>( )

foo.cpp:4:25: error: constant expression evaluates to 47038 which cannot be narrowed to type 'short'

    short a[2] = { 0xc487, 0xb7be};

                ^~~~~~

foo.cpp:4:25: note: insert an explicit cast to silence this issue

    short a[2] = { 0xc487, 0xb7be};

                ^~~~~~

                static_cast<short>( )

2 errors generated.

$ dpcpp foo.cpp -Wno-c++11-narrowing

$ cat foo.cpp

#include<stdio.h>


int main () {

    short a[2] = { 0xc487, 0xb7be};

    printf (" %d and %d \n", a[0], a[1]);

    return 0;

}




0 Kudos
ShivaniK_Intel
Moderator
1,142 Views

Hi,


Could you please try the workaround provided in the previous post by Viet_H_Intel and get back to us with an update? If you face any issues please let us know.


Thanks & Regards

Shivani


0 Kudos
ShivaniK_Intel
Moderator
1,073 Views

Hi,


As I have not heard back from you. This thread will no longer be monitored by Intel. If you need further assistance, please post a new question.


Thanks & Regards

Shivani


0 Kudos
Reply