From: Andrey Churbanov Date: Mon, 19 Jan 2015 18:29:35 +0000 (+0000) Subject: added support for PPC architectures (version 3): initial patch provided by Carlo... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d1c5504097ff5296567f9b83bf67257ffc544f3c;p=platform%2Fupstream%2Fllvm.git added support for PPC architectures (version 3): initial patch provided by Carlo Bertolli, latest version from Johnny Peyton llvm-svn: 226479 --- diff --git a/openmp/runtime/CMakeLists.txt b/openmp/runtime/CMakeLists.txt index 8a67efe0..5fc20e7 100644 --- a/openmp/runtime/CMakeLists.txt +++ b/openmp/runtime/CMakeLists.txt @@ -50,7 +50,7 @@ include(GetArchitecture) # get_architecture() # Build Configuration set(os_possible_values lin mac win) -set(arch_possible_values 32e 32 arm ppc64 aarch64 mic) +set(arch_possible_values 32e 32 arm ppc64 ppc64le aarch64 mic) set(build_type_possible_values release debug relwithdebinfo) set(omp_version_possible_values 40 30) set(lib_type_possible_values normal profile stubs) @@ -75,7 +75,7 @@ endif() get_architecture(detected_arch) set(os ${temp_os} CACHE STRING "The operating system to build for (lin/mac/win)") -set(arch ${detected_arch} CACHE STRING "The architecture to build for (32e/32/arm/ppc64/aarch64/mic). 32e is Intel(R) 64 architecture, 32 is IA-32 architecture") +set(arch ${detected_arch} CACHE STRING "The architecture to build for (32e/32/arm/ppc64/ppc64le/aarch64/mic). 32e is Intel(R) 64 architecture, 32 is IA-32 architecture") set(lib_type normal CACHE STRING "Performance,Profiling,Stubs library (normal/profile/stubs)") set(version 5 CACHE STRING "Produce libguide (version 4) or libiomp5 (version 5)") set(omp_version 40 CACHE STRING "The OpenMP version (40/30)") @@ -165,6 +165,8 @@ set(IA32 FALSE) set(INTEL64 FALSE) set(ARM FALSE) set(AARCH64 FALSE) +set(PPC64BE FALSE) +set(PPC64LE FALSE) set(PPC64 FALSE) if("${arch}" STREQUAL "32") # IA-32 architecture set(IA32 TRUE) @@ -172,10 +174,14 @@ elseif("${arch}" STREQUAL "32e") # Intel(R) 64 architecture set(INTEL64 TRUE) elseif("${arch}" STREQUAL "arm") # ARM architecture set(ARM TRUE) +elseif("${arch}" STREQUAL "ppc64") # PPC64BE architecture + set(PPC64BE TRUE) + set(PPC64 TRUE) +elseif("${arch}" STREQUAL "ppc64le") # PPC64LE architecture + set(PPC64LE TRUE) + set(PPC64 TRUE) elseif("${arch}" STREQUAL "aarch64") # AARCH64 architecture set(AARCH64 TRUE) -elseif("${arch}" STREQUAL "ppc64") # PPC64 architecture - set(PPC64 TRUE) elseif("${arch}" STREQUAL "mic") # Intel(R) Many Integrated Core Architecture set(MIC TRUE) endif() diff --git a/openmp/runtime/README.txt b/openmp/runtime/README.txt index 1ed7b2c..1151000 100644 --- a/openmp/runtime/README.txt +++ b/openmp/runtime/README.txt @@ -46,6 +46,8 @@ arch: Architecture. By default, the build will attempt to "32" for IA-32 architecture "32e" for Intel(R) 64 architecture "mic" for Intel(R) Many Integrated Core Architecture + "ppc64" for IBM(R) Power architecture (big endian) + "ppc64le" for IBM(R) Power architecture (little endian) If "mic" is specified then "icc" will be used as the compiler, and appropriate k1om binutils will be used. The diff --git a/openmp/runtime/cmake/HelperFunctions.cmake b/openmp/runtime/cmake/HelperFunctions.cmake index 46f8b26..e5dd950 100644 --- a/openmp/runtime/cmake/HelperFunctions.cmake +++ b/openmp/runtime/cmake/HelperFunctions.cmake @@ -67,8 +67,10 @@ function(set_legal_arch return_arch_string) set(${return_arch_string} "L1OM" PARENT_SCOPE) elseif(${ARM}) set(${return_arch_string} "ARM" PARENT_SCOPE) - elseif(${PPC64}) - set(${return_arch_string} "PPC64" PARENT_SCOPE) + elseif(${PPC64BE}) + set(${return_arch_string} "PPC64BE" PARENT_SCOPE) + elseif(${PPC64LE}) + set(${return_arch_string} "PPC64LE" PARENT_SCOPE) elseif(${AARCH64}) set(${return_arch_string} "AARCH64" PARENT_SCOPE) else() diff --git a/openmp/runtime/src/kmp_os.h b/openmp/runtime/src/kmp_os.h index 60463ce..5b9fe0c 100644 --- a/openmp/runtime/src/kmp_os.h +++ b/openmp/runtime/src/kmp_os.h @@ -75,8 +75,12 @@ #define KMP_ARCH_X86 0 #define KMP_ARCH_X86_64 0 -#define KMP_ARCH_PPC64 0 #define KMP_ARCH_AARCH64 0 +#define KMP_ARCH_PPC64_BE 0 +#define KMP_ARCH_PPC64_LE 0 + +#define KMP_ARCH_PPC64 (KMP_ARCH_PPC64_LE || KMP_ARCH_PPC64_BE) + #ifdef _WIN32 # undef KMP_OS_WINDOWS @@ -141,8 +145,13 @@ # undef KMP_ARCH_X86 # define KMP_ARCH_X86 1 # elif defined __powerpc64__ -# undef KMP_ARCH_PPC64 -# define KMP_ARCH_PPC64 1 +# if defined __LITTLE_ENDIAN__ +# undef KMP_ARCH_PPC64_LE +# define KMP_ARCH_PPC64_LE 1 +# else +# undef KMP_ARCH_PPC64_BE +# define KMP_ARCH_PPC64_BE 1 +# endif # elif defined __aarch64__ # undef KMP_ARCH_AARCH64 # define KMP_ARCH_AARCH64 1 diff --git a/openmp/runtime/src/kmp_tasking.c b/openmp/runtime/src/kmp_tasking.c index e87e7a5..35ccb02 100644 --- a/openmp/runtime/src/kmp_tasking.c +++ b/openmp/runtime/src/kmp_tasking.c @@ -835,7 +835,7 @@ __kmp_task_alloc( ident_t *loc_ref, kmp_int32 gtid, kmp_tasking_flags_t *flags, task = KMP_TASKDATA_TO_TASK(taskdata); // Make sure task & taskdata are aligned appropriately -#if KMP_ARCH_X86 || !KMP_HAVE_QUAD +#if KMP_ARCH_X86 || KMP_ARCH_PPC64 || !KMP_HAVE_QUAD KMP_DEBUG_ASSERT( ( ((kmp_uintptr_t)taskdata) & (sizeof(double)-1) ) == 0 ); KMP_DEBUG_ASSERT( ( ((kmp_uintptr_t)task) & (sizeof(double)-1) ) == 0 ); #else diff --git a/openmp/runtime/src/makefile.mk b/openmp/runtime/src/makefile.mk index 2426c8e..f15f492 100644 --- a/openmp/runtime/src/makefile.mk +++ b/openmp/runtime/src/makefile.mk @@ -379,7 +379,7 @@ ifeq "$(os)" "lin" ld-flags-extra += -lirc_pic endif endif - ifeq "$(filter 32 32e 64 ppc64,$(arch))" "" + ifeq "$(filter 32 32e 64 ppc64 ppc64le,$(arch))" "" ld-flags-extra += $(shell pkg-config --libs libffi) endif else @@ -478,16 +478,13 @@ endif cpp-flags += -D KMP_LIBRARY_FILE=\"$(lib_file)\" cpp-flags += -D KMP_VERSION_MAJOR=$(VERSION) -# customize ppc64 cache line size to 128, 64 otherwise -ifeq "$(arch)" "ppc64" - cpp-flags += -D CACHE_LINE=128 -else - cpp-flags += -D CACHE_LINE=64 -endif - -# customize aarch64 cache line size to 128, 64 otherwise magic won't happen -# Just kidding.. can we have some documentation on this, please -ifeq "$(arch)" "aarch64" +# Customize ppc64 and aarch64 cache line size to 128, use 64 otherwise +# Almost all data structures (kmp.h) are aligned to a cache line to reduce false sharing, thus +# increasing performance. For heavily accessed data structures (e.g., kmp_base_info), there are +# members of the data structure that are grouped together according to their memory access +# pattern. For example, readonly data is put on cache lines together. Then, on separate cachelines, +# private data used by the working thread is put on its own cache lines. etc. +ifneq "$(filter aarch64 ppc64 ppc64le,$(arch))" "" cpp-flags += -D CACHE_LINE=128 else cpp-flags += -D CACHE_LINE=64 @@ -498,8 +495,9 @@ cpp-flags += -D BUILD_PARALLEL_ORDERED cpp-flags += -D KMP_ASM_INTRINS cpp-flags += -D KMP_USE_INTERNODE_ALIGNMENT=0 # Linux and MIC compile with version symbols +# ppc64 and ppc64le architectures don't compile with version symbols ifneq "$(filter lin,$(os))" "" -ifeq "$(filter ppc64,$(arch))" "" +ifeq "$(filter ppc64 ppc64le,$(arch))" "" cpp-flags += -D KMP_USE_VERSION_SYMBOLS endif endif @@ -623,9 +621,9 @@ ifneq "$(os)" "win" ifeq "$(arch)" "arm" z_Linux_asm$(obj) : \ cpp-flags += -D KMP_ARCH_ARM - else ifeq "$(arch)" "ppc64" + else ifneq "$(filter ppc64 ppc64le,$(arch))" "" z_Linux_asm$(obj) : \ - cpp-flags += -D KMP_ARCH_PPC64 + cpp-flags += -D KMP_ARCH_PPC64 else ifeq "$(arch)" "aarch64" z_Linux_asm$(obj) : \ cpp-flags += -D KMP_ARCH_AARCH64 @@ -1471,9 +1469,12 @@ ifneq "$(filter %-dyna win-%,$(os)-$(LINK_TYPE))" "" td_exp += ld-linux-armhf.so.3 td_exp += libgcc_s.so.1 endif - ifeq "$(arch)" "ppc64" + ifneq "$(filter ppc64 ppc64le,$(arch))" "" td_exp += libc.so.6 td_exp += ld64.so.1 + # warning: this is for ppc64le, but as we do not currently + # distinguish it from ppc64, we need to add this dep here + td_exp += ld64.so.2 td_exp += libgcc_s.so.1 endif ifeq "$(arch)" "aarch" @@ -1494,7 +1495,7 @@ ifneq "$(filter %-dyna win-%,$(os)-$(LINK_TYPE))" "" endif td_exp += libdl.so.2 - ifeq "$(filter 32 32e 64 ppc64 mic,$(arch))" "" + ifeq "$(filter 32 32e 64 ppc64 ppc64le mic,$(arch))" "" td_exp += libffi.so.6 td_exp += libffi.so.5 endif diff --git a/openmp/runtime/tools/lib/Platform.pm b/openmp/runtime/tools/lib/Platform.pm index 2e2b890..8b701c2 100644 --- a/openmp/runtime/tools/lib/Platform.pm +++ b/openmp/runtime/tools/lib/Platform.pm @@ -50,6 +50,8 @@ sub canon_arch($) { $arch = "32e"; } elsif ( $arch =~ m{\Aarm(?:v7\D*)?\z} ) { $arch = "arm"; + } elsif ( $arch =~ m{\Appc64le} ) { + $arch = "ppc64le"; } elsif ( $arch =~ m{\Appc64} ) { $arch = "ppc64"; } elsif ( $arch =~ m{\Aaarch64} ) { @@ -201,6 +203,8 @@ sub target_options() { $_host_arch = "32e"; } elsif ( $hardware_platform eq "arm" ) { $_host_arch = "arm"; + } elsif ( $hardware_platform eq "ppc64le" ) { + $_host_arch = "ppc64le"; } elsif ( $hardware_platform eq "ppc64" ) { $_host_arch = "ppc64"; } elsif ( $hardware_platform eq "aarch64" ) { @@ -391,7 +395,7 @@ the script assumes host architecture is target one. Input string is an architecture name to canonize. The function recognizes many variants, for example: C<32e>, C, C, etc. Returned string is a canononized architecture name, -one of: C<32>, C<32e>, C<64>, C, C, C, or C is input string is not recognized. +one of: C<32>, C<32e>, C<64>, C, C, C, C, or C is input string is not recognized. =item B diff --git a/openmp/runtime/tools/lib/Uname.pm b/openmp/runtime/tools/lib/Uname.pm index d5bbde55..78ea31d 100644 --- a/openmp/runtime/tools/lib/Uname.pm +++ b/openmp/runtime/tools/lib/Uname.pm @@ -147,6 +147,8 @@ if ( 0 ) { $values{ hardware_platform } = "x86_64"; } elsif ( $values{ machine } =~ m{\Aarmv7\D*\z} ) { $values{ hardware_platform } = "arm"; + } elsif ( $values{ machine } =~ m{\Appc64le\z} ) { + $values{ hardware_platform } = "ppc64le"; } elsif ( $values{ machine } =~ m{\Appc64\z} ) { $values{ hardware_platform } = "ppc64"; } elsif ( $values{ machine } =~ m{\Aaarch64\z} ) { diff --git a/openmp/runtime/tools/src/common-defs.mk b/openmp/runtime/tools/src/common-defs.mk index 82a6b54..4a059d0 100644 --- a/openmp/runtime/tools/src/common-defs.mk +++ b/openmp/runtime/tools/src/common-defs.mk @@ -45,7 +45,7 @@ endif # Description: # The function return printable name of specified architecture, IA-32 architecture or Intel(R) 64. # -legal_arch = $(if $(filter 32,$(1)),IA-32,$(if $(filter 32e,$(1)),Intel(R) 64,$(if $(filter l1,$(1)),L1OM,$(if $(filter arm,$(1)),ARM,$(if $(filter ppc64,$(1)),PPC64,$(if $(filter aarch64,$(1)),AArch64,$(if $(filter mic,$(1)),Intel(R) Many Integrated Core Architecture,$(error Bad architecture specified: $(1))))))))) +legal_arch = $(if $(filter 32,$(1)),IA-32,$(if $(filter 32e,$(1)),Intel(R) 64,$(if $(filter l1,$(1)),L1OM,$(if $(filter arm,$(1)),ARM,$(if $(filter ppc64,$(1)),PPC64,$(if $(filter ppc64le,$(1)),PPC64LE,$(if $(filter aarch64,$(1)),AArch64,$(if $(filter mic,$(1)),Intel(R) Many Integrated Core Architecture,$(error Bad architecture specified: $(1)))))))))) # Synopsis: # var_name = $(call check_variable,var,list) @@ -128,13 +128,13 @@ endif # -------------------------------------------------------------------------------------------------- os := $(call check_variable,os,lin mac win) -arch := $(call check_variable,arch,32 32e 64 arm ppc64 aarch64 mic) +arch := $(call check_variable,arch,32 32e 64 arm ppc64 ppc64le aarch64 mic) ifeq "$(arch)" "mic" # We want the flavor of mic (knf, knc, knl, etc.) platform := $(os)_$(MIC_ARCH) else platform := $(os)_$(arch) endif -platform := $(call check_variable,platform,lin_32 lin_32e lin_64 lin_arm lin_knc lin_knf mac_32 mac_32e win_32 win_32e win_64 lin_ppc64 lin_aarch64) +platform := $(call check_variable,platform,lin_32 lin_32e lin_64 lin_arm lin_knc lin_knf mac_32 mac_32e win_32 win_32e win_64 lin_ppc64 lin_ppc64le lin_aarch64) # oa-opts means "os and arch options". They are passed to almost all perl scripts. oa-opts := --os=$(os) --arch=$(arch)