Skip to content

Commit 3051f97

Browse files
committedAug 7, 2014
Commit PowerPC64 support from Carlo Bertolli at IBM.
llvm-svn: 215093
1 parent 7849436 commit 3051f97

22 files changed

+298
-53
lines changed
 

‎openmp/CREDITS.txt

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ beautification by scripts. The fields are: name (N), email (E), web-address
88
(W), PGP key ID and fingerprint (P), description (D), and snail-mail address
99
(S).
1010

11+
N: Carlo Bertolli
12+
D: IBM contributor to PowerPC support in CMake files and elsewhere.
13+
1114
N: Sunita Chandrasekaran
1215
D: Contributor to testsuite from OpenUH
1316

‎openmp/runtime/Build_With_CMake.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ Build options
112112
======================
113113
==== Architecture ====
114114
======================
115-
-Darch=32|32e|arm
116-
* Architecture can be 32 (IA-32 architecture), 32e (Intel(R) 64 architecture)
117-
or arm (ARM architecture). This option, by default is chosen based on the
115+
-Darch=32|32e|arm|ppc64
116+
* Architecture can be 32 (IA-32 architecture), 32e (Intel(R) 64 architecture),
117+
arm (ARM architecture), or ppc64 (PPC64 architecture).
118+
This option, by default is chosen based on the
118119
CMake variable CMAKE_SIZEOF_VOID_P. If it is 8, then Intel(R) 64 architecture
119120
is assumed. If it is 4, then IA-32 architecture is assumed. If you want to
120121
use a different architecture other than x86 based architecture, you must specify

‎openmp/runtime/CMakeLists.txt

+13-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ include(FindPerl) # Standard cmake module to check for Perl
4949

5050
# Build Configuration
5151
set(os_possible_values lin mac win mic)
52-
set(arch_possible_values 32e 32 arm)
52+
set(arch_possible_values 32e 32 arm ppc64)
5353
set(build_type_possible_values release debug relwithdebinfo)
5454
set(omp_version_possible_values 40 30)
5555
set(lib_type_possible_values normal profile stubs)
@@ -71,10 +71,13 @@ else()
7171
set(os lin CACHE STRING "The operating system to build for (lin/mac/win/mic)")
7272
endif()
7373

74-
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
75-
set(arch 32 CACHE STRING "The architecture to build for (32e/32/arm). 32e is Intel(R) 64 architecture, 32 is IA-32 architecture")
76-
else()
77-
set(arch 32e CACHE STRING "The architecture to build for (32e/32/arm). 32e is Intel(R) 64 architecture, 32 is IA-32 architecture")
74+
# set to default architecture if the user did not specify an architecture explicitly
75+
if(NOT arch)
76+
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
77+
set(arch 32 CACHE STRING "The architecture to build for (32e/32/arm/ppc64). 32e is Intel(R) 64 architecture, 32 is IA-32 architecture")
78+
else()
79+
set(arch 32e CACHE STRING "The architecture to build for (32e/32/arm/ppc64). 32e is Intel(R) 64 architecture, 32 is IA-32 architecture")
80+
endif()
7881
endif()
7982

8083
set(lib_type normal CACHE STRING "Performance,Profiling,Stubs library (normal/profile/stubs)")
@@ -170,12 +173,15 @@ endif()
170173
set(IA32 FALSE)
171174
set(INTEL64 FALSE)
172175
set(ARM FALSE)
176+
set(PPC64 FALSE)
173177
if("${arch}" STREQUAL "32") # IA-32 architecture
174178
set(IA32 TRUE)
175179
elseif("${arch}" STREQUAL "32e") # Intel(R) 64 architecture
176180
set(INTEL64 TRUE)
177181
elseif("${arch}" STREQUAL "arm") # ARM architecture
178182
set(ARM TRUE)
183+
elseif("${arch}" STREQUAL "ppc64") # PPC64 architecture
184+
set(PPC64 TRUE)
179185
endif()
180186

181187
# Set some flags based on build_type
@@ -635,6 +641,8 @@ elseif(${INTEL64})
635641
set_source_files_properties(${src_dir}/z_Linux_asm.s PROPERTIES COMPILE_DEFINITIONS "KMP_ARCH_X86_64")
636642
elseif(${IA32})
637643
set_source_files_properties(${src_dir}/z_Linux_asm.s PROPERTIES COMPILE_DEFINITIONS "KMP_ARCH_X86")
644+
elseif(${PPC64})
645+
set_source_files_properties(${src_dir}/z_Linux_asm.s PROPERTIES COMPILE_DEFINITIONS "KMP_ARCH_PPC64")
638646
endif()
639647

640648
if(${WINDOWS})

‎openmp/runtime/cmake/Definitions.cmake

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ function(append_cpp_flags input_cpp_flags)
2323
append_definitions("-D BUILD_I8")
2424
append_definitions("-D KMP_LIBRARY_FILE=\\\\\"${lib_file}\\\\\"") # yes... you need 5 backslashes...
2525
append_definitions("-D KMP_VERSION_MAJOR=${version}")
26-
append_definitions("-D CACHE_LINE=64")
26+
27+
# customize to 128 bytes for ppc64
28+
if(${PPC64})
29+
append_definitions("-D CACHE_LINE=128")
30+
else()
31+
append_definitions("-D CACHE_LINE=64")
32+
endif()
33+
2734
append_definitions("-D KMP_ADJUST_BLOCKTIME=1")
2835
append_definitions("-D BUILD_PARALLEL_ORDERED")
2936
append_definitions("-D KMP_ASM_INTRINS")

