diff --git a/dart-if/include/dash/dart/if/dart_types.h b/dart-if/include/dash/dart/if/dart_types.h index c391e198b..0887edae1 100644 --- a/dart-if/include/dash/dart/if/dart_types.h +++ b/dart-if/include/dash/dart/if/dart_types.h @@ -328,7 +328,13 @@ typedef enum dart_locality_scope_t; /** Maximum size of a host name string in \ref dart_hwinfo_t */ -#define DART_LOCALITY_HOST_MAX_SIZE (HOST_NAME_MAX) +#if defined(HOST_NAME_MAX) + #define DART_LOCALITY_HOST_MAX_SIZE (HOST_NAME_MAX) +#elif defined(_POSIX_HOST_NAME_MAX) + #define DART_LOCALITY_HOST_MAX_SIZE (_POSIX_HOST_NAME_MAX) +#else + #define DART_LOCALITY_HOST_MAX_SIZE ((int)(256)) +#endif /** Maximum size of a domain tag string in \ref dart_hwinfo_t */ #define DART_LOCALITY_DOMAIN_TAG_MAX_SIZE ((int)(32)) /** Maximum number of domain scopes in \ref dart_hwinfo_t */ diff --git a/dart-impl/base/CMakeLists.txt b/dart-impl/base/CMakeLists.txt index 36ca80de4..68e802034 100644 --- a/dart-impl/base/CMakeLists.txt +++ b/dart-impl/base/CMakeLists.txt @@ -81,7 +81,9 @@ if (NOT ENABLE_SHARED_WINDOWS) "${ADDITIONAL_COMPILE_FLAGS} -DDART_MPI_DISABLE_SHARED_WINDOWS") endif() -set (ADDITIONAL_LIBRARIES ${ADDITIONAL_LIBRARIES} rt) +if(NOT APPLE) + set (ADDITIONAL_LIBRARIES ${ADDITIONAL_LIBRARIES} rt) +endif() set(DASH_DART_BASE_INCLUDE_DIRS diff --git a/dart-impl/base/src/hwinfo.c b/dart-impl/base/src/hwinfo.c index f7a6b15aa..73f543d1e 100644 --- a/dart-impl/base/src/hwinfo.c +++ b/dart-impl/base/src/hwinfo.c @@ -4,6 +4,29 @@ # define _GNU_SOURCE # include #endif + +#ifdef DART__PLATFORM__OSX +#include +#include + +#define CPUID(INFO, LEAF, SUBLEAF) __cpuid_count(LEAF, SUBLEAF, INFO[0], INFO[1], INFO[2], INFO[3]) + +static int osx_sched_getcpu() { + uint32_t CPUInfo[4]; + int cpuid; + CPUID(CPUInfo, 1, 0); + /* CPUInfo[1] is EBX, bits 24-31 are APIC ID */ + if ( (CPUInfo[3] & (1 << 9)) == 0) { + cpuid = -1; /* no APIC on chip */ + } + else { + cpuid = (unsigned)CPUInfo[1] >> 24; + } + if (cpuid < 0) cpuid = 0; + return cpuid; +} +#endif + #include #include #include @@ -353,15 +376,17 @@ dart_ret_t dart_hwinfo( } #endif /* DART_ENABLE_PAPI */ -#ifdef DART__PLATFORM__LINUX - if (hw.cpu_id < 0) { +if (hw.cpu_id < 0) { + #ifdef DART__PLATFORM__LINUX hw.cpu_id = sched_getcpu(); - } -#else - DART_LOG_ERROR("dart_hwinfo: " - "HWLOC or PAPI required if not running on a Linux platform"); - return DART_ERR_OTHER; -#endif + #elif defined(DART__PLATFORM__OSX) + hw.cpu_id = osx_sched_getcpu(); + #else + DART_LOG_ERROR("dart_hwinfo: " + "HWLOC or PAPI required if not running on a Linux or OSX platform"); + return DART_ERR_OTHER; + #endif +} #ifdef DART__ARCH__IS_MIC /* diff --git a/dart-impl/mpi/CMakeLists.txt b/dart-impl/mpi/CMakeLists.txt index 767807d21..5977b1428 100644 --- a/dart-impl/mpi/CMakeLists.txt +++ b/dart-impl/mpi/CMakeLists.txt @@ -153,7 +153,9 @@ if(MPI_COMPILE_FLAGS) ${ADDITIONAL_COMPILE_FLAGS} ${MPI_COMPILE_FLAGS}) endif() -set (ADDITIONAL_LIBRARIES ${ADDITIONAL_LIBRARIES} rt) +if(NOT APPLE) + set (ADDITIONAL_LIBRARIES ${ADDITIONAL_LIBRARIES} rt) +endif() message (STATUS "DART additional compile flags:") set(ADDITIONAL_COMPILE_FLAGS_STR "") diff --git a/dart-impl/mpi/src/dart_synchronization.c b/dart-impl/mpi/src/dart_synchronization.c index 5da5a9139..4d5a62d4f 100644 --- a/dart-impl/mpi/src/dart_synchronization.c +++ b/dart-impl/mpi/src/dart_synchronization.c @@ -23,8 +23,6 @@ #include #include #include -#include - struct dart_lock_struct { diff --git a/dash/CMakeLists.txt b/dash/CMakeLists.txt index e86df9908..248dd2f42 100644 --- a/dash/CMakeLists.txt +++ b/dash/CMakeLists.txt @@ -102,7 +102,7 @@ if (PAPI_FOUND AND ENABLE_PAPI) ${PAPI_INCLUDE_DIRS}) set (ADDITIONAL_LIBRARIES ${ADDITIONAL_LIBRARIES} ${PAPI_LIBRARIES}) -else() +elseif(NOT APPLE) set (ADDITIONAL_LIBRARIES ${ADDITIONAL_LIBRARIES} rt) endif() diff --git a/dash/examples/bench.07.local-copy/main.cpp b/dash/examples/bench.07.local-copy/main.cpp index d4e083d5b..069292246 100644 --- a/dash/examples/bench.07.local-copy/main.cpp +++ b/dash/examples/bench.07.local-copy/main.cpp @@ -11,8 +11,6 @@ #include #include -#include - #ifdef DASH_ENABLE_IPM #include #endif @@ -22,6 +20,12 @@ using std::endl; using std::setw; using std::setprecision; +static void *_aligned_malloc(size_t size, size_t alignment) { + void *buffer; + posix_memalign(&buffer, alignment, size); + return buffer; +} + typedef double ElementType; typedef int64_t index_t; typedef dash::Array< @@ -319,7 +323,7 @@ measurement copy_block_to_local( ElementType * local_array = nullptr; if (myid == target_unit_id) { local_array = static_cast( - memalign(align_size, block_bytes)); + _aligned_malloc(block_bytes, align_size)); } Array_t global_array; diff --git a/dash/include/dash/internal/Config.h b/dash/include/dash/internal/Config.h index 90e5d0d39..c795fd259 100644 --- a/dash/include/dash/internal/Config.h +++ b/dash/include/dash/internal/Config.h @@ -157,6 +157,7 @@ // OSX #if defined(__MACH__) && defined(__APPLE__) # define DASH__PLATFORM__OSX +# define DASH__PLATFORM__POSIX #endif // UX #if (defined(__hpux) || defined(hpux)) || \