Skip to content
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

[arrayfire] New Port #14240

Merged
merged 28 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e20c145
[arrayfire] New Port
jacobkahn Oct 26, 2020
c89fa21
Format manifest file
jacobkahn Oct 27, 2020
6a60546
Remove nvidia cub, forge, and spdlog submodules and use vcpkg ports -…
jacobkahn Oct 28, 2020
a0b61ff
Remove arrayfire/assets and don't build examples
jacobkahn Oct 28, 2020
8fe3de1
Remove arrayfire/glad submodule, use port, update patch
jacobkahn Oct 28, 2020
49f6194
Add optional freeimage dependency for graphics lib
jacobkahn Oct 28, 2020
510441a
Remove rename of arrayfire threads/pass path to build
jacobkahn Oct 29, 2020
302c8fa
Update ports/arrayfire/portfile.cmake
jacobkahn Oct 29, 2020
0ad302f
Fix up cmake targets files, install bin/dlls to the proper location
jacobkahn Oct 29, 2020
2e8b7b5
Use debug bin dir if in debug mode
jacobkahn Oct 29, 2020
7914c96
Fixes for unified, Windows dlls, and more
jacobkahn Oct 30, 2020
e17b383
Add warning for Windows static builds
jacobkahn Oct 30, 2020
84822f5
Ensure CMake assets are in the proper dir for non-Windows builds
jacobkahn Oct 30, 2020
0f18617
Actually, don't change cmake targets in non-Windows systems
jacobkahn Oct 30, 2020
ff2f1b8
Remove port-version
PhoebeHui Nov 3, 2020
ca48308
Use MKL for CPU and OpenCL backends
jacobkahn Nov 4, 2020
8ccfdf3
Patch arrayfire/threads - fix duplicate include
jacobkahn Nov 5, 2020
99f5d35
Use newer af/threads, replace include path to fix Windows builds
jacobkahn Nov 5, 2020
232235c
Fix binary dir for output DLLs
jacobkahn Nov 9, 2020
eb94c4e
Update select_compute_arch to work with CUDA 11
jacobkahn Nov 10, 2020
7f1991f
Don't include CUB if using CUDA >= 11
jacobkahn Nov 10, 2020
519816c
Bump port verison to 3.7.3 to handle CUDA 11+
jacobkahn Nov 11, 2020
a320750
Update port to use 3.7.3
jacobkahn Nov 11, 2020
07789f3
Update to include MSVC 2019 fixes, fixup CMake targets on *nix
jacobkahn Nov 16, 2020
375c730
Apply suggestions from code review
strega-nil Nov 18, 2020
b49eccf
Update ports/arrayfire/portfile.cmake
strega-nil Nov 18, 2020
85052db
Change AF CMake dir since targets.cmake are included by other targets
jacobkahn Nov 18, 2020
5bade0c
Bump to commit with fixed AF version for bits
jacobkahn Nov 19, 2020
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
200 changes: 200 additions & 0 deletions ports/arrayfire/build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e1108c60..670f271b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -104,18 +104,11 @@ mark_as_advanced(
CUDA_HOST_COMPILER
CUDA_USE_STATIC_CUDA_RUNTIME
CUDA_rt_LIBRARY
- SPDLOG_BUILD_EXAMPLES
- SPDLOG_BUILD_TESTING
ADDR2LINE_PROGRAM
Backtrace_LIBRARY
AF_WITH_STATIC_MKL
)

