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

Add AdaptiveCpp #28679

Open
wants to merge 48 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
b585c2f
Add AdaptiveCpp
jeongseok-meta Dec 22, 2024
47bf21e
Add clangdev
jeongseok-meta Dec 22, 2024
3b3fca5
Add llvmdev
jeongseok-meta Dec 22, 2024
74c7c99
Move llvm deps to host
jeongseok-meta Dec 22, 2024
1d3993e
Add version constraint, llvmdev >=14,<19
jeongseok-meta Dec 22, 2024
9f4be78
Add version constraint, llvm-openmp >=14,19
jeongseok-meta Dec 22, 2024
1c1b2ef
Override c_stdlib_version to 2.34
jeongseok-meta Dec 22, 2024
b1b8bda
Add run_constrained __glibc
jeongseok-meta Dec 22, 2024
fb429ad
glibc >=2.39
jeongseok-meta Dec 22, 2024
a97244b
Add rocm-opencl
jeongseok-meta Dec 22, 2024
97b48ee
Add ocl-icd
jeongseok-meta Dec 22, 2024
ad381ff
Add fallback functions for missing fmaxmag() and fmaxmagf()
jeongseok-meta Dec 22, 2024
a4cd5bd
Use CMAKE_CXX_FLAGS instead
jeongseok-meta Dec 22, 2024
93516d8
Add patch for missing functions
jeongseok-meta Dec 22, 2024
2acf144
Add actual patch
jeongseok-meta Dec 22, 2024
b1b7401
Fix patch
jeongseok-meta Dec 22, 2024
522fef5
More fix
jeongseok-meta Dec 22, 2024
238cc6c
Remove ocl-icd
jeongseok-meta Dec 22, 2024
f94312e
Add llvmdev to req.run
jeongseok-meta Dec 22, 2024
f5b097e
llvmdev -> llvm
jeongseok-meta Dec 22, 2024
b75bd67
Merge branch 'main' into adaptivecpp
jeongseok-meta Dec 31, 2024
acf9b66
Enable osx and win
jeongseok-meta Jan 2, 2025
c5b309c
c_stdlib_version: 10.15
jeongseok-meta Jan 2, 2025
7e24532
Set CMake options explicitly
jeongseok-meta Jan 2, 2025
c9f689b
Use clang compiler for win
jeongseok-meta Jan 2, 2025
e0a0ccb
Attempt to use ClangCL for win
jeongseok-meta Jan 2, 2025
e6a5055
Merge branch 'main' into adaptivecpp
jeongseok-meta Jan 4, 2025
ed2de00
Merge branch 'main' into adaptivecpp
jeongseok-meta Jan 7, 2025
557b769
Update recipes/AdaptiveCpp/build.sh
jeongseok-meta Jan 11, 2025
ed1af68
libboost-devel -> libboost-headers
jeongseok-meta Jan 11, 2025
8902674
Add tests for a header and a library
jeongseok-meta Jan 11, 2025
b9ef41b
Add test for CLI
jeongseok-meta Jan 11, 2025
56c6a61
Add libboost
jeongseok-meta Jan 11, 2025
99161e3
Fix tests
jeongseok-meta Jan 11, 2025
63be60d
Add simple test program
jeongseok-meta Jan 11, 2025
377458a
Attempt to resolve win CLI test
jeongseok-meta Jan 11, 2025
4f7f4bc
Add libboost-devel to ignore_run_exports
jeongseok-meta Jan 11, 2025
f10fa7b
Fix test script file names
jeongseok-meta Jan 11, 2025
cd46bcd
Add clangdev for test
jeongseok-meta Jan 11, 2025
1e854f7
Ignore run exports for libboost
jeongseok-meta Jan 11, 2025
e9298d1
Skip osx for now
jeongseok-meta Jan 11, 2025
8b4d80c
TST: Don't use full paths for acpp-info
carterbox Jan 11, 2025
75e8cfa
Attempt to fix syntax error
jeongseok-meta Jan 11, 2025
3b1b6c1
Remove llvm from run req
jeongseok-meta Jan 12, 2025
f7f3a98
Move around deps to resolve export warnings
jeongseok-meta Jan 12, 2025
fa04275
Move llvm-openmp to host
jeongseok-meta Jan 12, 2025
16a0b4f
Add llvm to run req
jeongseok-meta Jan 12, 2025
cc534c2
Add llvm to ignore_run_exports
jeongseok-meta Jan 12, 2025
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
15 changes: 15 additions & 0 deletions recipes/AdaptiveCpp/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@echo on

cmake %SRC_DIR% ^
%CMAKE_ARGS% ^
-T ClangCL ^
-A x64 ^
-B build ^
-DBUILD_SHARED_LIBS=ON ^
-DWITH_CUDA_BACKEND=OFF ^
carterbox marked this conversation as resolved.
Show resolved Hide resolved
-DWITH_OPENCL_BACKEND=OFF ^
-DWITH_ROCM_BACKEND=OFF

cmake --build build --parallel --config Release

cmake --install build --config Release
18 changes: 18 additions & 0 deletions recipes/AdaptiveCpp/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -exo pipefail

