Skip to content

Enable building on MacOSX #358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ jobs:
run: python3 -m pip install -r third_party/requirements.txt

- name: Install hwloc
run: brew install hwloc
run: brew install hwloc jemalloc tbb

- name: Configure build
run: >
Expand All @@ -294,10 +294,11 @@ jobs:
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_ENABLE_POOL_TRACKING=ON
-DUMF_ENABLE_POOL_TRACKING=ON
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=OFF
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=OFF
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
-DUMF_BUILD_SHARED_LIBRARY=ON

- name: Build UMF
Expand All @@ -310,3 +311,7 @@ jobs:
--install-dir ${{env.INSTL_DIR}}
--build-type ${{env.BUILD_TYPE}}
--shared-library
--disjoint-pool
--jemalloc-pool
--scalable-pool
--examples
63 changes: 28 additions & 35 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ endif()
set(DLL_PATH_LIST
"${DLL_PATH_LIST};PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}/../bin")

if(UMF_BUILD_LIBUMF_POOL_SCALABLE AND (LINUX OR WINDOWS))
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
pkg_check_modules(TBB tbb)
if(NOT TBB_FOUND)
find_package(TBB REQUIRED tbb)
Expand All @@ -182,7 +182,7 @@ if(UMF_BUILD_LIBUMF_POOL_SCALABLE AND (LINUX OR WINDOWS))
"${DLL_PATH_LIST};PATH=path_list_append:${TBB_LIBRARY_DIRS}/../bin")
endif()

if(UMF_BUILD_LIBUMF_POOL_JEMALLOC AND (LINUX OR WINDOWS))
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
pkg_check_modules(JEMALLOC jemalloc)
if(NOT JEMALLOC_FOUND)
find_package(JEMALLOC REQUIRED jemalloc)
Expand All @@ -194,41 +194,39 @@ if(UMF_BUILD_LIBUMF_POOL_JEMALLOC AND (LINUX OR WINDOWS))
endif()

# set UMF_PROXY_LIB_ENABLED
if(LINUX OR WINDOWS)
if(WINDOWS AND NOT (CMAKE_BUILD_TYPE STREQUAL "Release"))
# TODO: enable the proxy library in the Debug build on Windows
if(WINDOWS AND NOT (CMAKE_BUILD_TYPE STREQUAL "Release"))
message(
STATUS
"Disabling the proxy library, because it is supported only in the Release build on Windows (CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE})"
)
elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL SCALABLE)
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
set(UMF_PROXY_LIB_ENABLED ON)
set(PROXY_LIB_USES_SCALABLE_POOL ON)
set(PROXY_LIBS umf scalable_pool)
else()
message(
STATUS
"Disabling the proxy library, because it is supported only in the Release build on Windows (CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE})"
"Disabling the proxy library, because UMF_PROXY_LIB_BASED_ON_POOL==SCALABLE but UMF_BUILD_LIBUMF_POOL_SCALABLE is OFF"
)
elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL SCALABLE)
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
set(UMF_PROXY_LIB_ENABLED ON)
set(PROXY_LIB_USES_SCALABLE_POOL ON)
set(PROXY_LIBS umf scalable_pool)
else()
message(
STATUS
"Disabling the proxy library, because UMF_PROXY_LIB_BASED_ON_POOL==SCALABLE but UMF_BUILD_LIBUMF_POOL_SCALABLE is OFF"
)
endif()
elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL JEMALLOC)
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
set(UMF_PROXY_LIB_ENABLED ON)
set(PROXY_LIB_USES_JEMALLOC_POOL ON)
set(PROXY_LIBS umf jemalloc_pool)
else()
message(
STATUS
"Disabling the proxy library, because UMF_PROXY_LIB_BASED_ON_POOL==JEMALLOC but UMF_BUILD_LIBUMF_POOL_JEMALLOC is OFF"
)
endif()
endif()
elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL JEMALLOC)
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
set(UMF_PROXY_LIB_ENABLED ON)
set(PROXY_LIB_USES_JEMALLOC_POOL ON)
set(PROXY_LIBS umf jemalloc_pool)
else()
message(
FATAL_ERROR
"Proxy library: pool manager not chosen or set to a non-supported one (see UMF_PROXY_LIB_BASED_ON_POOL)"
STATUS
"Disabling the proxy library, because UMF_PROXY_LIB_BASED_ON_POOL==JEMALLOC but UMF_BUILD_LIBUMF_POOL_JEMALLOC is OFF"
)
endif()
else()
message(
FATAL_ERROR
"Proxy library: pool manager not chosen or set to a non-supported one (see UMF_PROXY_LIB_BASED_ON_POOL)"
)
endif()

add_subdirectory(src)
Expand All @@ -238,12 +236,7 @@ if(UMF_BUILD_TESTS)
endif()

