diff --git a/openmp/runtime/src/kmp_alloc.cpp b/openmp/runtime/src/kmp_alloc.cpp index 801cd06c95502..051f88c5a0996 100644 --- a/openmp/runtime/src/kmp_alloc.cpp +++ b/openmp/runtime/src/kmp_alloc.cpp @@ -70,10 +70,10 @@ static void bectl(kmp_info_t *th, bget_compact_t compact, /* Buffer allocation size quantum: all buffers allocated are a multiple of this size. This MUST be a power of two. */ -/* On IA-32 architecture with Linux* OS, malloc() does not - ensure 16 byte alignment */ +/* On some architectures, malloc() does not ensure 16 byte alignment, + Solaris/sparc and x86 among them. */ -#if KMP_ARCH_X86 || !KMP_HAVE_QUAD +#if KMP_ARCH_X86 || KMP_ARCH_SPARC || !KMP_HAVE_QUAD #define SizeQuant 8 #define AlignType double @@ -1861,7 +1861,7 @@ typedef struct kmp_mem_desc { // Memory block descriptor void *ptr_align; // Pointer to aligned memory, returned kmp_allocator_t *allocator; // allocator } kmp_mem_desc_t; -static int alignment = sizeof(void *); // align to pointer size by default +constexpr size_t alignment = SizeQuant; // external interfaces are wrappers over internal implementation void *__kmpc_alloc(int gtid, size_t size, omp_allocator_handle_t allocator) { diff --git a/openmp/runtime/src/kmp_csupport.cpp b/openmp/runtime/src/kmp_csupport.cpp index fdbf9ff45e354..3ca32ba583fe2 100644 --- a/openmp/runtime/src/kmp_csupport.cpp +++ b/openmp/runtime/src/kmp_csupport.cpp @@ -570,7 +570,7 @@ void __kmpc_fork_teams(ident_t *loc, kmp_int32 argc, kmpc_micro microtask, this_thr->th.th_teams_microtask = NULL; this_thr->th.th_teams_level = 0; - *(kmp_int64 *)(&this_thr->th.th_teams_size) = 0L; + memset(&this_thr->th.th_teams_size, 0, sizeof(kmp_teams_size_t)); va_end(ap); #if KMP_STATS_ENABLED if (previous_state == stats_state_e::SERIAL_REGION) { diff --git a/openmp/runtime/src/kmp_tasking.cpp b/openmp/runtime/src/kmp_tasking.cpp index 3d85a29423540..d7bc4922d54f7 100644 --- a/openmp/runtime/src/kmp_tasking.cpp +++ b/openmp/runtime/src/kmp_tasking.cpp @@ -1528,7 +1528,7 @@ kmp_task_t *__kmp_task_alloc(ident_t *loc_ref, kmp_int32 gtid, // Calculate shared structure offset including padding after kmp_task_t struct // to align pointers in shared struct shareds_offset = sizeof(kmp_taskdata_t) + sizeof_kmp_task_t; - shareds_offset = __kmp_round_up_to_val(shareds_offset, sizeof(void *)); + shareds_offset = __kmp_round_up_to_val(shareds_offset, sizeof(kmp_uint64)); // Allocate a kmp_taskdata_t block and a kmp_task_t block. KA_TRACE(30, ("__kmp_task_alloc: T#%d First malloc size: %ld\n", gtid,