cmake \
$SRC_DIR \
${CMAKE_ARGS} \
-G Ninja \
-B build \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DWITH_CUDA_BACKEND=OFF \
-DWITH_OPENCL_BACKEND=OFF \
-DWITH_ROCM_BACKEND=OFF

cmake --build build --parallel

cmake --install build --strip
2 changes: 2 additions & 0 deletions recipes/AdaptiveCpp/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
c_stdlib_version: # [osx and x86_64]
- '10.15' # [osx and x86_64]
73 changes: 73 additions & 0 deletions recipes/AdaptiveCpp/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{% set name = "AdaptiveCpp" %}
{% set version = "24.10.0" %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
- url: https://github.com/AdaptiveCpp/AdaptiveCpp/archive/v{{ version }}.tar.gz
sha256: 3bcd94eee41adea3ccc58390498ec9fd30e1548af5330a319be8ce3e034a6a0b
patches:
- patches/fallback-missing-functions.patch # [linux]

build:
number: 0
run_exports:
- {{ pin_subpackage('adaptivecpp', max_pin='x.x') }}
ignore_run_exports:
- libboost
skip: true # [osx]

requirements:
build:
- {{ compiler('cxx') }}
- {{ stdlib('c') }}
- cmake
- ninja # [not win]
host:
- clangdev
- libboost-devel
- llvm-openmp >=14,<19
- llvm >=14,<19
- spirv-tools
run:
- llvm >=14,<19
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conda has detected unused run dependencies. Could you please supress unused exports?

WARNING (adaptivecpp): run-exports library package conda-forge/linux-64::spirv-tools==2024.3=h84d6215_0 in requirements/run but it is not used (i.e. it is overdepending or perhaps statically linked? If that is what you want then add it to `build/ignore_run_exports`)
WARNING (adaptivecpp): dso library package conda-forge/linux-64::libboost==1.84.0=h6c02f8c_7 in requirements/run but it is not used (i.e. it is overdepending or perhaps statically linked? If that is what you want then add it to `build/ignore_run_exports`)
WARNING (adaptivecpp): run-exports library package conda-forge/linux-64::llvm==18.1.8=h1c4df35_2 in requirements/run but it is not used (i.e. it is overdepending or perhaps statically linked? If that is what you want then add it to `build/ignore_run_exports`)
WARNING (adaptivecpp): run-exports library package conda-forge/linux-64::llvm-openmp==18.1.8=hf5423f3_1 in requirements/run but it is not used (i.e. it is overdepending or perhaps statically linked? If that is what you want then add it to `build/ignore_run_exports`)

Possibly you may only need libboost-headers instead of libboost-devel.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only adding libboost-headers fails due to missing components:

2025-01-11T18:33:56.7315453Z -- Could NOT find Boost (missing: context fiber) (found version "1.84.0")
2025-01-11T18:33:56.7320574Z CMake Error at CMakeLists.txt:104 (message):
2025-01-11T18:33:56.7321619Z   Please provide the path to the root directory of the boost installation
2025-01-11T18:33:56.7322444Z   using the -DBOOST_ROOT option

Let me add libboost as well to see if it can resolve it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that libboost-devel is indeed required, as it needs to link to context and fiber. To suppress the warning, I will add libboost-devel to ignore_run_exports.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with boost. How is that these modules are linked, but not needed at runtime?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, there's still warnings about spriv and llvm packages.


test:
commands:
- test -f $PREFIX/include/AdaptiveCpp/sycl/sycl.hpp # [not win]
- test -f $PREFIX/lib/cmake/AdaptiveCpp/adaptivecpp-config.cmake # [not win]
- test -f $PREFIX/lib/libacpp-common${SHLIB_EXT} # [not win]
- $PREFIX/bin/acpp-info # [not win]
- if not exist %PREFIX%\\Library\\include\\AdaptiveCpp\\SYCL\\sycl.hpp exit 1 # [win]
- if not exist %PREFIX%\\Library\\lib\\cmake\\AdaptiveCpp\\adaptivecpp-config.cmake exit 1 # [win]
- if not exist %PREFIX%\\Library\\lib\\acpp-common.lib exit 1 # [win]
- if not exist %PREFIX%\\Library\\bin\\acpp-common.dll exit 1 # [win]
- "%PREFIX%\\Library\\bin\\acpp-info.exe" # [win]
carterbox marked this conversation as resolved.
Show resolved Hide resolved
requires:
- {{ compiler("c") }}
- {{ compiler("cxx") }}
- clangdev
- cmake
- ninja # [unix]
files:
- tests/

about:
home: https://adaptivecpp.github.io/
summary: 'The independent, community-driven platform for heterogeneous programming in C++'
description: |
AdaptiveCpp is the independent, community-driven modern platform for
C++-based heterogeneous programming models targeting CPUs and GPUs from all
major vendors. AdaptiveCpp lets applications adapt themselves to all the
hardware found in the system. This includes use cases where a single binary
needs to be able to target all supported hardware, or utilize hardware from
different vendors simultaneously.
license: BSD-2-Clause
license_file: LICENSE
dev_url: https://github.com/AdaptiveCpp/AdaptiveCpp

extra:
recipe-maintainers:
- jeongseok-meta
40 changes: 40 additions & 0 deletions recipes/AdaptiveCpp/patches/fallback-missing-functions.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/src/libkernel/sscp/host/math.cpp b/src/libkernel/sscp/host/math.cpp
index 9ee91df9..83b7fb1d 100644
--- a/src/libkernel/sscp/host/math.cpp
+++ b/src/libkernel/sscp/host/math.cpp
@@ -13,6 +13,35 @@
#include "hipSYCL/sycl/libkernel/sscp/builtins/builtin_config.hpp"
#include "hipSYCL/sycl/libkernel/sscp/builtins/math.hpp"

+/*
+ Patch: Provide fallback definitions for fmaxmag() and fmaxmagf() on host builds.
+ Reason:
+ - These functions are non-standard HPC/GPU extension functions and
+ do not exist in glibc or standard math libraries.
+ - Without these definitions, host compilation fails on "use of undeclared identifier 'fmaxmagf'/'fmaxmag'."
+*/
+
+#ifndef fmaxmagf
+inline float fmaxmagf(float x, float y) {
+ float ax = std::fabs(x);
+ float ay = std::fabs(y);
+ if (ax > ay) return x;
+ if (ay > ax) return y;
+ // In case of a tie, pick x arbitrarily
+ return x;
+}
+#endif
+
+#ifndef fmaxmag
+inline double fmaxmag(double x, double y) {
+ double ax = std::fabs(x);
+ double ay = std::fabs(y);
+ if (ax > ay) return x;
+ if (ay > ax) return y;
+ return x;
+}
+#endif
+
#define HIPSYCL_SSCP_MAP_HOST_FLOAT_BUILTIN(name) \
\
HIPSYCL_SSCP_BUILTIN float __acpp_sscp_##name##_f32(float x) { \
12 changes: 12 additions & 0 deletions recipes/AdaptiveCpp/run_test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@echo on

cmake tests ^
%CMAKE_ARGS% ^
-B tests/build ^
-T ClangCL ^
-A x64 ^
-DBUILD_SHARED_LIBS=ON
if errorlevel 1 exit 1

cmake --build tests/build --parallel --config Release
if errorlevel 1 exit 1
12 changes: 12 additions & 0 deletions recipes/AdaptiveCpp/run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -exo pipefail

cmake tests \
${CMAKE_ARGS} \
-G Ninja \
-B tests/build \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release

cmake --build tests/build --parallel
16 changes: 16 additions & 0 deletions recipes/AdaptiveCpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.10)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(adaptivecpp-example)