if(UMF_BUILD_BENCHMARKS)
if(LINUX OR WINDOWS)
add_subdirectory(benchmark)
else()
message(
FATAL_ERROR "benchmarks are supported on Linux and Windows only")
endif()
add_subdirectory(benchmark)
endif()

if(UMF_BUILD_EXAMPLES)
Expand Down
6 changes: 4 additions & 2 deletions cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ function(add_umf_library)
target_link_libraries(${ARG_NAME} PRIVATE ${ARG_LIBS})

target_include_directories(
${ARG_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include
${UMF_CMAKE_SOURCE_DIR}/src/base_alloc)
${ARG_NAME}
PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include
${UMF_CMAKE_SOURCE_DIR}/src/utils
${UMF_CMAKE_SOURCE_DIR}/src/base_alloc)
add_umf_target_compile_options(${ARG_NAME})
add_umf_target_link_options(${ARG_NAME})
endfunction()
Expand Down
3 changes: 1 addition & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ else()
target_sources(umf PRIVATE memory_pool_default.c)
endif()

# Currently, Level Zero provider is only built for Linux and Windows
if((LINUX OR WINDOWS) AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
target_sources(umf PRIVATE provider/provider_level_zero.c)

if(LINUX)
Expand Down
57 changes: 22 additions & 35 deletions src/pool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,45 +32,32 @@ endif()

# libumf_pool_jemalloc
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
if(LINUX OR WINDOWS)
add_umf_library(
NAME jemalloc_pool
TYPE STATIC
SRCS pool_jemalloc.c ${POOL_EXTRA_SRCS}
LIBS jemalloc umf_utils)
target_include_directories(jemalloc_pool
PRIVATE ${JEMALLOC_INCLUDE_DIRS})
target_compile_definitions(jemalloc_pool
PUBLIC ${POOL_COMPILE_DEFINITIONS})
add_library(${PROJECT_NAME}::jemalloc_pool ALIAS jemalloc_pool)
install(TARGETS jemalloc_pool EXPORT ${PROJECT_NAME}-targets)
else()
message(FATAL_ERROR "libumf_pool_jemalloc is supported on Linux and "
"Windows only")
endif()
add_umf_library(
NAME jemalloc_pool
TYPE STATIC
SRCS pool_jemalloc.c ${POOL_EXTRA_SRCS}
LIBS jemalloc umf_utils)
target_include_directories(jemalloc_pool PRIVATE ${JEMALLOC_INCLUDE_DIRS})
target_compile_definitions(jemalloc_pool PUBLIC ${POOL_COMPILE_DEFINITIONS})
add_library(${PROJECT_NAME}::jemalloc_pool ALIAS jemalloc_pool)
install(TARGETS jemalloc_pool EXPORT ${PROJECT_NAME}-targets)
endif()

# libumf_pool_scalable
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
if(LINUX OR WINDOWS)
if(LINUX)
set(LIBS_POOL_SCALABLE dl umf_utils)
elseif(WINDOWS)
set(LIBS_POOL_SCALABLE umf_utils)
endif()

add_umf_library(
NAME scalable_pool
TYPE STATIC
SRCS pool_scalable.c ${POOL_EXTRA_SRCS}
LIBS ${LIBS_POOL_SCALABLE})
target_include_directories(scalable_pool PRIVATE ${TBB_INCLUDE_DIRS})
target_compile_definitions(scalable_pool
PUBLIC ${POOL_COMPILE_DEFINITIONS})
add_library(${PROJECT_NAME}::scalable_pool ALIAS scalable_pool)
install(TARGETS scalable_pool EXPORT ${PROJECT_NAME}-targets)
if(LINUX)
set(LIBS_POOL_SCALABLE dl umf_utils)
else()
message(FATAL_ERROR "libumf_pool_scalable is supported on Linux and "
"Windows only")
set(LIBS_POOL_SCALABLE umf_utils)
endif()

add_umf_library(
NAME scalable_pool
TYPE STATIC
SRCS pool_scalable.c ${POOL_EXTRA_SRCS}
LIBS ${LIBS_POOL_SCALABLE})
target_include_directories(scalable_pool PRIVATE ${TBB_INCLUDE_DIRS})
target_compile_definitions(scalable_pool PUBLIC ${POOL_COMPILE_DEFINITIONS})
add_library(${PROJECT_NAME}::scalable_pool ALIAS scalable_pool)
install(TARGETS scalable_pool EXPORT ${PROJECT_NAME}-targets)
endif()
4 changes: 4 additions & 0 deletions test/test_proxy_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/

#if defined(__APPLE__)
#include <malloc/malloc.h>
#else
#include <malloc.h>
#endif

#include "base.hpp"
#include "test_helpers.h"
Expand Down