Skip to content

Commit dfca8e3

Browse files
committed
Replace OPAL_ASSEMBLY_ARCH with portable platform
With the introduction of the portable platform header, all the OPAL_ASSEMBLY_ARCH code was redundant and kind of a pain to deal with. Remove all uses of OPAL_ASSEMBLY_ARCH and replace with the equivalent portable platform conditional. Signed-off-by: Brian Barrett <[email protected]>
1 parent c05be90 commit dfca8e3

22 files changed

+92
-124
lines changed

config/opal_config_asm.m4

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ dnl #################################################################
597597
AC_DEFUN([OPAL_CONFIG_ASM],[
598598
AC_REQUIRE([OPAL_SETUP_CC])
599599
600-
OPAL_VAR_SCOPE_PUSH([atomics_found want_c11_atomics want_gcc_builtin_atomics want_asm_atomics opal_cv_asm_arch result])
600+
OPAL_VAR_SCOPE_PUSH([atomics_found want_c11_atomics want_gcc_builtin_atomics want_asm_atomics])
601601
602602
# only assembly style we support today is gcc-style inline
603603
# assembly, find out if it works. We need this even for C11/GCC
@@ -672,19 +672,16 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
672672
x86_64-*x32|i?86-*|x86_64*|amd64*)
673673
AS_IF([test "$ac_cv_sizeof_long" = "8"],
674674
[OPAL_CHECK_CMPXCHG16B
675-
opal_cv_asm_arch="X86_64"
676675
atomics_found="x86_64 assembly"])
677676
;;
678677
679678
aarch64*)
680-
opal_cv_asm_arch="ARM64"
681679
atomics_found="aarch64 assembly"
682680
;;
683681
684682
powerpc-*|powerpc64-*|powerpcle-*|powerpc64le-*|rs6000-*|ppc-*)
685683
AS_IF([test "$ac_cv_sizeof_long" = "8"],
686-
[opal_cv_asm_arch="POWERPC64"
687-
atomics_found="PowerPC asssembly"])
684+
[atomics_found="PowerPC asssembly"])
688685
;;
689686
esac
690687
@@ -696,10 +693,6 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
696693
AS_IF([test "$aomics_found" = "no"],
697694
[AC_MSG_ERROR([No usable atomics implementation found. Cannot continue.])])
698695
699-
result="OPAL_$opal_cv_asm_arch"
700-
AC_DEFINE_UNQUOTED([OPAL_ASSEMBLY_ARCH], [$result],
701-
[Architecture type of assembly to use for atomic operations and CMA])
702-
703696
AC_DEFINE_UNQUOTED([OPAL_USE_C11_ATOMICS],
704697
[$want_c11_atomics],
705698
[Whether to use C11 atomics for atomics implementation])

ompi/mca/osc/portals4/osc_portals4_component.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* of Tennessee Research Foundation. All rights
1010
* reserved.
1111
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
12-
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
12+
* Copyright (c) 2018-2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
1313
* Copyright (c) 2020 High Performance Computing Center Stuttgart,
1414
* University of Stuttgart. All rights reserved.
1515
* $COPYRIGHT$
@@ -24,6 +24,7 @@
2424
#include "opal/util/printf.h"
2525
#include "opal/include/opal/align.h"
2626
#include "opal/mca/mpool/base/base.h"
27+
#include "opal/opal_portable_platform.h"
2728

2829
#include "ompi/mca/osc/base/base.h"
2930
#include "ompi/mca/osc/base/osc_base_obj_convert.h"
@@ -589,7 +590,7 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
589590

590591
module->passive_target_access_epoch = false;
591592

592-
#if OPAL_ASSEMBLY_ARCH == OPAL_X86_64 || OPAL_ASSEMBLY_ARCH == OPAL_IA32
593+
#if defined(PLATFORM_ARCH_X86) || defined(PLATFORM_ARCH_X86_64)
593594
*model = MPI_WIN_UNIFIED;
594595
#else
595596
*model = MPI_WIN_SEPARATE;

opal/include/opal/sys/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# Copyright (c) 2017 Research Organization for Information Science
1717
# and Technology (RIST). All rights reserved.
1818
# Copyright (c) 2020-2021 Google, LLC. All rights reserved.
19+
# Copyright (c) 2022 Amazon.com, Inc. or its affiliates.
20+
# All Rights reserved.
1921
# $COPYRIGHT$
2022
#
2123
# Additional copyrights may follow
@@ -26,7 +28,6 @@
2628
# This makefile.am does not stand on its own - it is included from opal/Makefile.am
2729

2830
headers += \
29-
opal/sys/architecture.h \
3031
opal/sys/atomic.h \
3132
opal/sys/atomic_stdc.h \
3233
opal/sys/atomic_impl.h \

opal/include/opal/sys/architecture.h

Lines changed: 0 additions & 47 deletions
This file was deleted.

opal/include/opal/sys/arm64/timer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#ifndef OPAL_SYS_ARCH_TIMER_H
2020
#define OPAL_SYS_ARCH_TIMER_H 1
2121