-#Configure forge submodule
-#forge is included in ALL target if AF_BUILD_FORGE is ON
-#otherwise, forge is not built at all
-include(AFconfigure_forge_submodule)
-
configure_file(
${ArrayFire_SOURCE_DIR}/CMakeModules/version.hpp.in
${ArrayFire_BINARY_DIR}/version.hpp
@@ -159,9 +152,7 @@ if(NOT LAPACK_FOUND)
endif()
endif()

-set(SPDLOG_BUILD_TESTING OFF CACHE INTERNAL "Disable testing in spdlog")
-add_subdirectory(extern/spdlog EXCLUDE_FROM_ALL)
-add_subdirectory(extern/glad)
+find_package(spdlog CONFIG REQUIRED)
add_subdirectory(src/backend/common)
add_subdirectory(src/api/c)
add_subdirectory(src/api/cpp)
@@ -269,10 +260,6 @@ install(DIRECTORY examples/ #NOTE The slash at the end is important
DESTINATION ${AF_INSTALL_EXAMPLE_DIR}
COMPONENT examples)

-install(DIRECTORY assets/examples/ #NOTE The slash at the end is important
- DESTINATION ${AF_INSTALL_EXAMPLE_DIR}
- COMPONENT examples)
-
install(DIRECTORY "${ArrayFire_SOURCE_DIR}/LICENSES/"
DESTINATION LICENSES
COMPONENT licenses)
diff --git a/CMakeModules/AFInstallDirs.cmake b/CMakeModules/AFInstallDirs.cmake
index 2c7b96ea..b5006ee0 100644
--- a/CMakeModules/AFInstallDirs.cmake
+++ b/CMakeModules/AFInstallDirs.cmake
@@ -7,8 +7,12 @@ include(GNUInstallDirs)
# NOTE: These paths are all relative to the project installation prefix.

# Executables
-if(NOT DEFINED AF_INSTALL_BIN_DIR)
- set(AF_INSTALL_BIN_DIR "lib" CACHE PATH "Installation path for executables")
+if(CMAKE_BUILD_TYPE MATCHES Debug)
+ set(AF_INSTALL_BIN_DIR "${AF_BIN_DIR}/debug/bin")
+ message(STATUS " Setting install to debug path ${AF_INSTALL_BIN_DIR}")
+else()
+ set(AF_INSTALL_BIN_DIR "${AF_BIN_DIR}/bin")
+ message(STATUS " Setting install to release path ${AF_INSTALL_BIN_DIR}")
endif()

# Libraries
diff --git a/assets b/assets
index cd08d749..c53bfab9 160000
--- a/assets
+++ b/assets
@@ -1 +1 @@
-Subproject commit cd08d749611b324012555ad6f23fd76c5465bd6c
+Subproject commit c53bfab909adfeed626f91ed419555711e20bca5
diff --git a/src/api/unified/CMakeLists.txt b/src/api/unified/CMakeLists.txt
index 967eaa63..ff04392c 100644
--- a/src/api/unified/CMakeLists.txt
+++ b/src/api/unified/CMakeLists.txt
@@ -96,7 +96,7 @@ target_include_directories(af
target_link_libraries(af
PRIVATE
cpp_api_interface
- spdlog
+ spdlog::spdlog spdlog::spdlog_header_only
Threads::Threads
Boost::boost
${CMAKE_DL_LIBS}
diff --git a/src/backend/common/CMakeLists.txt b/src/backend/common/CMakeLists.txt
index c9fe0889..4fdfeb66 100644
--- a/src/backend/common/CMakeLists.txt
+++ b/src/backend/common/CMakeLists.txt
@@ -77,12 +77,15 @@ else()
target_sources(afcommon_interface INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/module_loading_unix.cpp)
endif()

+find_package(glad CONFIG REQUIRED)
+
target_link_libraries(afcommon_interface
INTERFACE
- spdlog
+ spdlog::spdlog
+ spdlog::spdlog_header_only
Boost::boost
- af_glad_interface
${CMAKE_DL_LIBS}
+ glad::glad
)

if(AF_BUILD_FORGE)
@@ -95,8 +98,6 @@ target_include_directories(afcommon_interface
${ArrayFire_BINARY_DIR}
SYSTEM INTERFACE
$<$<PLATFORM_ID:Darwin>:${OPENGL_INCLUDE_DIR}>
- ${ArrayFire_SOURCE_DIR}/extern/forge/include
- ${ArrayFire_BINARY_DIR}/extern/forge/include
)

if(APPLE AND NOT USE_MKL)
diff --git a/src/backend/cpu/CMakeLists.txt b/src/backend/cpu/CMakeLists.txt
index 170bb0f3..c6e20177 100644
--- a/src/backend/cpu/CMakeLists.txt
+++ b/src/backend/cpu/CMakeLists.txt
@@ -266,9 +266,10 @@ endif(AF_WITH_CPUID)

target_sources(afcpu
PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/threads/async_queue.hpp
- ${CMAKE_CURRENT_SOURCE_DIR}/threads/event.hpp
+ ${AF_CPU_THREAD_PATH}/include/threads/async_queue.hpp
+ ${AF_CPU_THREAD_PATH}/include/threads/event.hpp
)
+target_include_directories(afcpu PRIVATE ${AF_CPU_THREAD_PATH}/include)

arrayfire_set_default_cxx_flags(afcpu)

diff --git a/src/backend/cuda/CMakeLists.txt b/src/backend/cuda/CMakeLists.txt
index 7e3e4089..bbd8d838 100644
--- a/src/backend/cuda/CMakeLists.txt
+++ b/src/backend/cuda/CMakeLists.txt
@@ -110,7 +110,11 @@ cuda_include_directories(
${COMMON_INTERFACE_DIRS}
)
if(CUDA_VERSION_MAJOR VERSION_LESS 11)
- cuda_include_directories(${ArrayFire_SOURCE_DIR}/extern/cub)
+ find_path(CUB_INCLUDE_DIRS "cub/agent/agent_histogram.cuh")
+ if (${CUB_INCLUDE_DIRS} EQUAL "CUB_INCLUDE_DIRS-NOTFOUND")
+ set(CUB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/cub)
+ endif()
+ cuda_include_directories(${CUB_INCLUDE_DIRS})
endif()

file(GLOB jit_src "kernel/jit.cuh")
diff --git a/src/backend/opencl/kernel/scan_by_key/CMakeLists.txt b/src/backend/opencl/kernel/scan_by_key/CMakeLists.txt
index 9a796c9e..d9864b00 100644
--- a/src/backend/opencl/kernel/scan_by_key/CMakeLists.txt
+++ b/src/backend/opencl/kernel/scan_by_key/CMakeLists.txt
@@ -27,6 +27,7 @@ foreach(SBK_BINARY_OP ${SBK_BINARY_OPS})
add_dependencies(opencl_scan_by_key_${SBK_BINARY_OP}
${cl_kernel_targets} OpenCL::cl2hpp Boost::boost)

+ find_package(glad CONFIG REQUIRED)
target_include_directories(opencl_scan_by_key_${SBK_BINARY_OP}
PRIVATE
.
@@ -39,9 +40,7 @@ foreach(SBK_BINARY_OP ${SBK_BINARY_OPS})
$<TARGET_PROPERTY:OpenCL::OpenCL,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:OpenCL::cl2hpp,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:Boost::boost,INTERFACE_INCLUDE_DIRECTORIES>
- $<TARGET_PROPERTY:af_glad_interface,INTERFACE_INCLUDE_DIRECTORIES>
- ${ArrayFire_SOURCE_DIR}/extern/forge/include
- ${ArrayFire_BINARY_DIR}/extern/forge/include
+ $<TARGET_PROPERTY:glad::glad,INTERFACE_INCLUDE_DIRECTORIES>
)

set_target_properties(opencl_scan_by_key_${SBK_BINARY_OP}
diff --git a/src/backend/opencl/kernel/sort_by_key/CMakeLists.txt b/src/backend/opencl/kernel/sort_by_key/CMakeLists.txt
index d618ff2f..9f517398 100644
--- a/src/backend/opencl/kernel/sort_by_key/CMakeLists.txt
+++ b/src/backend/opencl/kernel/sort_by_key/CMakeLists.txt
@@ -32,14 +32,13 @@ foreach(SBK_TYPE ${SBK_TYPES})
../../../include
${CMAKE_CURRENT_BINARY_DIR})

+ find_package(glad CONFIG REQUIRED)
target_include_directories(opencl_sort_by_key_${SBK_TYPE}
SYSTEM PRIVATE
$<TARGET_PROPERTY:OpenCL::OpenCL,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:OpenCL::cl2hpp,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:Boost::boost,INTERFACE_INCLUDE_DIRECTORIES>
- $<TARGET_PROPERTY:af_glad_interface,INTERFACE_INCLUDE_DIRECTORIES>
- ${ArrayFire_SOURCE_DIR}/extern/forge/include
- ${ArrayFire_BINARY_DIR}/extern/forge/include
+ $<TARGET_PROPERTY:glad::glad,INTERFACE_INCLUDE_DIRECTORIES>
)

set_target_properties(opencl_sort_by_key_${SBK_TYPE}
diff --git a/test/data b/test/data
index 408f4405..6a48c886 160000
--- a/test/data
+++ b/test/data
@@ -1 +1 @@
-Subproject commit 408f44059015c57a66e13b4c98df86ebcb427950
+Subproject commit 6a48c88658bcd68392e99344714cb0dccd4ec285
69 changes: 69 additions & 0 deletions ports/arrayfire/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO arrayfire/arrayfire
REF 59ac7b980d1ae124aae914fb29cbf086c948954d # v3.7.3
SHA512 e8c209a5249046cb8d68877463b4f4921cfc363ec2f9b070ba67c9e00cbe7b44d5db209922dabc47e53977ff918e7f0d289f85c7571a826c2050d0ee8deae3e0
HEAD_REF master
PATCHES build.patch
)

# arrayfire cpu thread lib needed as a submodule for the CPU backend
vcpkg_from_github(
OUT_SOURCE_PATH CPU_THREADS_PATH
REPO arrayfire/threads
REF b666773940269179f19ef11c8f1eb77005e85d9a
SHA512 b3e8b54acf3a588b1f821c2774d5da2d8f8441962c6d99808d513f7117278b9066eb050b8b501bddbd3882e68eb5cc5da0b2fca54e15ab1923fe068a3fe834f5
HEAD_REF master
)

################################### Build ###################################

# Default flags
set(AF_DEFAULT_VCPKG_CMAKE_FLAGS
-DBUILD_TESTING=OFF
-DAF_BUILD_DOCS=OFF
-DAF_BUILD_EXAMPLES=OFF
-DUSE_CPU_MKL=ON
-DUSE_OPENCL_MKL=ON
-DAF_CPU_THREAD_PATH=${CPU_THREADS_PATH} # for building the arrayfire cpu threads lib
-DAF_INSTALL_CMAKE_DIR=${CURRENT_PACKAGES_DIR}/share/${PORT} # for CMake configs/targets
)

# bin/dll directory for Windows non-static builds for the unified backend dll
if (VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_LIBRARY_LINKAGE STREQUAL "static")
set(AF_BIN_DIR ${CURRENT_PACKAGES_DIR})
list(APPEND AF_DEFAULT_VCPKG_CMAKE_FLAGS "-DAF_BIN_DIR=${AF_BIN_DIR}")
endif()

if (VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "static")
message(WARNING "NOTE: Windows support with static linkeage is still experimental.")
endif()

# Determine which backend to build via specified feature
vcpkg_check_features(
OUT_FEATURE_OPTIONS AF_BACKEND_FEATURE_OPTIONS
FEATURES
unified AF_BUILD_UNIFIED
cpu AF_BUILD_CPU
cuda AF_BUILD_CUDA
opencl AF_BUILD_OPENCL
)

# Build and install
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
${AF_DEFAULT_VCPKG_CMAKE_FLAGS}
${AF_BACKEND_FEATURE_OPTIONS}
)
vcpkg_install_cmake()

vcpkg_copy_pdbs()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

# Copyright and license
file(INSTALL ${SOURCE_PATH}/COPYRIGHT.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
46 changes: 46 additions & 0 deletions ports/arrayfire/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "arrayfire",
"version-string": "3.7.3",
"description": "ArrayFire is a general-purpose library that simplifies the process of developing software that targets parallel and massively-parallel architectures including CPUs, GPUs, and other hardware acceleration devices.",
jacobkahn marked this conversation as resolved.
Show resolved Hide resolved
"supports": "x64",
"dependencies": [
"boost-compute",
"boost-stacktrace",
"forge",
"freeimage",
"glad",
"spdlog"
],
"default-features": [
"cpu",
"unified"
],
"features": {
"cpu": {
"description": "ArrayFire CPU backend",
"dependencies": [
"intel-mkl"
jacobkahn marked this conversation as resolved.
Show resolved Hide resolved
]
},
"cuda": {
"description": "ArrayFire CUDA backend",
"dependencies": [
"cub",
"cuda",
"cudnn"
]
},
"opencl": {
"description": "ArrayFire OpenCL backend",
"dependencies": [
"opencl"
]
},
"unified": {
"description": "ArrayFire unified backend",
"dependencies": [
"intel-mkl"
]
}
}
}