Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
2fcbb56
First pass at filtering CUDA kernel.
alserene Oct 15, 2024
1ad9912
Wrap header files in extern C for C linkage.
alserene Oct 17, 2024
8d13063
Add synchronisation for error catching in development.
alserene Oct 17, 2024
4f4f10c
Initial (uncompleted) GPU implementation.
alserene Oct 21, 2024
a1384c8
Add TODO comments.
alserene Oct 21, 2024
6416201
Add array handling.
alserene Oct 22, 2024
6fdfdd2
Remove comment.
alserene Oct 22, 2024
24d5509
Tidy types.
alserene Oct 22, 2024
f171e23
Remove outdated comment.
alserene Oct 22, 2024
3d53662
Tidy code.
alserene Oct 22, 2024
c444018
Minor changes to resolve error messages.
alserene Oct 23, 2024
b939e36
Add PerturbField.o to build file.
alserene Oct 25, 2024
3943d2d
Misc changes during debugging.
alserene Oct 25, 2024
51eab94
Debugging attempts
alserene Oct 25, 2024
af06767
Reorganise C and CUDA code so only CUDA related code in cu file.
alserene Oct 26, 2024
9162148
Trim trailing whitespace.
alserene Oct 27, 2024
c5f6450
Add CUDAError to list of exitcodes.
alserene Oct 28, 2024
b9d1fd3
Add CUDAError to list of error codes.
alserene Oct 28, 2024
6fdb4e8
Clean up kernel.
alserene Oct 28, 2024
0b36ebc
Remove cudaDeviceSynchronize.
alserene Oct 28, 2024
477d076
Capital letter in comment
alserene Oct 29, 2024
1d9ff1c
reset profiling libraries
Oct 31, 2024
16d3cdf
Merge branch 'v4-prep' into adacs_tiger_dev_v2
Oct 31, 2024
b32ebce
fix purging of lowres density when needed
daviesje Oct 18, 2024
a374af3
First draft of SpinTemp kernel.
alserene Nov 8, 2024
8e62698
Make corrections to fix compilation errors.
alserene Nov 8, 2024
7045288
Add SpinTemp CUDA object to build file.
alserene Nov 8, 2024
f1d5c6c
Add -lstdc++ flag for thrust.
alserene Nov 9, 2024
3689bfa
Add workaround for table struct corruption.
alserene Nov 9, 2024
4413c33
Add accessor function for SFRD_conditional_table.
alserene Nov 9, 2024
b25cefe
Fix struct corruption bug.
alserene Nov 15, 2024
456446d
Reuse memory for unchanged arrays.
alserene Nov 16, 2024
4c3800c
Fix pointer passing issue.
alserene Nov 20, 2024
1bd2f88
Add accerssor function for nbins.
alserene Nov 20, 2024
80a3e66
Update kernel param to correct type.
alserene Nov 21, 2024
6c95c8b
Remove commented old code.
alserene Nov 25, 2024
2b7289b
Resolve merge conflicts.
alserene Nov 26, 2024
38b9e53
store RGTable2D in one block of continuous memory
JHu-s Nov 28, 2024
8e330a8
store type def in a separate header file; add flatten data as a membe…
JHu-s Nov 28, 2024
7aedc54
copy global params to device constant memory
JHu-s Nov 29, 2024
7d237e0
copy nhalo, mcol, and nhalo_inv tables to device constant memory (ver…
JHu-s Nov 29, 2024
c906eee
convert relevant functions in interp_tables to device functions; fix …
JHu-s Nov 29, 2024
a4ad5f7
add cuda error checking macro
JHu-s Dec 1, 2024
f437ada
add error check for cuda runtime functions
JHu-s Dec 1, 2024
0a2df37
update cffi build
JHu-s Dec 1, 2024
16550d4
add filter function using thrust
JHu-s Dec 1, 2024
4c6e5c1
add cuda specific header; add device function for interpolation
JHu-s Dec 1, 2024
e145625
add functions to access interp tables outside the file
JHu-s Dec 1, 2024
ea41f8f
separate type def from function prototypes (tmp solution)
JHu-s Dec 1, 2024
0d31ac7
update sample progenitor kernel function with sparsity condition
JHu-s Dec 2, 2024
1f8807b
add a basic while loop to launch kernels iteratively
JHu-s Dec 2, 2024
35e603e
Merge branch latest v4-prep updates
alserene Dec 2, 2024
df8d7aa
Remove original hello-world cuda test code.
alserene Dec 4, 2024
b25bfc2
Add bound check for thread ids to fix small memory leak.
alserene Dec 4, 2024
5ef38e9
Correct numBlocks calculation; add extra bound check in reduction ker…
alserene Dec 4, 2024
49e2553
get device properties; condense array with input mask value
JHu-s Dec 5, 2024
90037bb
Add ionisation CUDA object to build file.
alserene Dec 9, 2024
ec1afc0
Add CUDA functionality to ComputeIonisation function.
alserene Dec 9, 2024
7b3a2e5
Add accessor function for Nion conditional table.
alserene Dec 9, 2024
d597148
Make indent friendly to collapse in IDE.
alserene Dec 9, 2024
3c84bde
Add error catching for individual CUDA calls + synchronisation.
alserene Dec 10, 2024
bb54adf
Wrap CUDA calls in error checking function.
alserene Dec 11, 2024
8c1e8e6
Add DEBUG messages throuhgout ComputeIonizedBox.
alserene Dec 11, 2024
d432663
Add CUDA wrapper for errors.
alserene Dec 11, 2024
3317702
Fix bug with flag passing.
alserene Dec 11, 2024
9e5c5e5
add sample correction algorithm
JHu-s Dec 14, 2024
f727a81
Correct average calculation.
alserene Dec 16, 2024
c4b984f
Correct NumBlocks bug.
alserene Dec 19, 2024
679c897
Remove unneeded lines.
alserene Dec 19, 2024
2eb2bf3
Remove synchronisation after thrust call.
alserene Dec 25, 2024
9111e2c
Slight change to calculation of numBlocks.
alserene Dec 26, 2024
2527ad1
Remove comments.
alserene Dec 26, 2024
d394156
Remove comments and debug statements.
alserene Dec 26, 2024
1acbcfb
Update comment for accuracy.
alserene Dec 26, 2024
9dbb964
Wrap CUDA calls in error checking function.
alserene Dec 30, 2024
4ed3ec8
Remove redundant casts.
alserene Dec 30, 2024
993f73b
Reorganise error checking and synchronisation after CUDA kernel and t…
alserene Dec 30, 2024
a0cbffe
add device rng functions
JHu-s Feb 9, 2025
ae0bdc5
tmp: test for cuda activation and init rand states (need to move thes…
JHu-s Feb 9, 2025
7bfec65
resolve linking issues caused by function name mangling
JHu-s Feb 9, 2025
7cafd55
add device version of functions in hmf.c
JHu-s Feb 9, 2025
f65b566
WIP: add cuda version of sampling progenitors
JHu-s Feb 10, 2025
1b047af
tmp profilings
JHu-s Feb 10, 2025
1b354b4
add cuda version of filtering (3d index)
JHu-s Feb 10, 2025
ec76419
add hello world cuda function for validation
JHu-s Feb 10, 2025
d92f42f
adjust env file for use
JHu-s Feb 10, 2025
bde0516
tmp change
JHu-s Feb 10, 2025
cafa308
merge changes for cudanize progenitor sampling
JHu-s Feb 11, 2025
ffb7902
fix linking errors
JHu-s Feb 11, 2025
00c8623
add rand state init at the beginning of creating halo field; remove o…
JHu-s Feb 13, 2025
b3d546b
Refactor PerturbField.c to separate-out MapMass_cpu().
gbpoole Feb 3, 2025
8170c6b
Place proper CUDA compile guards around code code in filtering.c
gbpoole Feb 3, 2025
d138e1f
Place proper CUDA compile guards around code code in SpinTemperatureB…
gbpoole Feb 4, 2025
a00d463
Place proper CUDA compile guards around code code in IonisationBox.c
gbpoole Feb 4, 2025
3058a1f
Remove several unneeded instances of '#include <cuda_runtime.h>'.
gbpoole Feb 4, 2025
79eda01
CPU-only build is working once again but tests are failing.
gbpoole Feb 5, 2025
e8242d8
Add meson.build
gbpoole Feb 11, 2025
637b30f
Migrate setup.py metadata to pyproject.toml and flesh-out meson build…
gbpoole Feb 11, 2025
896a62f
meson build for CPU mostly working. Import and tests fail due to bro…
gbpoole Feb 17, 2025
8cce0b0
Add nanobind as a dependency.
gbpoole Feb 24, 2025
fc636c8
Add wrapper code. Build broken due to C/C++ linkage issues.
gbpoole Feb 24, 2025
aabe2b1
Code builds but error with 'importing ffi' killing package import.
gbpoole Feb 24, 2025
d4ba9cd
Nanobind wrtapper now being built; imports from c_21cmfast disabled b…
gbpoole Feb 25, 2025
8a7e036
Import the C-extension nanobind module extension correctly; all the f…
gbpoole Feb 26, 2025
e493f18
Remove some CFFI-related comments.
gbpoole Mar 4, 2025
af24ee8
All FFI code removed but lots still NotImplemented. Build works and …
gbpoole Mar 21, 2025
442e05a
First attempt at implementing fields method of StructWrapper
gbpoole Apr 11, 2025
e07a8a6
fix building error raised by newer version of setuptools
JHu-s Apr 14, 2025
ee1e0bf
add use_cuda condition to initialcondition and stochasticity
JHu-s Apr 14, 2025
4df1540
condense other star, sfr, xray, coords array as well (reserve comment…
JHu-s Apr 14, 2025
14b97c0
move get device prop function to hello_world; add device check in ini…
JHu-s Apr 14, 2025
7b4ed3f
clean up
JHu-s Apr 15, 2025
045f263
remove tmp file
JHu-s Apr 15, 2025
18cca7b
merge cuda code for stochasticity
JHu-s May 6, 2025
dc35cc2
Place proper CUDA compile guards around code in Stochasticity.c
JHu-s May 6, 2025
c0887ea
Place proper CUDA compile guards around code in InitialConditions.c
JHu-s May 6, 2025
ef8785a
some minor cleanup
daviesje May 8, 2025
205b867
delete cffi files
daviesje May 8, 2025
233c547
Merge branch 'main' into gpu-build-v4 WIP: fix conflicts only
daviesje May 9, 2025
339d57c
compiles
daviesje May 9, 2025
aa75563
imports
daviesje May 9, 2025
5f41f42
ics computed
daviesje May 10, 2025
89d0949
change the rest of the wrapper to use nb::ndarray
daviesje May 11, 2025
9b8d9ff
fix up wrapper function arguments
daviesje May 12, 2025
6399e59
Merge branch 'main' into gpu-build-v4
daviesje May 12, 2025
28e5723
compact integration test warnings
daviesje May 12, 2025
b8a1fb9
get photoncons working
daviesje May 12, 2025
53e9e00
add compiler options for log level and debug builds
daviesje May 13, 2025
fb6a027
add files, fix call_c_simple
daviesje May 13, 2025
c53cace
non-integration tests pass
daviesje May 13, 2025
53c3444
tweak installation parameters
daviesje May 16, 2025
a2c847c
Merge branch 'main' into gpu-build-v4
daviesje Jul 8, 2025
fcb04da
Merge branch 'float-halopos' into gpu-build-v4
daviesje Jul 21, 2025
9375571
rename/remove old files
daviesje Jul 21, 2025
0b1b7df
Merge branch 'float-halopos' into gpu-build-v4
daviesje Jul 22, 2025
9d3d4d9
fix paramaeter and field names
daviesje Jul 23, 2025
2e9a38b
Merge branch 'main' into gpu-build-v4
daviesje Jul 23, 2025
dde8599
fix log level, move halo overflow error outside of parallel loop
daviesje Jul 23, 2025
3910e79
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 23, 2025
8f168ab
fix code duplication from merge
daviesje Jul 23, 2025
2a26701
use setuptools_scm for versioning
daviesje Jul 25, 2025
8af14b6
Merge branch 'main' into gpu-build-v4
daviesje Jul 29, 2025
7156183
delete old RSD params
daviesje Jul 29, 2025
fbf41eb
rename parameters in CUDA files
daviesje Jul 29, 2025
f26d048
WIP try adding CUDA compilation to the meson files
daviesje Jul 29, 2025
2f92fa6
WIP compiles
daviesje Aug 14, 2025
0724382
Merge branch 'main' into ESF-L-implementation
daviesje Aug 19, 2025
d31c5a3
fix the bugs
daviesje Aug 20, 2025
0485848
add tests
daviesje Aug 21, 2025
6acb370
actually add the test file
daviesje Aug 21, 2025
5f7df6b
add flag for halobox outputs not used in calculation
daviesje Aug 21, 2025
43593b4
fix bugs from removing integral count field
daviesje Aug 24, 2025
b992c20
add tests for optional fields
daviesje Aug 24, 2025
f6c640b
cover last case
daviesje Aug 25, 2025
5cb1898
make cosmo a cached property
daviesje Aug 25, 2025
7878625
regenerate integration test data
daviesje Aug 25, 2025
5976814
Merge branch 'ESF-L-implementation' into gpu-build-v4
daviesje Aug 25, 2025
7ca07d0
fix compilation
daviesje Aug 25, 2025
6e749b5
fix import
daviesje Aug 25, 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
6 changes: 0 additions & 6 deletions .bumpversion.cfg

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ src/21cmFAST.egg-info/
pip-wheel-metadata/
src/py21cmfast\.egg-info/

.python-version

*.so
build/
*.*~
Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

132 changes: 0 additions & 132 deletions build_cffi.py

This file was deleted.

18 changes: 0 additions & 18 deletions bump

This file was deleted.

4 changes: 1 addition & 3 deletions environment_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ dependencies:
- zlib
- pip
- libxml2
- libffi
- zipp
- click
- scipy
Expand Down Expand Up @@ -47,7 +46,6 @@ dependencies:
- qt
- packaging
- ipython_genutils
- cffi
- pytest-remotedata
- nomkl
- chardet
Expand Down Expand Up @@ -117,4 +115,4 @@ dependencies:
- pytest-plt
- questionary
- pip:
- pre-commit
- pre-commit
72 changes: 72 additions & 0 deletions install_custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/python
"""
install_custom.py provides a custom installation process for the 21cmFAST package.

Allows users to specify various build and configuration options via command-line arguments.

Features:
- Allows setting the log level for the installation process.
- Provides an option to enable debug symbols for the build.
- Enables customization of the optimization level for the build process.

Command-line Arguments:
- --log-level: Specifies the log level for the build process. Options include:
NO_LOG, ERROR, WARNING, INFO, DEBUG, SUPER_DEBUG, ULTRA_DEBUG. Defaults to WARNING.
- --debug: Enables debug symbols for the build, which can be useful for debugging.
- -o, --optimization: Sets the optimization level for the build (e.g., -O0, -O1, -O2, -O3).
Defaults to 3.

Usage:
Run the script from the command line to install 21cmFAST with the desired options:
python install_custom.py [options]

Example:
python install_custom.py --log-level DEBUG --debug -o 2

Dependencies:
- Python 3.x
- pip (Python package installer)

Note:
This script uses the `subprocess` module to invoke the `pip install` command with
custom configuration settings.

"""

import argparse
import subprocess

# Define the command-line arguments
parser = argparse.ArgumentParser(description="Install 21cmFAST with custom options.")
parser.add_argument(
"--log-level",
type=str,
default="WARNING",
help="Set the log level (NO_LOG, ERROR, WARNING, INFO, DEBUG, SUPER_DEBUG, ULTRA_DEBUG)",
)
parser.add_argument("--debug", action="store_true", help="Enable debug symbols")
parser.add_argument(
"-o",
"--optimization",
help="optimisation level (i,e -O0, -O1, -O2, -O3)",
default="3",
)

args = parser.parse_args()
if args.optimization not in ["0", "g", "1", "2", "3", "s"]:
raise ValueError("Invalid optimization level. Choose from 0, g, 1, 2, 3 or s")

# Get the LOG_LEVEL environment variable (default to 'WARNING' if not set)
log_level_str = args.log_level
setup_args = [
f"--config-setting=setup-args=-Dlog_level={log_level_str}",
]

debug = str(args.debug).lower()

setup_args += [f"--config-setting=setup-args=-Ddebug={args.debug}"]
setup_args += [f"--config-setting=setup-args=-Doptimization={args.optimization}"]


# Run pip install with the specified options
subprocess.run(["pip", "install", ".", *setup_args])
36 changes: 36 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#To find the version we need to find python and run setuptools-scm, while keeping the project() call first
project('21cmFAST', ['c', 'cpp'],
version : run_command(find_program('python'), '-c', 'from setuptools_scm import get_version; print(get_version())', check: true).stdout().strip(),
default_options : ['cpp_std=c++17'],
)

# Check if CUDA should be enabled after project declaration
env_cuda_str = run_command('printenv', 'USE_CUDA', check: false).stdout().strip()
if env_cuda_str == ''
env_cuda_flag = get_option('use_cuda')
else
if env_cuda_str == 'TRUE'
env_cuda_flag = true
else
env_cuda_flag = false
endif
endif

nvcc_prog = find_program('nvcc', required: false)

# Add CUDA language if both the environment variable is set AND nvcc is available
if env_cuda_flag and nvcc_prog.found()
add_languages('cuda')
# For CUDA, we need to pass the C++ standard as a compiler argument since we're adding the language dynamically
add_project_arguments('--std=c++17', language: 'cuda')
message('CUDA enabled: nvcc found at ' + nvcc_prog.full_path())
else
if env_cuda_flag and not nvcc_prog.found()
warning('USE_CUDA=TRUE but nvcc not found, building CPU-only version')
endif
message('Building CPU-only version')
endif

py = import('python').find_installation(pure: false)

subdir('src')
3 changes: 3 additions & 0 deletions meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Define the log level option
option('log_level', type: 'string', value: 'WARNING', description: 'Set the log level (e.g., NO_LOG, ERROR, WARNING, INFO, DEBUG, SUPER_DEBUG, ULTRA_DEBUG)')
option('use_cuda',type: 'boolean', value: false, description: 'Attempt to find and use CUDA in the compilation if set to TRUE')
Loading
Loading