Skip to content

Commit

Permalink
Merge pull request #675 from anindex/sup-build-macOS
Browse files Browse the repository at this point in the history
Support DASH builds and tests on MacOS
  • Loading branch information
devreal authored Jan 28, 2020
2 parents 534a40f + eb22d3c commit d72dfc5
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 17 deletions.
8 changes: 7 additions & 1 deletion dart-if/include/dash/dart/if/dart_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 3 additions & 1 deletion dart-impl/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 33 additions & 8 deletions dart-impl/base/src/hwinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@
# define _GNU_SOURCE
# include <sched.h>
#endif

#ifdef DART__PLATFORM__OSX
#include <cpuid.h>
#include <stdint.h>

#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 <dash/dart/base/macro.h>
#include <dash/dart/base/logging.h>
#include <dash/dart/base/locality.h>
Expand Down Expand Up @@ -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
/*
Expand Down
4 changes: 3 additions & 1 deletion dart-impl/mpi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
Expand Down
2 changes: 0 additions & 2 deletions dart-impl/mpi/src/dart_synchronization.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <malloc.h>


struct dart_lock_struct
{
Expand Down
2 changes: 1 addition & 1 deletion dash/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 7 additions & 3 deletions dash/examples/bench.07.local-copy/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include <cstring>
#include <limits>

#include <malloc.h>

#ifdef DASH_ENABLE_IPM
#include <mpi.h>
#endif
Expand All @@ -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<
Expand Down Expand Up @@ -319,7 +323,7 @@ measurement copy_block_to_local(
ElementType * local_array = nullptr;
if (myid == target_unit_id) {
local_array = static_cast<ElementType *>(
memalign(align_size, block_bytes));
_aligned_malloc(block_bytes, align_size));
}

Array_t global_array;
Expand Down
1 change: 1 addition & 0 deletions dash/include/dash/internal/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)) || \
Expand Down

0 comments on commit d72dfc5

Please sign in to comment.