‎openmp/runtime/cmake/HelperFunctions.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ function(set_legal_arch return_arch_string)
6767
set(${return_arch_string} "L1OM" PARENT_SCOPE)
6868
elseif(${ARM})
6969
set(${return_arch_string} "ARM" PARENT_SCOPE)
70+
elseif(${PPC64})
71+
set(${return_arch_string} "PPC64" PARENT_SCOPE)
7072
else()
7173
warning_say("set_legal_arch(): Warning: Unknown architecture...")
7274
endif()

‎openmp/runtime/src/CMakeLists.txt

+52-10
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ else()
2222
message(FATAL_ERROR "Unsupported OS")
2323
endif()
2424

25-
if("${ARCH}" STREQUAL "")
25+
if(arch)
26+
set(ARCH ${arch}) #acquire from command line
27+
else() #assume default
2628
set(ARCH "32e")
2729
endif()
2830

29-
set(ARCH_STR "Intel(R) 64")
31+
if("${arch}" STREQUAL "32e")
32+
set(ARCH_STR "Intel(R) 64")
33+
elseif("${arch}" STREQUAL "ppc64")
34+
set(ARCH_STR "PPC64")
35+
endif()
3036

3137
set(FEATURE_FLAGS "-D USE_ITT_BUILD")
3238
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D NDEBUG")
@@ -36,22 +42,36 @@ set(FEATURE_FLAGS "${FEATURE_FLAGS} -D _REENTRANT")
3642
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D KMP_USE_ASSERT")
3743
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D BUILD_I8")
3844
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D BUILD_TV")
45+
3946
if(APPLE)
4047
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -current_version 5.0")
4148
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -compatibility_version 5.0")
4249
endif()
50+
4351
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D KMP_LIBRARY_FILE=\\\"libiomp5.${OMP_SHLIBEXT}\\\"")
4452
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D KMP_VERSION_MAJOR=${VERSION}")
45-
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D CACHE_LINE=64")
53+
54+
# customize cache line size for ppc64 to 128 bytes: 64 in all other cases
55+
if("${arch}" STREQUAL "ppc64")
56+
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D CACHE_LINE=128")
57+
else()
58+
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D CACHE_LINE=64")
59+
endif()
60+
4661
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D KMP_ADJUST_BLOCKTIME=1")
4762
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D BUILD_PARALLEL_ORDERED")
4863
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D KMP_ASM_INTRINS")
4964
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D USE_LOAD_BALANCE")
5065
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D USE_CBLKDATA")
5166
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D GUIDEDLL_EXPORTS")
5267
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D KMP_GOMP_COMPAT")
53-
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D KMP_USE_ADAPTIVE_LOCKS=1")
54-
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D KMP_DEBUG_ADAPTIVE_LOCKS=0")
68+
69+
#adaptive locks use x86 assembly - disable for ppc64
70+
if("${arch}" STREQUAL "32e" OR "${arch}" STREQUAL "32" OR "${arch}" STREQUAL "arm")
71+
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D KMP_USE_ADAPTIVE_LOCKS=1")
72+
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D KMP_DEBUG_ADAPTIVE_LOCKS=0")
73+
endif()
74+
5575
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D OMP_50_ENABLED=0")
5676
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D OMP_41_ENABLED=0")
5777
set(FEATURE_FLAGS "${FEATURE_FLAGS} -D OMP_40_ENABLED=1")
@@ -122,16 +142,38 @@ add_custom_command(
122142
OUTPUT omp.h
123143
COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/../tools/expand-vars.pl --strict -D Revision=\"\\$$Revision\" -D Date=\"\\$$Date\" -D KMP_TYPE=\"Performance\" -D KMP_ARCH=\"\\\"${ARCH_STR}\\\"\" -D KMP_VERSION_MAJOR=${VERSION} -D KMP_VERSION_MINOR=0 -D KMP_VERSION_BUILD=00000000 -D KMP_BUILD_DATE=\"${BUILD_TIME} UTC\" -D KMP_TARGET_COMPILER=12 -D KMP_DIAG=0 -D KMP_DEBUG_INFO=0 -D OMP_VERSION=${OMP_VERSION} ${CMAKE_CURRENT_SOURCE_DIR}/include/${OMP_VERSION_NUM}/omp.h.var omp.h
124144
)
125-
add_custom_command(
126-
OUTPUT z_Linux_asm.o
127-
COMMAND ${CMAKE_CXX_COMPILER} -c -o z_Linux_asm.o -D KMP_ASM_INTRINS -D KMP_GOMP_COMPAT -D KMP_ARCH_X86_64 -x assembler-with-cpp ${CMAKE_CURRENT_SOURCE_DIR}/${ASM_SOURCES}
128-
)
145+
146+
if("${ARCH}" STREQUAL "ppc64")
147+
add_custom_command(
148+
OUTPUT z_Linux_asm.o
149+
COMMAND ${CMAKE_CXX_COMPILER} -c -o z_Linux_asm.o -D KMP_ASM_INTRINS -D KMP_GOMP_COMPAT -D KMP_ARCH_PPC64 -x assembler-with-cpp ${CMAKE_CURRENT_SOURCE_DIR}/${ASM_SOURCES}
150+
)
151+
else()
152+
add_custom_command(
153+
OUTPUT z_Linux_asm.o
154+
COMMAND ${CMAKE_CXX_COMPILER} -c -o z_Linux_asm.o -D KMP_ASM_INTRINS -D KMP_GOMP_COMPAT -D KMP_ARCH_X86_64 -x assembler-with-cpp ${CMAKE_CURRENT_SOURCE_DIR}/${ASM_SOURCES}
155+
)
156+
endif()
157+
129158

