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 cuda-opencl recipe #23002

Merged
merged 13 commits into from
Jun 13, 2023
9 changes: 9 additions & 0 deletions recipes/cuda-opencl/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if not exist %PREFIX% mkdir %PREFIX%

move lib\x64\* %LIBRARY_LIB%
move include\* %LIBRARY_INC%
adibbley marked this conversation as resolved.
Show resolved Hide resolved

not exist %LIBRARY_PREFIX%\etc mkdir %LIBRARY_PREFIX%\etc
not exist %LIBRARY_PREFIX%\etc\OpenCL mkdir %LIBRARY_PREFIX%\etc\OpenCL
not exist %LIBRARY_PREFIX%\etc\OpenCL\vendors mkdir %LIBRARY_PREFIX%\etc\OpenCL\vendors
type nul >> %LIBRARY_PREFIX%\etc\OpenCL\vendors\cuda.icd
31 changes: 31 additions & 0 deletions recipes/cuda-opencl/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Install to conda style directories
[[ -d lib64 ]] && mv lib64 lib
mkdir -p ${PREFIX}/lib/pkgconfig
[[ -d pkg-config ]] && mv pkg-config/* ${PREFIX}/lib/pkgconfig
[[ -d "$PREFIX/lib/pkgconfig" ]] && sed -E -i "s|cudaroot=.+|cudaroot=$PREFIX|g" $PREFIX/lib/pkgconfig/opencl-*.pc

[[ ${target_platform} == "linux-64" ]] && targetsDir="targets/x86_64-linux"
[[ ${target_platform} == "linux-ppc64le" ]] && targetsDir="targets/ppc64le-linux"
[[ ${target_platform} == "linux-aarch64" ]] && targetsDir="targets/sbsa-linux"

for i in `ls`; do
[[ $i == "build_env_setup.sh" ]] && continue
[[ $i == "conda_build.sh" ]] && continue
[[ $i == "metadata_conda_debug.yaml" ]] && continue
if [[ $i == "lib" ]] || [[ $i == "include" ]]; then
# Headers and libraries are installed to targetsDir
mkdir -p ${PREFIX}/${targetsDir}
mkdir -p ${PREFIX}/$i
cp -rv $i ${PREFIX}/${targetsDir}
# Don't symlink libs in $PREFIX/lib to avoid clobbering
else
# Put all other files in targetsDir
mkdir -p ${PREFIX}/${targetsDir}/${PKG_NAME}
cp -rv $i ${PREFIX}/${targetsDir}/${PKG_NAME}
fi
done

mkdir -p "${PREFIX}/etc/OpenCL/vendors"
echo "${PREFIX}/${targetsDir}/lib/libOpenCL.so" > "${PREFIX}/etc/OpenCL/vendors/cuda.icd"
107 changes: 107 additions & 0 deletions recipes/cuda-opencl/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{% set name = "cuda-opencl" %}
{% set version = "12.0.76" %}
{% set lib_version = "1.0.0" %}
{% set cuda_version = "12.0" %}
{% set platform = "linux-x86_64" %} # [linux64]
{% set platform = "windows-x86_64" %} # [win]
{% set target_name = "x86_64-linux" %} # [linux64]
{% set target_name = "x64" %} # [win]
{% set extension = "tar.xz" %} # [not win]
{% set extension = "zip" %} # [win]

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

source:
url: https://developer.download.nvidia.com/compute/cuda/redist/cuda_opencl/{{ platform }}/cuda_opencl-{{ platform }}-{{ version }}-archive.{{ extension }}
sha256: 285b646a231d1101d7ffb7b37ca081f2c170114102ebfd0439fe189dbdc07b37 # [linux64]
sha256: 9a8688abf527dd1105e2f366e5aa84f901975a3ba94d977088764c45586370d3 # [win]

build:
number: 0
skip: true # [osx or aarch64 or ppc64le]

test:
commands:
- test -f $PREFIX/targets/{{ target_name }}/lib/libOpenCL.so.{{ lib_version }} # [linux]
- test -L $PREFIX/targets/{{ target_name }}/lib/libOpenCL.so.{{ lib_version.split(".")[0] }} # [linux]
- test -L $PREFIX/targets/{{ target_name }}/lib/libOpenCL.so.{{ lib_version.split(".")[0] }}.{{ lib_version.split(".")[1] }} # [linux]
jakirkham marked this conversation as resolved.
Show resolved Hide resolved
- test -f $PREFIX/etc/OpenCL/vendors/cuda.icd # [linux]
- if not exist %LIBRARY_PREFIX%\etc\OpenCL\vendors\cuda.icd exit 1 # [win]

outputs:
- name: cuda-opencl
files:
- targets/{{ target_name }}/lib/libOpenCL.so.* # [linux]
- etc/OpenCL/vendors/cuda.icd # [linux]
- Library\etc\OpenCL\vendors\cuda.icd # [win]
requirements:
build:
- {{ compiler("c") }}
- {{ compiler("cxx") }}
host:
- cuda-version {{ cuda_version }}
- ocl-icd # [linux]
- khronos-opencl-icd-loader # [win]
run:
- {{ pin_compatible("cuda-version", max_pin="x.x") }}
- ocl-icd # [linux]
- khronos-opencl-icd-loader # [win]
# Tests are defined at the top level, due to package/output name conflicts.
about:
home: https://developer.nvidia.com/cuda-toolkit
license_file: LICENSE
license: LicenseRef-NVIDIA-End-User-License-Agreement
license_url: https://docs.nvidia.com/cuda/eula/index.html
summary: CUDA OpenCL native Libraries
description: |
CUDA OpenCL native Libraries
doc_url: https://docs.nvidia.com/cuda/index.html

- name: cuda-opencl-dev
build:
run_exports:
- {{ pin_subpackage("cuda-opencl", max_pin="x") }}
files:
- lib/pkgconfig # [linux]
- targets/{{ target_name }}/include # [linux]
- targets/{{ target_name }}/lib/libOpenCL.so # [linux]
- Library\include # [win]
- Library\lib # [win]
requirements:
host:
- cuda-version {{ cuda_version }}
run:
- {{ pin_compatible("cuda-version", max_pin="x.x") }}
- {{ pin_subpackage("cuda-opencl", exact=True) }}
test:
commands:
- test -f $PREFIX/lib/pkgconfig/opencl-*.pc # [linux]
- test -f $PREFIX/targets/{{ target_name }}/include/CL/cl.h # [linux]
- test -L $PREFIX/targets/{{ target_name }}/lib/libOpenCL.so # [linux]
- if not exist %LIBRARY_INC%\CL\cl.h exit 1 # [win]
- if not exist %LIBRARY_LIB%\OpenCL.lib exit 1 # [win]
about:
home: https://developer.nvidia.com/cuda-toolkit
license_file: LICENSE
license: LicenseRef-NVIDIA-End-User-License-Agreement
license_url: https://docs.nvidia.com/cuda/eula/index.html
summary: CUDA OpenCL native Libraries
description: |
CUDA OpenCL native Libraries
doc_url: https://docs.nvidia.com/cuda/index.html

about:
home: https://developer.nvidia.com/cuda-toolkit
license: LicenseRef-NVIDIA-End-User-License-Agreement
license_file: LICENSE
license_url: https://docs.nvidia.com/cuda/eula/index.html
summary: CUDA OpenCL native Libraries
description: |
CUDA OpenCL native Libraries
doc_url: https://docs.nvidia.com/cuda/index.html

extra:
recipe-maintainers:
- adibbley