Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Diagnostic 3180: unrecognized OpenMP #pragma

maeshiro_mi
Beginner
4,209 Views

The test code below worked with Intel Composer 2013 but not with SP1 Update 5,
and gives me "Diagnostic 3180: unrecognized OpenMP #pragma".
Thanks in advance.]

// OpenMPTest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <map>
#include <omp.h>

int _tmain(int argc, _TCHAR* argv[])
{
	std::map<int, int> box;
	box[0] = 0;
	box[1] = 0;
	box[2] = 0;

#pragma omp parallel for
	for (auto iter = box.begin(); iter != box.end(); ++iter) {
		(*iter).second = rand();
	}
	return 0;
}

 

0 Kudos
1 Solution
Shenghong_G_Intel
4,209 Views

Hi maeshiro_mi,

I was talking about the warning "Diagnostic 3180: unrecognized OpenMP #pragma". If your build on command line for this code with /Qopenmp, and also have this warning, this is unexpected. If this is the case for you, it is really strange, maybe some strange environment issue.

Regarding this "v13:compiled successfully but no paralleled threads", for your simple test case, Intel compiler may optimized the whole loop away, I wonder whether there is any code generated for it. Whatever, you may add some more code (example: print the vector content) to avoid optimization away the code, and check carefully. If you do think compiler is not generating parallel code, you may let me know more details (how you build, how you run, and how you check that no parallel threads etc.)  I can explain it to you then. :)

Thanks,

Shenghong

View solution in original post

0 Kudos
7 Replies
Shenghong_G_Intel
4,209 Views

Hi maeshiro_mi,

First of all, I'd suggest you to upgrade to v16.0 compiler if possible. 2013 SP1 is rather old version (we have 2015 later, and now 2016 initial release is also activated.) So, we'll not have any bug fix for 2013 SP1 version.

Then, regarding the issue you mentioned, I've also tested with v16.0 initial release in VS2015. You need to be noted that, to support OpenMP pragma, you need to open "/Qopenmp" option in command line, or set the project properties in VS "Project Properties -> Configuration Properties -> C/C++ -> Language [Intel C++] -> OpenMP Support -> Generate Parallel Code (/Qopenmp)". With this, the warning will go away. But to be mentioned, your code is invalid OpenMP code, and it will report an error. I've tested the same code with GCC, Visual Studio, both will fail with OpenMP enabled.

To be noted also, if you test it with Visual Studio, it will not report this warning! And Visual Studio just ignores this pragmas, this may not be a good behaviour (though GCC also will not warn on it). Whatever, I think most OpenMP users may like to get the warning in case they forget to enable OpenMP. For none-openmp users, they'll never write OpenMP code...

Hope it's clear. Let me know if you are clear and your thoughts.

Summary:

Without OpenMP: GCC/VS build without any warning, ICC will warn and I think ICC behaviours better here.

With OpenMP: ICC/GCC/VS all will get error, as this code is invalid OpenMP code.

Thanks,

Shenghong

 

0 Kudos
maeshiro_mi
Beginner
4,209 Views

Thanks Shenghong for your help.

I'm working on old systems built with 2013(v13) or 2013SP1(v14).
What I'm trying to do is to upgrade all v13 systems to v14 so we can deal only with v14.

The OpenMP code can be compiled successfully with v13. (Qopenmp enabled)
But when I change the compiler to v14, fails with "
Diagnostic 3180: unrecognized OpenMP #pragma".
(Configuration Properties->General->Platform Toolset: Intel C++ Compiler XE 13.0  >>  Intel C++ Compiler XE 14.0)

As you said, my test code seems to be invalid(maybe, std::map cannot be used with parallel for?)
because when I change std::map to std::vector, v13 compiles it successfully.

I'll try changing std::map to other options.
Thanks again.

 

0 Kudos
Shenghong_G_Intel
4,209 Views

Hi maeshiro_mi,

The OpenMP code can be compiled successfully with v13. (Qopenmp enabled)
But when I change the compiler to v14, fails with "Diagnostic 3180: unrecognized OpenMP #pragma".
(Configuration Properties->General->Platform Toolset: Intel C++ Compiler XE 13.0  >>  Intel C++ Compiler XE 14.0)

Shenghong's notes ->> Did you also double-confirm that /Qopenmp is still enabled? I wonder whether it is because when you switch the platform toolset, the flags are not carried over? (this is just a guess, as I've tested with v15.0 and v16.0, when I switch it, the flags will be carried over.)