130159
add_custom_target(gen_kmp_i18n DEPENDS kmp_i18n_id.inc kmp_i18n_default.inc omp.h z_Linux_asm.o)
131160

132161
if(NOT APPLE)
133-
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports_so.txt")
162+
if(${ARCH} STREQUAL "ppc64" AND ${OS_GEN} STREQUAL "lin")
163+
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports_so.txt -ldl")
164+
else()
165+
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports_so.txt")
166+
endif()
134167
endif()
135168

136169
add_library(iomp5 SHARED ${SOURCES} z_Linux_asm.o)
170+
171+
# This is a workaround to a known ppc64 issue about libpthread. For more
172+
# information see
173+
# http://ryanarn.blogspot.com/2011/07/curious-case-of-pthreadatfork-on.html
174+
if("${ARCH}" STREQUAL "ppc64")
175+
find_library(PTHREAD NAMES pthread)
176+
target_link_libraries(iomp5 ${PTHREAD})
177+
endif()
178+
137179
add_dependencies(iomp5 gen_kmp_i18n)

‎openmp/runtime/src/kmp.h

+11-3
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,9 @@ typedef int PACKED_REDUCTION_METHOD_T;
459459
/*
460460
* Only Linux* OS and Windows* OS support thread affinity.
461461
*/
462-
#if KMP_OS_LINUX || KMP_OS_WINDOWS
462+
#if (KMP_OS_LINUX || KMP_OS_WINDOWS) && !KMP_OS_CNK && !KMP_ARCH_PPC64
463463
# define KMP_AFFINITY_SUPPORTED 1
464-
#elif KMP_OS_DARWIN || KMP_OS_FREEBSD
464+
#elif KMP_OS_DARWIN || KMP_OS_FREEBSD || KMP_OS_CNK || KMP_ARCH_PPC64
465465
// affinity not supported
466466
# define KMP_AFFINITY_SUPPORTED 0
467467
#else
@@ -476,7 +476,7 @@ extern size_t __kmp_affin_mask_size;
476476

477477
# if KMP_OS_LINUX
478478
//
479-
// On Linux* OS, the mask isactually a vector of length __kmp_affin_mask_size
479+
// On Linux* OS, the mask is actually a vector of length __kmp_affin_mask_size
480480
// (in bytes). It should be allocated on a word boundary.
481481
//
482482
// WARNING!!! We have made the base type of the affinity mask unsigned char,
@@ -946,6 +946,9 @@ extern unsigned int __kmp_place_core_offset;
946946
#if KMP_OS_WINDOWS
947947
# define KMP_INIT_WAIT 64U /* initial number of spin-tests */
948948
# define KMP_NEXT_WAIT 32U /* susequent number of spin-tests */
949+
#elif KMP_OS_CNK
950+
# define KMP_INIT_WAIT 16U /* initial number of spin-tests */
951+
# define KMP_NEXT_WAIT 8U /* susequent number of spin-tests */
949952
#elif KMP_OS_LINUX
950953
# define KMP_INIT_WAIT 1024U /* initial number of spin-tests */
951954
# define KMP_NEXT_WAIT 512U /* susequent number of spin-tests */
@@ -971,6 +974,11 @@ extern void __kmp_x86_cpuid( int mode, int mode2, struct kmp_cpuid *p );
971974
extern void __kmp_x86_pause( void );
972975
# endif
973976
# define KMP_CPU_PAUSE() __kmp_x86_pause()
977+
#elif KMP_ARCH_PPC64
978+
# define KMP_PPC64_PRI_LOW() __asm__ volatile ("or 1, 1, 1")
979+
# define KMP_PPC64_PRI_MED() __asm__ volatile ("or 2, 2, 2")
980+
# define KMP_PPC64_PRI_LOC_MB() __asm__ volatile ("" : : : "memory")
981+
# define KMP_CPU_PAUSE() do { KMP_PPC64_PRI_LOW(); KMP_PPC64_PRI_MED(); KMP_PPC64_PRI_LOC_MB(); } while (0)
974982
#else
975983
# define KMP_CPU_PAUSE() /* nothing to do */
976984
#endif

‎openmp/runtime/src/kmp_csupport.c

+13
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,19 @@ __kmpc_flush(ident_t *loc, ...)
837837
#endif // KMP_MIC
838838
#elif KMP_ARCH_ARM
839839
// Nothing yet
840+
#elif KMP_ARCH_PPC64
841+
// Nothing needed here (we have a real MB above).
842+
#if KMP_OS_CNK
843+
// The flushing thread needs to yield here; this prevents a
844+
// busy-waiting thread from saturating the pipeline. flush is
845+
// often used in loops like this:
846+
// while (!flag) {
847+
// #pragma omp flush(flag)
848+
// }
849+
// and adding the yield here is good for at least a 10x speedup
850+
// when running >2 threads per core (on the NAS LU benchmark).
851+
__kmp_yield(TRUE);
852+
#endif
840853
#else
841854
#error Unknown or unsupported architecture
842855
#endif

‎openmp/runtime/src/kmp_ftn_os.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@
478478
//#define KMP_API_NAME_GOMP_TARGET_UPDATE GOMP_target_update
479479
#define KMP_API_NAME_GOMP_TEAMS GOMP_teams
480480

