From 69a2cba490d346267f32a98a31ba8a843f84a790 Mon Sep 17 00:00:00 2001 From: khizmax Date: Tue, 30 Sep 2014 22:50:40 +0400 Subject: [PATCH] Add support for Intel C++ compiler for Linux (icc 15) --- build/build.sh | 60 +++++++++++++++++-- cds/compiler/icl/compiler_barriers.h | 33 +++++----- cds/compiler/icl/defs.h | 4 +- cds/container/striped_map/std_hash_map.h | 2 +- cds/container/striped_set/std_hash_set.h | 2 +- cds/details/defs.h | 2 +- cds/threading/details/msvc_manager.h | 2 +- .../map/hdr_refinable_hashmap_hashmap_std.cpp | 2 +- .../map/hdr_refinable_hashmap_hashmap_vc.cpp | 2 +- .../map/hdr_striped_hashmap_hashmap_std.cpp | 2 +- .../map/hdr_striped_hashmap_hashmap_vc.cpp | 2 +- tests/test-hdr/misc/hash_tuple.cpp | 2 +- .../set/hdr_refinable_hashset_hashset_std.cpp | 2 +- .../set/hdr_refinable_hashset_hashset_vc.cpp | 2 +- .../set/hdr_striped_hashset_hashset_std.cpp | 2 +- .../set/hdr_striped_hashset_hashset_vc.cpp | 2 +- tests/unit/map2/map_types.h | 4 +- tests/unit/set2/set_types.h | 6 +- tests/unit/set2/std_hash_set.h | 2 +- 19 files changed, 91 insertions(+), 44 deletions(-) diff --git a/build/build.sh b/build/build.sh index 5048d6ab..7e79549d 100644 --- a/build/build.sh +++ b/build/build.sh @@ -18,7 +18,7 @@ usage() echo "Usage: build.sh \"options\"" echo " where options may be any of the following:" echo " -t make target" - echo " -c Possible values are: gcc,clang" + echo " -c Possible values are: gcc,clang,icc" echo " -x (e.g. g++, CC)" echo " -p Possible values are:" echo " x86, amd64 (x86_64), sparc, ia64" @@ -208,6 +208,11 @@ case $ccompiler in cppcompiler=clang++ fi ;; + icc) + if test $cppcompiler = ''; then + cppcompiler=icc + fi + ;; *) echo "ERROR: Unknown compiler: $ccompiler" exit $ERROR_EXIT_CODE @@ -389,13 +394,49 @@ case $ccompiler in ;; esac - cppcompiler_version=`$cppcompiler -dumpversion` - echo g++ version=$gcc_version + #cppcompiler_version=`$cppcompiler -dumpversion` + #echo compiler version=$cppcompiler $cppcompiler_version # Setup target options # buildCXXflags="-std=gnu++0x $buildCXXflags" - cxx_debug_options="-D_DEBUG -O0 -g $cxx_debug_options" - cxx_release_options="-DNDEBUG $cxx_release_optimization $cxx_release_options" + #cxx_debug_options="-D_DEBUG -O0 -g $cxx_debug_options" + #cxx_release_options="-DNDEBUG $cxx_release_optimization $cxx_release_options" + ;; + icc) + case $processor_arch in + amd64) + case $OS_FAMILY in + linux) + buildCXXflags="-fPIC -march=$ArchFlag $amd64_cxx_options" + buildCflags="-fPIC -march=$ArchFlag $amd64_cxx_options" + buildLDflags="-fPIC" + buildTestLDflags="-fPIC" + ;; + *) + echo "Warning: cannot determine compiler flags for processor $processor_arch, OS $OS_FAMILY, and compiler $ccompiler" + #exit ${ERROR_EXIT_CODE} + ;; + esac + ;; + x86) + case $OS_FAMILY in + linux) + buildCXXflags="-fPIC -march=$ArchFlag" + buildCflags="-fPIC -march=$ArchFlag" + buildLDflags="-fPIC" + buildTestLDflags="-fPIC" + ;; + *) + echo "Warning: cannot determine compiler flags for processor $processor_arch, OS $OS_FAMILY, and compiler $ccompiler" + #exit ${ERROR_EXIT_CODE} + ;; + esac + ;; + *) + echo "Warning: cannot determine compiler flags for processor $processor_arch and compiler $ccompiler" + #exit ${ERROR_EXIT_CODE} + ;; + esac ;; *) echo "ERROR: Unknown compiler: $ccompiler" @@ -403,6 +444,15 @@ case $ccompiler in ;; esac +cppcompiler_version=`$cppcompiler -dumpversion` +echo compiler version=$cppcompiler $cppcompiler_version + +# Setup target options +# buildCXXflags="-std=gnu++0x $buildCXXflags" +cxx_debug_options="-D_DEBUG -O0 -g $cxx_debug_options" +cxx_release_options="-DNDEBUG $cxx_release_optimization $cxx_release_options" + + if test $BOOST_INCLUDE_PATH != ''; then buildCXXflags="$buildCXXflags -I$BOOST_INCLUDE_PATH" fi diff --git a/cds/compiler/icl/compiler_barriers.h b/cds/compiler/icl/compiler_barriers.h index d06e0143..66d96752 100644 --- a/cds/compiler/icl/compiler_barriers.h +++ b/cds/compiler/icl/compiler_barriers.h @@ -3,28 +3,25 @@ #ifndef __CDS_COMPILER_ICL_COMPILER_BARRIERS_H #define __CDS_COMPILER_ICL_COMPILER_BARRIERS_H -#if _MSC_VER > 0 -# if _MSC_VER < 1700 - // VC++ up to vc10 -# include +#if defined(_MSC_VER) && _MSC_VER < 1700 + // VC++ up to vc10 +# include -# pragma intrinsic(_ReadWriteBarrier) -# pragma intrinsic(_ReadBarrier) -# pragma intrinsic(_WriteBarrier) +# pragma intrinsic(_ReadWriteBarrier) +# pragma intrinsic(_ReadBarrier) +# pragma intrinsic(_WriteBarrier) -# define CDS_COMPILER_RW_BARRIER _ReadWriteBarrier() -# define CDS_COMPILER_R_BARRIER _ReadBarrier() -# define CDS_COMPILER_W_BARRIER _WriteBarrier() +# define CDS_COMPILER_RW_BARRIER _ReadWriteBarrier() +# define CDS_COMPILER_R_BARRIER _ReadBarrier() +# define CDS_COMPILER_W_BARRIER _WriteBarrier() -# else - // MS VC11+ -# include +#else + // MS VC11+, linux +# include -# define CDS_COMPILER_RW_BARRIER std::atomic_thread_fence( std::memory_order_acq_rel ) -# define CDS_COMPILER_R_BARRIER CDS_COMPILER_RW_BARRIER -# define CDS_COMPILER_W_BARRIER CDS_COMPILER_RW_BARRIER - -# endif +# define CDS_COMPILER_RW_BARRIER std::atomic_thread_fence( std::memory_order_acq_rel ) +# define CDS_COMPILER_R_BARRIER CDS_COMPILER_RW_BARRIER +# define CDS_COMPILER_W_BARRIER CDS_COMPILER_RW_BARRIER #endif #endif // #ifndef __CDS_COMPILER_ICL_COMPILER_BARRIERS_H diff --git a/cds/compiler/icl/defs.h b/cds/compiler/icl/defs.h index 9e6e9ec5..ebfd417c 100644 --- a/cds/compiler/icl/defs.h +++ b/cds/compiler/icl/defs.h @@ -36,12 +36,12 @@ #endif // Processor architecture -#if defined(_M_X64) || defined(_M_AMD64) +#if defined(_M_X64) || defined(_M_AMD64) || defined(__amd64__) || defined(__amd64) # define CDS_BUILD_BITS 64 # define CDS_PROCESSOR_ARCH CDS_PROCESSOR_AMD64 # define CDS_PROCESSOR__NAME "AMD64" # define CDS_PROCESSOR__NICK "amd64" -#elif defined(_M_IX86) +#elif defined(_M_IX86) || defined(__i386__) || defined(__i386) # define CDS_BUILD_BITS 32 # define CDS_PROCESSOR_ARCH CDS_PROCESSOR_X86 # define CDS_PROCESSOR__NAME "Intel x86" diff --git a/cds/container/striped_map/std_hash_map.h b/cds/container/striped_map/std_hash_map.h index 7b1fa6bc..dbaf22aa 100644 --- a/cds/container/striped_map/std_hash_map.h +++ b/cds/container/striped_map/std_hash_map.h @@ -4,7 +4,7 @@ #define __CDS_CONTAINER_STRIPED_MAP_STD_HASH_MAP_ADAPTER_H #include -#if (CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600 // MS VC 2008 +#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 // MS VC 2008 # include #else # include diff --git a/cds/container/striped_set/std_hash_set.h b/cds/container/striped_set/std_hash_set.h index fcfb5e99..7ba35e39 100644 --- a/cds/container/striped_set/std_hash_set.h +++ b/cds/container/striped_set/std_hash_set.h @@ -4,7 +4,7 @@ #define __CDS_CONTAINER_STRIPED_SET_STD_HASH_SET_ADAPTER_H #include -#if (CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600 // MS VC 2008 +#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 // MS VC 2008 # include #else # include diff --git a/cds/details/defs.h b/cds/details/defs.h index 97d046b4..ff482c17 100644 --- a/cds/details/defs.h +++ b/cds/details/defs.h @@ -456,7 +456,7 @@ namespace cds { { if ( !bCond ) { char buf[4096]; -# if CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL +# if CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CS_OSI_WINDOWS) _snprintf_s( buf, sizeof(buf)/sizeof(buf[0]), _TRUNCATE, pszMsg, pszFile, nLine ); # else snprintf( buf, sizeof(buf)/sizeof(buf[0]), pszMsg, pszFile, nLine ); diff --git a/cds/threading/details/msvc_manager.h b/cds/threading/details/msvc_manager.h index da29e9c1..c2f4ef05 100644 --- a/cds/threading/details/msvc_manager.h +++ b/cds/threading/details/msvc_manager.h @@ -3,7 +3,7 @@ #ifndef __CDS_THREADING_DETAILS_MSVC_MANAGER_H #define __CDS_THREADING_DETAILS_MSVC_MANAGER_H -#if !( CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL ) +#if !( CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) # error "threading/details/msvc_manager.h may be used only with Microsoft Visual C++ / Intel C++ compiler" #endif diff --git a/tests/test-hdr/map/hdr_refinable_hashmap_hashmap_std.cpp b/tests/test-hdr/map/hdr_refinable_hashmap_hashmap_std.cpp index 4572cb1e..bba2d1f1 100644 --- a/tests/test-hdr/map/hdr_refinable_hashmap_hashmap_std.cpp +++ b/tests/test-hdr/map/hdr_refinable_hashmap_hashmap_std.cpp @@ -5,7 +5,7 @@ #include #include -#if !((CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600) +#if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600) namespace map { diff --git a/tests/test-hdr/map/hdr_refinable_hashmap_hashmap_vc.cpp b/tests/test-hdr/map/hdr_refinable_hashmap_hashmap_vc.cpp index ff1a774d..988532ca 100644 --- a/tests/test-hdr/map/hdr_refinable_hashmap_hashmap_vc.cpp +++ b/tests/test-hdr/map/hdr_refinable_hashmap_hashmap_vc.cpp @@ -5,7 +5,7 @@ #include #include -#if (CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600 +#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 namespace map { diff --git a/tests/test-hdr/map/hdr_striped_hashmap_hashmap_std.cpp b/tests/test-hdr/map/hdr_striped_hashmap_hashmap_std.cpp index aa1e582d..95f3c103 100644 --- a/tests/test-hdr/map/hdr_striped_hashmap_hashmap_std.cpp +++ b/tests/test-hdr/map/hdr_striped_hashmap_hashmap_std.cpp @@ -5,7 +5,7 @@ #include #include -#if !((CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600) +#if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600) namespace map { diff --git a/tests/test-hdr/map/hdr_striped_hashmap_hashmap_vc.cpp b/tests/test-hdr/map/hdr_striped_hashmap_hashmap_vc.cpp index d198454c..cfc5de72 100644 --- a/tests/test-hdr/map/hdr_striped_hashmap_hashmap_vc.cpp +++ b/tests/test-hdr/map/hdr_striped_hashmap_hashmap_vc.cpp @@ -5,7 +5,7 @@ #include #include -#if (CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600 +#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 namespace map { diff --git a/tests/test-hdr/misc/hash_tuple.cpp b/tests/test-hdr/misc/hash_tuple.cpp index e9353a78..470d5c7b 100644 --- a/tests/test-hdr/misc/hash_tuple.cpp +++ b/tests/test-hdr/misc/hash_tuple.cpp @@ -60,7 +60,7 @@ namespace misc { CPPUNIT_ASSERT( val[3] == nHash + 4 ); CPPUNIT_ASSERT( val[4] == nHash + 5 ); -#if !((CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER == 1700) +#if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER == 1700) // MS VC 11: std::tuple suports up to 5 template params only cds::opt::hash< std::tuple< hashing, hash2, hash3, hash4, hash5, hash6 > >::pack::hash h6; diff --git a/tests/test-hdr/set/hdr_refinable_hashset_hashset_std.cpp b/tests/test-hdr/set/hdr_refinable_hashset_hashset_std.cpp index 769d4995..9d7d1ac1 100644 --- a/tests/test-hdr/set/hdr_refinable_hashset_hashset_std.cpp +++ b/tests/test-hdr/set/hdr_refinable_hashset_hashset_std.cpp @@ -5,7 +5,7 @@ #include #include -#if !((CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600) +#if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600) namespace set { diff --git a/tests/test-hdr/set/hdr_refinable_hashset_hashset_vc.cpp b/tests/test-hdr/set/hdr_refinable_hashset_hashset_vc.cpp index 902f2d15..b12a079b 100644 --- a/tests/test-hdr/set/hdr_refinable_hashset_hashset_vc.cpp +++ b/tests/test-hdr/set/hdr_refinable_hashset_hashset_vc.cpp @@ -5,7 +5,7 @@ #include #include -#if (CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600 +#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 namespace stdext { inline size_t hash_value(set::StripedSetHdrTest::item const& _Keyval) diff --git a/tests/test-hdr/set/hdr_striped_hashset_hashset_std.cpp b/tests/test-hdr/set/hdr_striped_hashset_hashset_std.cpp index feb7b259..9f75a3c3 100644 --- a/tests/test-hdr/set/hdr_striped_hashset_hashset_std.cpp +++ b/tests/test-hdr/set/hdr_striped_hashset_hashset_std.cpp @@ -5,7 +5,7 @@ #include #include -#if !((CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600) +#if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600) namespace set { diff --git a/tests/test-hdr/set/hdr_striped_hashset_hashset_vc.cpp b/tests/test-hdr/set/hdr_striped_hashset_hashset_vc.cpp index dbe78e97..1c499ab9 100644 --- a/tests/test-hdr/set/hdr_striped_hashset_hashset_vc.cpp +++ b/tests/test-hdr/set/hdr_striped_hashset_hashset_vc.cpp @@ -5,7 +5,7 @@ #include #include -#if (CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600 +#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 namespace stdext { inline size_t hash_value(set::StripedSetHdrTest::item const& _Keyval) diff --git a/tests/unit/map2/map_types.h b/tests/unit/map2/map_types.h index 761a7233..add04d47 100644 --- a/tests/unit/map2/map_types.h +++ b/tests/unit/map2/map_types.h @@ -3825,7 +3825,7 @@ namespace map2 { , co::less< less > > StripedMap_list; -#if (CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600 +#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 typedef StripedHashMap_ord< stdext::hash_map< Key, Value, stdext::hash_compare > , co::hash< hash2 > @@ -3942,7 +3942,7 @@ namespace map2 { , co::hash< hash2 > > RefinableMap_map; -#if (CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600 +#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 typedef RefinableHashMap_ord< stdext::hash_map< Key, Value, stdext::hash_compare > , co::hash< hash2 > diff --git a/tests/unit/set2/set_types.h b/tests/unit/set2/set_types.h index a88b8604..a2baa7fe 100644 --- a/tests/unit/set2/set_types.h +++ b/tests/unit/set2/set_types.h @@ -284,7 +284,7 @@ namespace set2 { } }; -#if (CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600 +#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 struct hash_less: public stdext::hash_compare< key_type, std::less > { typedef stdext::hash_compare< key_type, std::less > base_class; @@ -3474,7 +3474,7 @@ namespace set2 { , co::hash< hash2 > > StripedSet_set; -#if (CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600 +#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 typedef StripedHashSet_ord< stdext::hash_set< key_val, hash_less > , co::hash< hash2 > @@ -3609,7 +3609,7 @@ namespace set2 { , co::hash< hash2 > > RefinableSet_set; -#if (CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER < 1600 +#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 typedef RefinableHashSet_ord< stdext::hash_set< key_val, hash_less > , co::hash< hash2 > diff --git a/tests/unit/set2/std_hash_set.h b/tests/unit/set2/std_hash_set.h index 49eabe9a..4b89ca0e 100644 --- a/tests/unit/set2/std_hash_set.h +++ b/tests/unit/set2/std_hash_set.h @@ -3,7 +3,7 @@ #ifndef __CDSUNIT_STD_HASH_SET_H #define __CDSUNIT_STD_HASH_SET_H -#if (CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER == 1500 +#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER == 1500 # include "set2/std_hash_set_vc9.h" #else # include "set2/std_hash_set_std.h" -- 2.34.1