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

Patch 11.8.4 #138

Merged
merged 1 commit into from
Oct 7, 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
51 changes: 27 additions & 24 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ __pycache__/
.pytest_cache/
.benchmarks/
*.cpp
!cuda/_lib/param_packer.cpp
!cuda/_cuda/loader.cpp
!cuda/cuda/bindings/_lib/param_packer.cpp
!cuda/cuda/bindings/_bindings/loader.cpp

# CUDA Python specific (auto-generated)
cuda/_cuda/ccuda.pxd
cuda/_cuda/ccuda.pyx
cuda/_cuda/cnvrtc.pxd
cuda/_cuda/cnvrtc.pyx
cuda/_lib/ccudart/ccudart.pxd
cuda/_lib/ccudart/ccudart.pyx
cuda/_lib/ccudart/utils.pxd
cuda/_lib/ccudart/utils.pyx
cuda/_lib/utils.pxd
cuda/_lib/utils.pyx
cuda/ccuda.pxd
cuda/ccuda.pyx
cuda/ccudart.pxd
cuda/ccudart.pyx
cuda/cnvrtc.pxd
cuda/cnvrtc.pyx
cuda/cuda.pxd
cuda/cuda.pyx
cuda/cudart.pxd
cuda/cudart.pyx
cuda/nvrtc.pxd
cuda/nvrtc.pyx
cuda/cuda/bindings/_bindings/cydriver.pxd
cuda/cuda/bindings/_bindings/cydriver.pyx
cuda/cuda/bindings/_bindings/cynvrtc.pxd
cuda/cuda/bindings/_bindings/cynvrtc.pyx
cuda/cuda/bindings/_lib/cyruntime/cyruntime.pxd
cuda/cuda/bindings/_lib/cyruntime/cyruntime.pyx
cuda/cuda/bindings/_lib/cyruntime/utils.pxd
cuda/cuda/bindings/_lib/cyruntime/utils.pyx
cuda/cuda/bindings/_lib/utils.pxd
cuda/cuda/bindings/_lib/utils.pyx
cuda/cuda/bindings/cydriver.pxd
cuda/cuda/bindings/cydriver.pyx
cuda/cuda/bindings/cyruntime.pxd
cuda/cuda/bindings/cyruntime.pyx
cuda/cuda/bindings/cynvrtc.pxd
cuda/cuda/bindings/cynvrtc.pyx
cuda/cuda/bindings/driver.pxd
cuda/cuda/bindings/driver.pyx
cuda/cuda/bindings/runtime.pxd
cuda/cuda/bindings/runtime.pyx
cuda/cuda/bindings/nvrtc.pxd
cuda/cuda/bindings/nvrtc.pyx

# Distribution / packaging
.Python
Expand Down Expand Up @@ -168,3 +168,6 @@ dmypy.json

# Cython debug symbols
cython_debug/

# Dont ignore
!.github/actions/build/
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

24 changes: 24 additions & 0 deletions continuous_integration/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: cuda_python
channels:
- defaults
dependencies:
- python>=3.10
- cython>=3.0.0
- pytest>=6.2.4
- numpy>=1.21.1
- setuptools
- wheel
- pip
- cuda-version=12.6
- cuda-cudart-static
- cuda-driver-dev
- cuda-cudart-dev
- cuda-profiler-api
- cuda-nvrtc-dev
- cuda-nvcc
- pip:
- pytest-benchmark>=3.4.1
- pyclibrary>=0.1.7
- versioneer==0.29
- tomli; python_version < "3.11"
- pywin32; sys_platform == 'win32'
1 change: 1 addition & 0 deletions continuous_integration/no_dependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "packages" : {} }
30 changes: 30 additions & 0 deletions continuous_integration/scripts/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

build_ci() {
set -xeou pipefail

cd "${REPO_DIR}"

export CUDA_HOME="${CONDA_PREFIX}/targets/x86_64-linux"
export PARALLEL_LEVEL=$(nproc --ignore 1)

python setup.py bdist_wheel
}

build_project() {
set -xeou pipefail

export PYTHONUNBUFFERED=1

. setup-utils;
init_build_env "$@";

git config --global --add safe.directory "$REPO_DIR/.git"

case "${BUILD_TYPE}" in
ci) build_ci;;
*) return 1;;
esac
}

(build_project "$@");
16 changes: 16 additions & 0 deletions continuous_integration/scripts/conda-utils
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

activate_conda_env() {
set +xu
eval "$(conda shell.bash hook)"
conda activate "${CONDA_ENV}";
set -xu
: ${PYTHON_VERSION:=$(python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")}
export PYTHON_VERSION
}

conda_info() {
set +x
conda info
set -x
}
20 changes: 20 additions & 0 deletions continuous_integration/scripts/entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

set_initial_env() {
set -xeuo pipefail

export PATH="${PATH}:${REPO_DIR}/continuous_integration/scripts"
}

entrypoint() {
set -xeuo pipefail
set_initial_env;

git config --global --add safe.directory "$REPO_DIR/.git"

cd "${REPO_DIR}"

exec "$@";
}

entrypoint "$@";
35 changes: 35 additions & 0 deletions continuous_integration/scripts/make-conda-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

set -x

make_ci_env() {
mamba env create -n "${CONDA_ENV}" -f "${REPO_DIR}/continuous_integration/environment.yml"
}

make_test_env() {
. conda-utils

mamba env create -n "${CONDA_ENV}" -f "${REPO_DIR}/continuous_integration/environment.yml"

activate_conda_env

pip install "${ARTIFACTS_DIR}"/*.whl

}

make_conda_env() {
set -xeuo pipefail

. setup-utils;
set_base_defs;

case "$1" in
ci) make_ci_env;;
test) make_test_env;;
*) return 1;;
esac

return 0;
}

(make_conda_env "$@");
52 changes: 52 additions & 0 deletions continuous_integration/scripts/render-template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env python3

import argparse
import json
from jinja2 import Environment, FileSystemLoader
import os
import re

# TODO: make this work for arbitrary context. ie. implement replace_using_context()
def replace_placeholder(source_str, variable_name, variable_value):
# Escaping any regex special characters in variable_name
variable_name_escaped = re.escape(variable_name)

# Using regular expression to replace ${variable_name} with actual variable_value
# \s* means any amount of whitespace (including none)
# pattern = rf'\$\{{\s*\{{\s*{variable_name_escaped}\s*\}}\s*\}}'
pattern = rf'<<\s*{variable_name_escaped}\s*>>'
return re.sub(pattern, variable_value.strip(), source_str)

# Setup command-line argument parsing
parser = argparse.ArgumentParser(description='Render a Jinja2 template using a JSON context.')
parser.add_argument('template_file', type=str, help='Path to the Jinja2 template file (with .j2 extension).')
parser.add_argument('json_file', type=str, help='Path to the JSON file to use as the rendering context.')
parser.add_argument('output_file', type=str, help='Path to the output file.')

args = parser.parse_args()

# Load JSON file as the rendering context
with open(args.json_file, 'r') as file:
context = json.load(file)

# Setup Jinja2 environment and load the template
env = Environment(
loader=FileSystemLoader(searchpath='./'),
variable_start_string='<<',
variable_end_string='>>',
block_start_string='<%',
block_end_string='%>',
comment_start_string='<#',
comment_end_string='#>')
env.filters['replace_placeholder'] = replace_placeholder

template = env.get_template(args.template_file)

# Render the template with the context
rendered_content = template.render(context)
# print(rendered_content)

with open(args.output_file, 'w') as file:
file.write(rendered_content)

print(f'Template rendered successfully. Output saved to {args.output_file}')
Loading