481-
#if KMP_OS_LINUX
481+
#if KMP_OS_LINUX && !KMP_OS_CNK && !KMP_ARCH_PPC64
482482
#define xstr(x) str(x)
483483
#define str(x) #x
484484

‎openmp/runtime/src/kmp_global.c

+4
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,11 @@ int __kmp_env_consistency_check = FALSE; /* KMP_CONSISTENCY_CHECK speci
321321
kmp_uint32 __kmp_yield_init = KMP_INIT_WAIT;
322322
kmp_uint32 __kmp_yield_next = KMP_NEXT_WAIT;
323323
kmp_uint32 __kmp_yielding_on = 1;
324+
#if KMP_OS_CNK
325+
kmp_uint32 __kmp_yield_cycle = 0;
326+
#else
324327
kmp_uint32 __kmp_yield_cycle = 1; /* Yield-cycle is on by default */
328+
#endif
325329
kmp_int32 __kmp_yield_on_count = 10; /* By default, yielding is on for 10 monitor periods. */
326330
kmp_int32 __kmp_yield_off_count = 1; /* By default, yielding is off for 1 monitor periods. */
327331
/* ----------------------------------------------------- */

‎openmp/runtime/src/kmp_gsupport.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//===----------------------------------------------------------------------===//
1616

1717

18-
#if defined(__x86_64)
18+
#if defined(__x86_64) || defined (__powerpc64__)
1919
# define KMP_I8
2020
#endif
2121
#include "kmp.h"

‎openmp/runtime/src/kmp_lock.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ __kmp_destroy_bootstrap_lock( kmp_bootstrap_lock_t *lck )
518518
// Internal RTL locks are also implemented as ticket locks, for now.
519519
//
520520
// FIXME - We should go through and figure out which lock kind works best for
521-
// each internal lock, and use the type deeclaration and function calls for
521+
// each internal lock, and use the type declaration and function calls for
522522
// that explicit lock kind (and get rid of this section).
523523
//
524524

‎openmp/runtime/src/kmp_os.h

+22-3
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@
7070
#define KMP_OS_FREEBSD 0
7171
#define KMP_OS_DARWIN 0
7272
#define KMP_OS_WINDOWS 0
73+
#define KMP_OS_CNK 0
7374
#define KMP_OS_UNIX 0 /* disjunction of KMP_OS_LINUX, KMP_OS_DARWIN etc. */
7475

7576
#define KMP_ARCH_X86 0
7677
#define KMP_ARCH_X86_64 0
78+
#define KMP_ARCH_PPC64 0
7779

7880
#ifdef _WIN32
7981
# undef KMP_OS_WINDOWS
@@ -85,16 +87,26 @@
8587
# define KMP_OS_DARWIN 1
8688
#endif
8789

90+
// in some ppc64 linux installations, only the second condition is met
8891
#if ( defined __linux )
8992
# undef KMP_OS_LINUX
9093
# define KMP_OS_LINUX 1
94+
#elif ( defined __linux__)
95+
# undef KMP_OS_LINUX
96+
# define KMP_OS_LINUX 1
97+
#else
9198
#endif
9299

93100
#if ( defined __FreeBSD__ )
94101
# undef KMP_OS_FREEBSD
95102
# define KMP_OS_FREEBSD 1
96103
#endif
97104

105+
#if ( defined __bgq__ )
106+
# undef KMP_OS_CNK
107+
# define KMP_OS_CNK 1
108+
#endif
109+
98110
#if (1 != KMP_OS_LINUX + KMP_OS_FREEBSD + KMP_OS_DARWIN + KMP_OS_WINDOWS)
99111
# error Unknown OS
100112
#endif
@@ -121,6 +133,9 @@
121133
# elif defined __i386
122134
# undef KMP_ARCH_X86
123135
# define KMP_ARCH_X86 1
136+
# elif defined __powerpc64__
137+
# undef KMP_ARCH_PPC64
138+
# define KMP_ARCH_PPC64 1
124139
# endif
125140
#endif
126141

@@ -160,7 +175,7 @@
160175
# define KMP_ARCH_ARM 1
161176
#endif
162177

163-
#if (1 != KMP_ARCH_X86 + KMP_ARCH_X86_64 + KMP_ARCH_ARM)
178+
#if (1 != KMP_ARCH_X86 + KMP_ARCH_X86_64 + KMP_ARCH_ARM + KMP_ARCH_PPC64)
164179
# error Unknown or unsupported architecture
165180
#endif
166181

@@ -238,7 +253,7 @@
238253