22-
#if OPAL_ASSEMBLY_ARCH == OPAL_ARM64
22+
#if defined(PLATFORM_ARCH_AARCH64)
2323
typedef uint64_t opal_timer_t;
2424
#else
2525
typedef uint32_t opal_timer_t;
@@ -32,7 +32,7 @@ static inline opal_timer_t opal_sys_timer_get_cycles(void)
3232
opal_timer_t ret;
3333

3434
__asm__ __volatile__("isb" ::: "memory");
35-
#if OPAL_ASSEMBLY_ARCH == OPAL_ARM64
35+
#if defined(PLATFORM_ARCH_AARCH64)
3636
__asm__ __volatile__("mrs %0, CNTVCT_EL0" : "=r"(ret));
3737
#else
3838
__asm__ __volatile__("mrs %0, CNTVCT" : "=r"(ret));
@@ -44,7 +44,7 @@ static inline opal_timer_t opal_sys_timer_get_cycles(void)
4444
static inline opal_timer_t opal_sys_timer_get_freq(void)
4545
{
4646
opal_timer_t freq;
47-
#if OPAL_ASSEMBLY_ARCH == OPAL_ARM64
47+
#if defined(PLATFORM_ARCH_AARCH64)
4848
__asm__ __volatile__("mrs %0, CNTFRQ_EL0" : "=r"(freq));
4949
#else
5050
__asm__ __volatile__("mrs %0, CNTFRQ" : "=r"(freq));

opal/include/opal/sys/atomic.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@
4949
#ifndef OPAL_SYS_ATOMIC_H
5050
#define OPAL_SYS_ATOMIC_H 1
5151

52-
#include "opal_config.h"
53-
5452
#include <stdbool.h>
5553

56-
#include "opal/sys/architecture.h"
54+
#include "opal/opal_portable_platform.h"
5755
#include "opal_stdatomic.h"
5856

5957
BEGIN_C_DECLS
@@ -436,9 +434,9 @@ static inline void opal_atomic_sc_ptr(opal_atomic_intptr_t *addr, intptr_t newva
436434
#error "No atomics support found."
437435
#endif
438436

439-
#if OPAL_ASSEMBLY_ARCH == OPAL_ARM64
437+
#if defined(PLATFORM_ARCH_AARCH64)
440438
# include "opal/sys/arm64/atomic_llsc.h"
441-
#elif OPAL_ASSEMBLY_ARCH == OPAL_POWERPC64
439+
#elif defined(PLATFORM_ARCH_POWERPC) && defined(PLATFORM_ARCH_64)
442440
# include "opal/sys/powerpc/atomic_llsc.h"
443441
#endif
444442

opal/include/opal/sys/atomic_stdc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static inline void opal_atomic_wmb(void)
5050

5151
static inline void opal_atomic_rmb(void)
5252
{
53-
# if OPAL_ASSEMBLY_ARCH == OPAL_X86_64
53+
# if defined(PLATFORM_ARCH_X86_64)
5454
/* work around a bug in older gcc versions (observed in gcc 6.x)
5555
* where acquire seems to get treated as a no-op instead of being
5656
* equivalent to __asm__ __volatile__("": : :"memory") on x86_64 */

opal/include/opal/sys/cma.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* Copyright (c) 2017 Research Organization for Information Science
66
* and Technology (RIST). All rights reserved.
77
* Copyright (c) 2020 Google, LLC. All rights reserved.
8+
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates.
9+
* All Rights reserved.
810
* $COPYRIGHT$
911
*/
1012

@@ -19,12 +21,7 @@
1921
#ifndef OPAL_SYS_CMA_H
2022
#define OPAL_SYS_CMA_H 1
2123

22-
#if !defined(OPAL_ASSEMBLY_ARCH)
23-
/* need opal_config.h for the assembly architecture */
24-
# include "opal_config.h"
25-
#endif
26-
27-
#include "opal/sys/architecture.h"
24+
#include "opal/opal_portable_platform.h"
2825

2926
#ifdef HAVE_SYS_TYPES_H
3027
# include <sys/types.h>
@@ -34,28 +31,28 @@
3431
# include <sys/unistd.h>
3532
#endif
3633

37-
#ifdef __linux__
34+
#ifdef PLATFORM_OS_LINUX
3835

3936
/* Cross Memory Attach is so far only supported under linux */
4037

41-
# if OPAL_ASSEMBLY_ARCH == OPAL_X86_64
38+
# if defined(PLATFORM_ARCH_x86_64)
4239
# define __NR_process_vm_readv 310
4340
# define __NR_process_vm_writev 311
44-
# elif OPAL_ASSEMBLY_ARCH == OPAL_IA32
41+
# elif defined(PLATFORM_ARCH_X86)
4542
# define __NR_process_vm_readv 347
4643
# define __NR_process_vm_writev 348
47-
# elif OPAL_ASSEMBLY_ARCH == OPAL_POWERPC32
44+
# elif defined(PLATFORM_ARCH_POWERPC) && defined(PLATFORM_ARCH_32)
4845
# define __NR_process_vm_readv 351
4946
# define __NR_process_vm_writev 352
50-
# elif OPAL_ASSEMBLY_ARCH == OPAL_POWERPC64
47+
# elif defined(PLATFORM_ARCH_POWERPC) && defined(PLATFORM_ARCH_64)
5148
# define __NR_process_vm_readv 351
5249
# define __NR_process_vm_writev 352
53-
# elif OPAL_ASSEMBLY_ARCH == OPAL_ARM
50+
# elif defined(PLATFORM_ARCH_ARM)
5451

5552
# define __NR_process_vm_readv 376
5653
# define __NR_process_vm_writev 377
5754

58-
# elif OPAL_ASSEMBLY_ARCH == OPAL_ARM64
55+
# elif defined(PLATFORM_ARCH_AARCH64)
5956

6057
/* ARM64 uses the asm-generic syscall numbers */
6158

opal/include/opal/sys/gcc_builtin/atomic.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
* Memory Barriers
3636
*
3737
*********************************************************************/
38-
#if (OPAL_ASSEMBLY_ARCH == OPAL_X86_64) && defined (__GNUC__) && !defined(__llvm) && (__GNUC__ < 6)
38+
39+
#if defined(PLATFORM_ARCH_X86_64) && defined (__GNUC__) && !defined(__llvm) && (__GNUC__ < 6)
3940
/* work around a bug in older gcc versions where ACQUIRE seems to get
4041
* treated as a no-op instead */
4142
#define OPAL_BUSTED_ATOMIC_MB 1

opal/include/opal/sys/timer.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
#ifndef OPAL_SYS_TIMER_H
3434
#define OPAL_SYS_TIMER_H 1
3535

36-
#include "opal_config.h"
37-
38-
#include "opal/sys/architecture.h"
36+
#include "opal/opal_portable_platform.h"
3937

4038
#ifdef HAVE_SYS_TYPES_H
4139
# include <sys/types.h>
@@ -59,11 +57,11 @@ BEGIN_C_DECLS
5957

6058
#if defined(DOXYGEN)
6159
/* don't include system-level gorp when generating doxygen files */
62-
#elif OPAL_ASSEMBLY_ARCH == OPAL_X86_64 || OPAL_ASSEMBLY_ARCH == OPAL_IA32
60+
#elif defined(PLATFORM_ARCH_X86_64) || defined(PLATFORM_ARCH_X86)
6361
# include "opal/sys/x86_64/timer.h"
64-
#elif OPAL_ASSEMBLY_ARCH == OPAL_ARM64 || OPAL_ASSEMBLY_ARCH == OPAL_ARM
62+
#elif defined(PLATFORM_ARCH_ARM) || defined(PLATFORM_ARCH_AARCH64)
6563
# include "opal/sys/arm64/timer.h"
66-
#elif OPAL_ASSEMBLY_ARCH == OPAL_POWERPC64 || OPAL_ASSEMBLY_ARCH == OPAL_POWERPC32
64+
#elif defined(PLATFORM_ARCH_POWERPC)
6765
# include "opal/sys/powerpc/timer.h"
6866
#endif
6967

opal/include/opal/sys/x86_64/timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ typedef uint64_t opal_timer_t;
3232

3333
#if OPAL_C_GCC_INLINE_ASSEMBLY
3434

35-
# if OPAL_ASSEMBLY_ARCH == OPAL_X86_64
35+
# if defined(PLATFORM_ARCH_X86_64)
3636

3737
/* TODO: add AMD mfence version and dispatch at init */
3838
static inline opal_timer_t opal_sys_timer_get_cycles(void)

opal/mca/patcher/base/base.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* All rights reserved.
1313
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
1414
* reserved.
15+
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates.
16+
* All Rights reserved.
1517
* $COPYRIGHT$
1618
*
1719
* Additional copyrights may follow
@@ -24,6 +26,7 @@
2426
#define OPAL_PATCHER_BASE_H
2527

2628
#include "opal_config.h"
29+
#include "opal/opal_portable_platform.h"
2730
#include "opal/mca/base/mca_base_framework.h"
2831
#include "opal/mca/patcher/patcher.h"
2932

@@ -69,7 +72,7 @@ OPAL_DECLSPEC void mca_base_patcher_patch_apply_binary(mca_patcher_base_patch_t
6972

7073
static inline uintptr_t mca_patcher_base_addr_text(uintptr_t addr)
7174
{
72-
#if (OPAL_ASSEMBLY_ARCH == OPAL_POWERPC64) && (!defined(_CALL_ELF) || (_CALL_ELF != 2))
75+
#if defined(PLATFORM_ARCH_POWERPC) && defined(PLATFORM_ARCH_64) && (!defined(_CALL_ELF) || (_CALL_ELF != 2))
7376
struct odp_t {
7477
uintptr_t text;
7578
uintptr_t toc;

0 commit comments

Comments
 (0)