Add support for Intel C++ compiler for Linux (icc 15)
authorkhizmax <libcds.dev@gmail.com>
Tue, 30 Sep 2014 18:50:40 +0000 (22:50 +0400)
committerkhizmax <libcds.dev@gmail.com>
Tue, 30 Sep 2014 18:50:40 +0000 (22:50 +0400)
19 files changed:
build/build.sh
cds/compiler/icl/compiler_barriers.h
cds/compiler/icl/defs.h
cds/container/striped_map/std_hash_map.h
cds/container/striped_set/std_hash_set.h
cds/details/defs.h
cds/threading/details/msvc_manager.h
tests/test-hdr/map/hdr_refinable_hashmap_hashmap_std.cpp
tests/test-hdr/map/hdr_refinable_hashmap_hashmap_vc.cpp
tests/test-hdr/map/hdr_striped_hashmap_hashmap_std.cpp
tests/test-hdr/map/hdr_striped_hashmap_hashmap_vc.cpp
tests/test-hdr/misc/hash_tuple.cpp
tests/test-hdr/set/hdr_refinable_hashset_hashset_std.cpp
tests/test-hdr/set/hdr_refinable_hashset_hashset_vc.cpp
tests/test-hdr/set/hdr_striped_hashset_hashset_std.cpp
tests/test-hdr/set/hdr_striped_hashset_hashset_vc.cpp
tests/unit/map2/map_types.h
tests/unit/set2/set_types.h
tests/unit/set2/std_hash_set.h

index 5048d6ab6c06def7628d2ab1505207e03f5346ca..7e79549d583a3d130b1bf9ab828fc03f9014b0ea 100644 (file)
@@ -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 <C compiler name> Possible values are: gcc,clang"
+    echo "       -c <C compiler name> Possible values are: gcc,clang,icc"
     echo "       -x <C++ compiler name> (e.g. g++, CC)"
     echo "       -p <Processor architecture> 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
index d06e01434b42f3f218e92a725dcc4ccf0794a411..66d9675281d8f5c3421e1f576ddcdb578a5e7a74 100644 (file)
@@ -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 <intrin.h>
+#if defined(_MSC_VER) && _MSC_VER < 1700
+    // VC++ up to vc10
+#   include <intrin.h>
 
-#       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 <atomic>
+#else
+    // MS VC11+, linux
+#   include <atomic>
 
-#       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
index 9e6e9ec5d1560be401ecfdc4109099d72e24e99c..ebfd417ca43ed1c45aeb9e73fa75ecacf8676774 100644 (file)
 #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"
index 7b1fa6bc0e86b445f61ece99beced8d98915f29e..dbaf22aa449073e97e7ad0fe697cd239d59c03fa 100644 (file)
@@ -4,7 +4,7 @@
 #define __CDS_CONTAINER_STRIPED_MAP_STD_HASH_MAP_ADAPTER_H
 
 #include <cds/container/striped_set/adapter.h>
-#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 <cds/container/striped_map/std_hash_map_vc.h>
 #else
 #   include <cds/container/striped_map/std_hash_map_std.h>
index fcfb5e99eebabc4b2b6094bcc9ff123d750cd08e..7ba35e399bf5b19e11318aa64ee0dad8ee4916a4 100644 (file)
@@ -4,7 +4,7 @@
 #define __CDS_CONTAINER_STRIPED_SET_STD_HASH_SET_ADAPTER_H
 
 #include <cds/container/striped_set/adapter.h>
-#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 <cds/container/striped_set/std_hash_set_vc.h>
 #else
 #   include <cds/container/striped_set/std_hash_set_std.h>
index 97d046b45549034f46e4e8cd0262642c8f125ada..ff482c1787248ed49b227d28acb756338eb927c1 100644 (file)
@@ -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 );
index da29e9c16fa9ed7557f927575907912a5dcb00cb..c2f4ef05ed6df6b81e80406867ba2dcbd10ca8b5 100644 (file)
@@ -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
 
index 4572cb1e5fd0dbd66a025c7d8146e7ec500fb015..bba2d1f1b5fe0d7d8eea56ffe6a75fd6372d6120 100644 (file)
@@ -5,7 +5,7 @@
 #include <cds/container/striped_map.h>
 #include <cds/lock/spinlock.h>
 
-#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 {
 
index ff1a774d600d3c0b067f81489c9cd0781205d73e..988532ca52ab0b34964a24ebb7e560986dbbb632 100644 (file)
@@ -5,7 +5,7 @@
 #include <cds/container/striped_map.h>
 #include <cds/lock/spinlock.h>
 
-#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 {
 
index aa1e582d744f82c845773e1433e29dd400488ee8..95f3c1033bc84209e7517a7fd27e67d1c5c74f60 100644 (file)
@@ -5,7 +5,7 @@
 #include <cds/container/striped_map.h>
 #include <cds/lock/spinlock.h>
 
-#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 {
 
index d198454c7217e839ef48e0c844053727a0563794..cfc5de72b6b17cf831a3990eaaef52b550858062 100644 (file)
@@ -5,7 +5,7 @@
 #include <cds/container/striped_map.h>
 #include <cds/lock/spinlock.h>
 
-#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 {
 
index e9353a78cd4e806de1782fd962c62946c5d52485..470d5c7bf4643d596334997d0ffabd0682e00142 100644 (file)
@@ -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<cds::opt::none>::hash  h6;
index 769d499563db3e40dedb7ca9857d006ca39e60d4..9d7d1ac151747a45fd7edbadacbf436a167573b4 100644 (file)
@@ -5,7 +5,7 @@
 #include <cds/container/striped_set.h>
 #include <cds/lock/spinlock.h>
 
-#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 {
 
index 902f2d152459031817ebd5e962c2bf04822969e3..b12a079b3cfb02a6964bad6b6e1c106c724c47ca 100644 (file)
@@ -5,7 +5,7 @@
 #include <cds/container/striped_set.h>
 #include <cds/lock/spinlock.h>
 
-#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)
index feb7b259383a5e51616bf24db568d702d6440e03..9f75a3c362a5e9a2e51cccfcb8b5f2b983a0ee72 100644 (file)
@@ -5,7 +5,7 @@
 #include <cds/container/striped_set.h>
 #include <cds/lock/spinlock.h>
 
-#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 {
 
index dbe78e9794d4d6601b1d79560214166cbd7bc6d4..1c499ab9f5e515157b4b66956f0c63623fddcd1b 100644 (file)
@@ -5,7 +5,7 @@
 #include <cds/container/striped_set.h>
 #include <cds/lock/spinlock.h>
 
-#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)
index 761a7233a20b15506cc795a098615bfa65087c8c..add04d47eb26c493557a3423f42da7c0633bf2c3 100644 (file)
@@ -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<Key, less > >
             , 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<Key, less > >
             , co::hash< hash2 >
index a88b8604661392d79ad127a44013ad55e364bc7f..a2baa7fe0af7a41fb3e6cb611d420173490b1dbb 100644 (file)
@@ -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<key_type> >
         {
             typedef stdext::hash_compare< key_type, std::less<key_type> > 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 >
index 49eabe9adef81db4df94e3fd9db30d9e18f56985..4b89ca0eaa1ded883931ad6962139a897dd290f4 100644 (file)
@@ -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"