find_package(AdaptiveCpp CONFIG REQUIRED)

if(WIN32)
add_definitions(-D_USE_MATH_DEFINES)
endif()

add_executable(${PROJECT_NAME} main.cpp)
add_sycl_to_target(TARGET ${PROJECT_NAME} SOURCES main.cpp)
64 changes: 64 additions & 0 deletions recipes/AdaptiveCpp/tests/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifdef WIN32
#include <SYCL/sycl.hpp>
#else
#include <sycl/sycl.hpp>
#endif

#include <iostream>

int main(int argc, char** argv) {
try {
// Get all available SYCL platforms
std::vector<sycl::platform> platforms = sycl::platform::get_platforms();

std::cout << "Available platforms: " << platforms.size() << "\n\n";
for (const auto& plt : platforms) {
std::cout << "Platform: " << plt.get_info<sycl::info::platform::name>() << "\n";
std::cout << "Vendor: " << plt.get_info<sycl::info::platform::vendor>() << "\n";
std::cout << "Version: " << plt.get_info<sycl::info::platform::version>() << "\n\n";

// Get all devices in this platform
std::vector<sycl::device> devices = plt.get_devices();

std::cout << " Number of devices in this platform: " << devices.size() << "\n";
for (const auto& dev : devices) {
std::cout << " Device Name : " << dev.get_info<sycl::info::device::name>() << "\n";
std::cout << " Vendor : " << dev.get_info<sycl::info::device::vendor>() << "\n";
std::cout << " Driver : " << dev.get_info<sycl::info::device::driver_version>()
<< "\n";
std::cout << " Device Type : ";
switch (dev.get_info<sycl::info::device::device_type>()) {
case sycl::info::device_type::cpu:
std::cout << "CPU\n";
break;
case sycl::info::device_type::gpu:
std::cout << "GPU\n";
break;
case sycl::info::device_type::accelerator:
std::cout << "Accelerator\n";
break;
case sycl::info::device_type::host:
std::cout << "Host\n";
break;
default:
std::cout << "Unknown\n";
break;
}

// Print out some device capabilities
std::cout << " Max Compute Units: "
<< dev.get_info<sycl::info::device::max_compute_units>() << "\n";
std::cout << " Max Work Group Size: "
<< dev.get_info<sycl::info::device::max_work_group_size>() << "\n\n";
}

std::cout << "--------------------------------------\n\n";
}

} catch (sycl::exception const& e) {
std::cerr << "SYCL Exception: " << e.what() << "\n";
return 1;
}

return 0;
}
Loading