239254
#if KMP_ARCH_X86 || KMP_ARCH_ARM
240255
# define KMP_SIZE_T_SPEC KMP_UINT32_SPEC
241-
#elif KMP_ARCH_X86_64
256+
#elif KMP_ARCH_X86_64 || KMP_ARCH_PPC64
242257
# define KMP_SIZE_T_SPEC KMP_UINT64_SPEC
243258
#else
244259
# error "Can't determine size_t printf format specifier."
@@ -663,6 +678,10 @@ extern kmp_real64 __kmp_test_then_add_real64 ( volatile kmp_real64 *p, kmp_real6
663678
# endif
664679
#endif /* KMP_OS_WINDOWS */
665680

681+
#if KMP_ARCH_PPC64
682+
# define KMP_MB() __sync_synchronize()
683+
#endif
684+
666685
#ifndef KMP_MB
667686
# define KMP_MB() /* nothing to do */
668687
#endif
@@ -769,7 +788,7 @@ typedef void (*microtask_t)( int *gtid, int *npr, ... );
769788
#endif /* KMP_I8 */
770789

771790
/* Workaround for Intel(R) 64 code gen bug when taking address of static array (Intel(R) 64 Tracker #138) */
772-
#if KMP_ARCH_X86_64 && KMP_OS_LINUX
791+
#if (KMP_ARCH_X86_64 || KMP_ARCH_PPC64) && KMP_OS_LINUX
773792
# define STATIC_EFI2_WORKAROUND
774793
#else
775794
# define STATIC_EFI2_WORKAROUND static

‎openmp/runtime/src/kmp_runtime.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -8450,7 +8450,7 @@ __kmp_determine_reduction_method( ident_t *loc, kmp_int32 global_tid,
84508450
int atomic_available = FAST_REDUCTION_ATOMIC_METHOD_GENERATED;
84518451
int tree_available = FAST_REDUCTION_TREE_METHOD_GENERATED;
84528452

8453-
#if KMP_ARCH_X86_64
8453+
#if KMP_ARCH_X86_64 || KMP_ARCH_PPC64
84548454

84558455
#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_WINDOWS || KMP_OS_DARWIN
84568456
#if KMP_MIC

‎openmp/runtime/src/kmp_settings.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ __kmp_stg_parse_file(
536536

537537
static char * par_range_to_print = NULL;
538538

539+
#ifdef KMP_DEBUG
539540
static void
540541
__kmp_stg_parse_par_range(
541542
char const * name,
@@ -614,7 +615,7 @@ __kmp_stg_parse_par_range(
614615
break;
615616
}
616617
} // __kmp_stg_parse_par_range
617-
618+
#endif
618619

619620
int
620621
__kmp_initial_threads_capacity( int req_nproc )

‎openmp/runtime/src/makefile.mk

+24-5
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ endif
313313
ifeq "$(CPLUSPLUS)" "on"
314314
ifeq "$(os)" "win"
315315
c-flags += -TP
316+
else ifeq "$(arch)" "ppc64"
317+
# c++0x on ppc64 linux removes definition of preproc. macros, needed in .hs
318+
c-flags += -x c++ -std=gnu++0x
316319
else
317320
ifneq "$(filter gcc clang,$(c))" ""
318321
c-flags += -x c++ -std=c++0x
@@ -373,7 +376,7 @@ ifeq "$(os)" "lin"
373376
ld-flags-extra += -lirc_pic
374377
endif
375378
endif
376-
ifeq "$(filter 32 32e 64,$(arch))" ""
379+
ifeq "$(filter 32 32e 64 ppc64,$(arch))" ""
377380
ld-flags-extra += $(shell pkg-config --libs libffi)
378381
endif
379382
else
@@ -469,7 +472,14 @@ ifneq "$(os)" "win"
469472
endif
470473
cpp-flags += -D KMP_LIBRARY_FILE=\"$(lib_file)\"
471474
cpp-flags += -D KMP_VERSION_MAJOR=$(VERSION)
472-
cpp-flags += -D CACHE_LINE=64
475+
476+
# customize ppc64 cache line size to 128, 64 otherwise
477+
ifeq "$(arch)" "ppc64"
478+
cpp-flags += -D CACHE_LINE=128
479+
else
480+
cpp-flags += -D CACHE_LINE=64
481+
endif
482+
473483
cpp-flags += -D KMP_ADJUST_BLOCKTIME=1
474484
cpp-flags += -D BUILD_PARALLEL_ORDERED
475485
cpp-flags += -D KMP_ASM_INTRINS
@@ -584,9 +594,12 @@ ifneq "$(os)" "win"
584594
ifeq "$(arch)" "arm"
585595
z_Linux_asm$(obj) : \
586596
cpp-flags += -D KMP_ARCH_ARM
587-
else
597+
else ifeq "$(arch)" "ppc64"
588598
z_Linux_asm$(obj) : \
589-
cpp-flags += -D KMP_ARCH_X86$(if $(filter 32e,$(arch)),_64)
599+
cpp-flags += -D KMP_ARCH_PPC64
600+
else
601+
z_Linux_asm$(obj) : \
602+
cpp-flags += -D KMP_ARCH_X86$(if $(filter 32e,$(arch)),_64)
590603
endif
591604
endif
592605

@@ -735,7 +748,9 @@ endif
735748
else # 5
736749
lib_c_items += kmp_gsupport
737750
endif
751+
# ifneq "$(arch)" "ppc64"
738752
lib_asm_items += z_Linux_asm
753+
# endif
739754
endif
740755
endif
741756

@@ -1397,9 +1412,13 @@ ifneq "$(filter %-dyna win-%,$(os)-$(LINK_TYPE))" ""
13971412
td_exp += libc.so.6
13981413
td_exp += ld-linux-armhf.so.3
13991414
endif
1415+
ifeq "$(arch)" "ppc64"
1416+
td_exp += libc.so.6
1417+
td_exp += ld64.so.1
1418+
endif
14001419
td_exp += libdl.so.2
14011420
td_exp += libgcc_s.so.1
1402-
ifeq "$(filter 32 32e 64,$(arch))" ""
1421+
ifeq "$(filter 32 32e 64 ppc64,$(arch))" ""
14031422
td_exp += libffi.so.6
14041423
td_exp += libffi.so.5
14051424
endif

‎openmp/runtime/src/thirdparty/ittnotify/ittnotify_config.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@
132132
# define ITT_ARCH_ARM 4
133133
#endif /* ITT_ARCH_ARM */
134134

135+
#ifndef ITT_ARCH_PPC64
136+
# define ITT_ARCH_PPC64 5
137+
#endif /* ITT_ARCH_PPC64 */
138+
139+
135140
#ifndef ITT_ARCH
136141
# if defined _M_IX86 || defined __i386__
137142
# define ITT_ARCH ITT_ARCH_IA32
@@ -141,6 +146,8 @@
141146
# define ITT_ARCH ITT_ARCH_IA64
142147
# elif defined _M_ARM || __arm__
143148
# define ITT_ARCH ITT_ARCH_ARM
149+
# elif defined __powerpc64__
150+
# define ITT_ARCH ITT_ARCH_PPC64
144151
# endif
145152
#endif
146153

@@ -274,7 +281,7 @@ ITT_INLINE long __TBB_machine_fetchadd4(volatile void* ptr, long addend)
274281
: "memory");
275282
return result;
276283
}
277-
#elif ITT_ARCH==ITT_ARCH_ARM
284+
#elif ITT_ARCH==ITT_ARCH_ARM || ITT_ARCH==ITT_ARCH_PPC64
278285
#define __TBB_machine_fetchadd4(addr, val) __sync_fetch_and_add(addr, val)
279286
#endif /* ITT_ARCH==ITT_ARCH_IA64 */
280287
#ifndef ITT_SIMPLE_INIT

‎openmp/runtime/src/z_Linux_asm.s

+11-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ __kmp_unnamed_critical_addr:
138138
#endif /* KMP_GOMP_COMPAT */
139139

140140

141-
#if KMP_ARCH_X86
141+
#if KMP_ARCH_X86 && !KMP_ARCH_PPC64
142142

143143
// -----------------------------------------------------------------------
144144
// microtasking routines specifically written for IA-32 architecture
@@ -1585,6 +1585,16 @@ __kmp_unnamed_critical_addr:
15851585
.size __kmp_unnamed_critical_addr,4
15861586
#endif /* KMP_ARCH_ARM */
15871587

1588+
#if KMP_ARCH_PPC64
1589+
.data
1590+
.comm .gomp_critical_user_,32,8
1591+
.data
1592+
.align 8
1593+
.global __kmp_unnamed_critical_addr
1594+
__kmp_unnamed_critical_addr:
1595+
.8byte .gomp_critical_user_
1596+
.size __kmp_unnamed_critical_addr,8
1597+
#endif /* KMP_ARCH_PPC64 */
15881598

15891599
#if defined(__linux__)
15901600
.section .note.GNU-stack,"",@progbits

‎openmp/runtime/src/z_Linux_util.c

+108-13
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include <sys/resource.h>
3333
#include <sys/syscall.h>
3434

35-
#if KMP_OS_LINUX
35+
#if KMP_OS_LINUX && !KMP_OS_CNK
3636
# include <sys/sysinfo.h>
3737
# if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
3838
// We should really include <futex.h>, but that causes compatibility problems on different
@@ -61,7 +61,7 @@
6161
#include <fcntl.h>
6262

6363
// For non-x86 architecture
64-
#if KMP_COMPILER_GCC && !(KMP_ARCH_X86 || KMP_ARCH_X86_64)
64+
#if KMP_COMPILER_GCC && !(KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_PPC64)
6565
# include <stdbool.h>
6666
# include <ffi.h>
6767
#endif
@@ -110,7 +110,7 @@ __kmp_print_cond( char *buffer, kmp_cond_align_t *cond )
110110
/* ------------------------------------------------------------------------ */
111111
/* ------------------------------------------------------------------------ */
112112

113-
#if KMP_OS_LINUX && KMP_AFFINITY_SUPPORTED
113+
#if ( KMP_OS_LINUX && KMP_AFFINITY_SUPPORTED)
114114

115115
/*
116116
* Affinity support
@@ -147,6 +147,19 @@ __kmp_print_cond( char *buffer, kmp_cond_align_t *cond )
147147
# error Wrong code for getaffinity system call.
148148
# endif /* __NR_sched_getaffinity */
149149

150+
# elif KMP_ARCH_PPC64
151+
# ifndef __NR_sched_setaffinity
152+
# define __NR_sched_setaffinity 222
153+
# elif __NR_sched_setaffinity != 222
154+
# error Wrong code for setaffinity system call.
155+
# endif /* __NR_sched_setaffinity */
156+
# ifndef __NR_sched_getaffinity
157+
# define __NR_sched_getaffinity 223
158+
# elif __NR_sched_getaffinity != 223
159+
# error Wrong code for getaffinity system call.
160+
# endif /* __NR_sched_getaffinity */
161+
162+
150163
# else
151164
# error Unknown or unsupported architecture
152165

@@ -445,7 +458,7 @@ __kmp_change_thread_affinity_mask( int gtid, kmp_affin_mask_t *new_mask,
445458
/* ------------------------------------------------------------------------ */
446459
/* ------------------------------------------------------------------------ */
447460

448-
#if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
461+
#if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM) && !KMP_OS_CNK
449462

450463
int
451464
__kmp_futex_determine_capable()
@@ -462,7 +475,7 @@ __kmp_futex_determine_capable()
462475
return retval;
463476
}
464477

465-
#endif // KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
478+
#endif // KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM) && !KMP_OS_CNK
466479

467480
/* ------------------------------------------------------------------------ */
468481
/* ------------------------------------------------------------------------ */
@@ -481,7 +494,7 @@ __kmp_test_then_or32( volatile kmp_int32 *p, kmp_int32 d )
481494
old_value = TCR_4( *p );
482495
new_value = old_value | d;
483496

484-
while ( ! __kmp_compare_and_store32 ( p, old_value, new_value ) )
497+
while ( ! KMP_COMPARE_AND_STORE_REL32 ( p, old_value, new_value ) )
485498
{
486499
KMP_CPU_PAUSE();
487500
old_value = TCR_4( *p );
@@ -498,7 +511,7 @@ __kmp_test_then_and32( volatile kmp_int32 *p, kmp_int32 d )
498511
old_value = TCR_4( *p );
499512
new_value = old_value & d;
500513

501-
while ( ! __kmp_compare_and_store32 ( p, old_value, new_value ) )
514+
while ( ! KMP_COMPARE_AND_STORE_REL32 ( p, old_value, new_value ) )
502515
{
503516
KMP_CPU_PAUSE();
504517
old_value = TCR_4( *p );
@@ -507,7 +520,7 @@ __kmp_test_then_and32( volatile kmp_int32 *p, kmp_int32 d )
507520
return old_value;
508521
}
509522

510-
# if KMP_ARCH_X86
523+
# if KMP_ARCH_X86 || KMP_ARCH_PPC64
511524
kmp_int64
512525
__kmp_test_then_add64( volatile kmp_int64 *p, kmp_int64 d )
513526
{
@@ -516,7 +529,7 @@ __kmp_test_then_add64( volatile kmp_int64 *p, kmp_int64 d )
516529
old_value = TCR_8( *p );
517530
new_value = old_value + d;
518531

519-
while ( ! __kmp_compare_and_store64 ( p, old_value, new_value ) )
532+
while ( ! KMP_COMPARE_AND_STORE_REL64 ( p, old_value, new_value ) )
520533
{
521534
KMP_CPU_PAUSE();
522535
old_value = TCR_8( *p );
@@ -533,7 +546,7 @@ __kmp_test_then_or64( volatile kmp_int64 *p, kmp_int64 d )
533546

534547
old_value = TCR_8( *p );
535548
new_value = old_value | d;
536-
while ( ! __kmp_compare_and_store64 ( p, old_value, new_value ) )
549+
while ( ! KMP_COMPARE_AND_STORE_REL64 ( p, old_value, new_value ) )
537550
{
538551
KMP_CPU_PAUSE();
539552
old_value = TCR_8( *p );
@@ -549,7 +562,7 @@ __kmp_test_then_and64( volatile kmp_int64 *p, kmp_int64 d )
549562

550563
old_value = TCR_8( *p );
551564
new_value = old_value & d;
552-
while ( ! __kmp_compare_and_store64 ( p, old_value, new_value ) )
565+
while ( ! KMP_COMPARE_AND_STORE_REL64 ( p, old_value, new_value ) )
553566
{
554567
KMP_CPU_PAUSE();
555568
old_value = TCR_8( *p );
@@ -2527,7 +2540,7 @@ __kmp_get_load_balance( int max )
25272540
#endif // USE_LOAD_BALANCE
25282541

25292542

2530-
#if KMP_COMPILER_GCC && !(KMP_ARCH_X86 || KMP_ARCH_X86_64)
2543+
#if KMP_COMPILER_GCC && !(KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_PPC64)
25312544

25322545
int __kmp_invoke_microtask( microtask_t pkfn, int gtid, int tid, int argc,
25332546
void *p_argv[] )
@@ -2561,7 +2574,89 @@ int __kmp_invoke_microtask( microtask_t pkfn, int gtid, int tid, int argc,
25612574
return 1;
25622575
}
25632576

2564-
#endif // KMP_COMPILER_GCC && !(KMP_ARCH_X86 || KMP_ARCH_X86_64)
2577+
#endif // KMP_COMPILER_GCC && !(KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_PPC64)
2578+
2579+
#if KMP_ARCH_PPC64
2580+
2581+
// we really only need the case with 1 argument, because CLANG always build
2582+
// a struct of pointers to shared variables referenced in the outlined function
2583+
int
2584+
__kmp_invoke_microtask( microtask_t pkfn,
2585+
int gtid, int tid,
2586+
int argc, void *p_argv[] ) {
2587+
switch (argc) {
2588+
default:
2589+
fprintf(stderr, "Too many args to microtask: %d!\n", argc);
2590+
fflush(stderr);
2591+
exit(-1);
2592+
case 0:
2593+
(*pkfn)(&gtid, &tid);
2594+
break;
2595+
case 1:
2596+
(*pkfn)(&gtid, &tid, p_argv[0]);
2597+
break;
2598+
case 2:
2599+
(*pkfn)(&gtid, &tid, p_argv[0], p_argv[1]);
2600+
break;
2601+
case 3:
2602+
(*pkfn)(&gtid, &tid, p_argv[0], p_argv[1], p_argv[2]);
2603+
break;
2604+
case 4:
2605+
(*pkfn)(&gtid, &tid, p_argv[0], p_argv[1], p_argv[2], p_argv[3]);
2606+
break;
2607+
case 5:
2608+
(*pkfn)(&gtid, &tid, p_argv[0], p_argv[1], p_argv[2], p_argv[3], p_argv[4]);
2609+
break;
2610+
case 6:
2611+
(*pkfn)(&gtid, &tid, p_argv[0], p_argv[1], p_argv[2], p_argv[3], p_argv[4],
2612+
p_argv[5]);
2613+
break;
2614+
case 7:
2615+
(*pkfn)(&gtid, &tid, p_argv[0], p_argv[1], p_argv[2], p_argv[3], p_argv[4],
2616+
p_argv[5], p_argv[6]);
2617+
break;
2618+
case 8:
2619+
(*pkfn)(&gtid, &tid, p_argv[0], p_argv[1], p_argv[2], p_argv[3], p_argv[4],
2620+
p_argv[5], p_argv[6], p_argv[7]);
2621+
break;
2622+
case 9:
2623+
(*pkfn)(&gtid, &tid, p_argv[0], p_argv[1], p_argv[2], p_argv[3], p_argv[4],
2624+
p_argv[5], p_argv[6], p_argv[7], p_argv[8]);
2625+
break;
2626+
case 10:
2627+
(*pkfn)(&gtid, &tid, p_argv[0], p_argv[1], p_argv[2], p_argv[3], p_argv[4],
2628+
p_argv[5], p_argv[6], p_argv[7], p_argv[8], p_argv[9]);
2629+
break;
2630+
case 11:
2631+
(*pkfn)(&gtid, &tid, p_argv[0], p_argv[1], p_argv[2], p_argv[3], p_argv[4],
2632+
p_argv[5], p_argv[6], p_argv[7], p_argv[8], p_argv[9], p_argv[10]);
2633+
break;
2634+
case 12:
2635+
(*pkfn)(&gtid, &tid, p_argv[0], p_argv[1], p_argv[2], p_argv[3], p_argv[4],
2636+
p_argv[5], p_argv[6], p_argv[7], p_argv[8], p_argv[9], p_argv[10],
2637+
p_argv[11]);
2638+
break;
2639+
case 13:
2640+
(*pkfn)(&gtid, &tid, p_argv[0], p_argv[1], p_argv[2], p_argv[3], p_argv[4],
2641+
p_argv[5], p_argv[6], p_argv[7], p_argv[8], p_argv[9], p_argv[10],
2642+
p_argv[11], p_argv[12]);
2643+
break;
2644+
case 14:
2645+
(*pkfn)(&gtid, &tid, p_argv[0], p_argv[1], p_argv[2], p_argv[3], p_argv[4],
2646+
p_argv[5], p_argv[6], p_argv[7], p_argv[8], p_argv[9], p_argv[10],
2647+
p_argv[11], p_argv[12], p_argv[13]);
2648+
break;
2649+
case 15:
2650+
(*pkfn)(&gtid, &tid, p_argv[0], p_argv[1], p_argv[2], p_argv[3], p_argv[4],
2651+
p_argv[5], p_argv[6], p_argv[7], p_argv[8], p_argv[9], p_argv[10],
2652+
p_argv[11], p_argv[12], p_argv[13], p_argv[14]);
2653+
break;
2654+
}
2655+
2656+
return 1;
2657+
}
2658+
2659+
#endif
25652660

25662661
// end of file //
25672662

‎openmp/runtime/tools/lib/Platform.pm

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ sub canon_arch($) {
5050
$arch = "32e";
5151
} elsif ( $arch =~ m{\Aarm(?:v7\D*)?\z} ) {
5252
$arch = "arm";
53+
} elsif ( $arch =~ m{\Appc64} ) {
54+
$arch = "ppc64";
5355
} else {
5456
$arch = undef;
5557
}; # if
@@ -159,6 +161,8 @@ sub target_options() {
159161
$_host_arch = "32e";
160162
} elsif ( $hardware_platform eq "arm" ) {
161163
$_host_arch = "arm";
164+
} elsif ( $hardware_platform eq "ppc64" ) {
165+
$_host_arch = "ppc64";
162166
} else {
163167
die "Unsupported host hardware platform: \"$hardware_platform\"; stopped";
164168
}; # if

‎openmp/runtime/tools/lib/Uname.pm

+2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ if ( 0 ) {
147147
$values{ hardware_platform } = "x86_64";
148148
} elsif ( $values{ machine } =~ m{\Aarmv7\D*\z} ) {
149149
$values{ hardware_platform } = "arm";
150+
} elsif ( $values{ machine } =~ m{\Appc64\z} ) {
151+
$values{ hardware_platform } = "ppc64";
150152
} else {
151153
die "Unsupported machine (\"$values{ machine }\") returned by POSIX::uname(); stopped";
152154
}; # if

‎openmp/runtime/tools/src/common-defs.mk

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ endif
4545
# Description:
4646
# The function return printable name of specified architecture, IA-32 architecture or Intel(R) 64.
4747
#
48-
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,$(error Bad architecture specified: $(1))))))
48+
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,$(error Bad architecture specified: $(1)))))))
4949

5050
# Synopsis:
5151
# var_name = $(call check_variable,var,list)
@@ -128,9 +128,9 @@ endif
128128
# --------------------------------------------------------------------------------------------------
129129

130130
os := $(call check_variable,os,lin lrb mac win)
131-
arch := $(call check_variable,arch,32 32e 64 arm)
131+
arch := $(call check_variable,arch,32 32e 64 arm ppc64)
132132
platform := $(os)_$(arch)
133-
platform := $(call check_variable,platform,lin_32 lin_32e lin_64 lin_arm lrb_32e mac_32 mac_32e win_32 win_32e win_64)
133+
platform := $(call check_variable,platform,lin_32 lin_32e lin_64 lin_arm lrb_32e mac_32 mac_32e win_32 win_32e win_64 lin_ppc64)
134134
# oa-opts means "os and arch options". They are passed to almost all perl scripts.
135135
oa-opts := --os=$(os) --arch=$(arch)
136136

0 commit comments

Comments
 (0)
Please sign in to comment.