Whatever, please double check and you may also try on command line, it seems more like a configuration issue for the IDE. I do not think v14.0 will fail even when /Qstd=openmp enabled (if that is the case, I guess it is reported and fixed at very beginning! :) )

 

As you said, my test code seems to be invalid(maybe, std::map cannot be used with parallel for?)
because when I change std::map to std::vector, v13 compiles it successfully.

Shenghong's notes ->> Yes, the code is invalid when using std::map. The main reason is, for "for (auto iter = box.begin(); iter != box.end(); ++iter) {" part, compiler needs to split the tasks to run parallelly, Intel compiler used the "operate-" for this case (you can also get this from the error message it reported). For GCC and VS, even std::vector cannot work (I've tested), it seems like they have more strict requirement, VS requires it to be signed integer. I think Intel compiler implements it better here. Using map is impossible to split the tasks I think.

Below is the code accepted by all compilers:

#include <vector>
#include <map>
#include <omp.h>

int main()
{
	std::vector<int> box;
	//std::map<int, int> box;
	box[0] = 0;
	box[1] = 0;
	box[2] = 0;

#pragma omp parallel for
	for (int i = 0; i < box.size(); ++i) {
		//for (auto iter = box.begin(); iter != box.end(); ++iter) {
			//*iter = rand();
		box = rand();
	}
	return 0;
}

Hope it helps.

Thanks,

Shenghong

0 Kudos
maeshiro_mi
Beginner
4,209 Views

Hi Shenghong,

The "\Qopenmp" option is absolutely enabled.
As you suggested, I tried with Command Prompt(icl /Qopenmp OpenMPTest.cpp) but nothing changed.
(v13:compiled successfully but no paralleled threads / v14:Same Error)

Maybe something is wrong with my environment.

Anyway, it seems that I have to consider using other containers.

Thank you for your help.

 

0 Kudos
Shenghong_G_Intel
4,210 Views

Hi maeshiro_mi,

I was talking about the warning "Diagnostic 3180: unrecognized OpenMP #pragma". If your build on command line for this code with /Qopenmp, and also have this warning, this is unexpected. If this is the case for you, it is really strange, maybe some strange environment issue.

Regarding this "v13:compiled successfully but no paralleled threads", for your simple test case, Intel compiler may optimized the whole loop away, I wonder whether there is any code generated for it. Whatever, you may add some more code (example: print the vector content) to avoid optimization away the code, and check carefully. If you do think compiler is not generating parallel code, you may let me know more details (how you build, how you run, and how you check that no parallel threads etc.)  I can explain it to you then. :)

Thanks,

Shenghong

0 Kudos
maeshiro_mi
Beginner
4,209 Views

Hi Shenghong,

I'm really sorry, I made a big mistake.
The error message when compiled with v14 is
1>  Building with Intel(R) C++ Compiler XE 14.0
1>ClCompile:
1>  ***** ClCompile (x64 - Intel C++)
1>  stdafx.cpp
1>  OpenMPTest.cpp
1>OpenMPTest.cpp(17): error : no operator "-" matches these operands
1>              operand types are: const std::_Tree_iterator<std::_Tree_val<std::_Tmap_traits<int, int, std::less<int>, std::allocator<std::pair<const int, int>>, 0>>> - std::_Tree_iterator<std::_Tree_val<std::_Tmap_traits<int, int, std::less<int>, std::allocator<std::pair<const int, int>>, 0>>>
1>        for (auto iter = box.begin(); iter != box.end(); ++iter) {
1>                                      ^
1>  
1>  compilation aborted for OpenMPTest.cpp (code 2)
1>
1>Build FAILED.

v13 compiles the same code successfully but no paralleled threads.
(Checked by adding omp_get_thread_num() inside the for loop)
I should checked if the for loop was paralleled or not.

Finally, I got my test code paralleled.

    std::map<int, int> box;
    box[0] = 0;
    box[1] = 0;
    box[2] = 0;
#pragma omp parallel for
	for (int i = 0; i < box.size(); i++) {
		box = omp_get_thread_num();
		printf("ID:%d\n", box);
	}

Again, I'm really sorry for my mistake here.

0 Kudos
Shenghong_G_Intel
4,209 Views

Hi maeshiro_mi,

Thank you for your update. Now, everything makes sense and is clear. :)

Thanks,

Shenghong

0 Kudos
Reply