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

Compilation on demand #15

Merged
merged 81 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
35d0fe9
WIP
Keluaa May 26, 2023
1fa82e3
WIP space name filtering
Keluaa May 31, 2023
f1ab26b
WIP: filter memory spaces and apply on copy.cpp
Keluaa Jun 1, 2023
2bbbbd4
Small check for valid Kokkos version + support for VersionNumber
Keluaa Jun 12, 2023
f3791b6
Renamed `KokkosWrapper` module to `Wrapper`
Keluaa Jun 13, 2023
dbf3c28
Completed compilation on demand. Moved `Idx` to `Spaces`.
Keluaa Jun 19, 2023
6582914
Removed configuration options for views. Renamed `load_or_compile` to…
Keluaa Jun 19, 2023
3768df6
Renamed `COMPILED_EXEC_SPACES` and `COMPILED_EXEC_SPACES` to `ENABLED…
Keluaa Jun 19, 2023
15db3f7
Updated tests
Keluaa Jun 19, 2023
a7cbcb7
Control on which views tests are done, plus a few more tests.
Keluaa Jun 19, 2023
7122456
Moved layouts to their own file
Keluaa Jun 19, 2023
d4ef056
Updated docs
Keluaa Jun 20, 2023
6d90966
Compilation lock
Keluaa Jun 20, 2023
9e2e4f6
Version 0.5.0. Cleanup
Keluaa Jun 20, 2023
e93e9a9
Merge branch 'main' into compilation_on_demand
Keluaa Jun 20, 2023
be98300
Small fix
Keluaa Jun 20, 2023
d314615
Compile `create_mirror_*` result view type. Deep copy tests for errors.
Keluaa Jun 20, 2023
43eb444
Compile `create_mirror_*` result view type. Deep copy tests for errors.
Keluaa Jun 20, 2023
80fa190
Merge remote-tracking branch 'origin/compilation_on_demand' into comp…
Keluaa Jun 20, 2023
268cc68
Added `cxx_type_name`
Keluaa Jun 21, 2023
9e185a5
Fixes to `create_mirror[_view]`. Fixes to `cxx_type_name`.
Keluaa Jun 21, 2023
8b08211
Deep copy CI debug
Keluaa Jun 21, 2023
9a09223
Revert "Deep copy CI debug"
Keluaa Jun 22, 2023
491fed9
Circumvent https://github.com/JuliaInterop/CxxWrap.jl/issues/363
Keluaa Jun 22, 2023
ad6305b
Update README.md
Keluaa Jun 22, 2023
cb22386
Greatly reduced test time for GPUs.
Keluaa Jun 22, 2023
7e0628f
Fixed `Kokkos.deep_copy(exec, dest, src)`
Keluaa Jun 22, 2023
8164455
Replace 'compiled' with 'enabled'
Keluaa Jun 22, 2023
2cc6c4c
Always generate a deep_copy method, but throw a runtime error if `!is…
Keluaa Jun 22, 2023
9120f1b
Many small fixes
Keluaa Jun 23, 2023
2ce34d6
Testing fixes for GPU
Keluaa Jun 23, 2023
0b46586
Env var to specify the Kokkos version to test. More testing fixes for…
Keluaa Jun 23, 2023
5e9f66d
CI for Kokkos 3.7.02
Keluaa Jun 23, 2023
7b47948
Fix CI.yml
Keluaa Jun 23, 2023
bb56646
Use `KOKKOS_VERSION` for 3.7 compat. Fix `view_wrap` bug.
Keluaa Jun 23, 2023
3cae3c3
HIP tests config. Small fixes.
Keluaa Jun 23, 2023
c2bb8af
HIP fixes. Added `KOKKOS_VERSION_CMP`.
Keluaa Jun 23, 2023
58a94a8
Keep options while testing. Made `set_cmake_options` & `set_kokkos_op…
Keluaa Jun 23, 2023
808e5cd
`#ifdef` instead of `#if`
Keluaa Jun 23, 2023
5370f5e
Tests fixes for HIP
Keluaa Jun 23, 2023
9ccb8a1
Clarifications + CI debug
Keluaa Jun 26, 2023
02db81f
More CI debug
Keluaa Jun 26, 2023
62e114f
Thread-safety
Keluaa Jun 26, 2023
dfbb767
Stop overriding module (attempt to fix double registration errors)
Keluaa Jun 26, 2023
9cc924a
More thread-safety. Cleanup before tests.
Keluaa Jun 26, 2023
6efe5fd
CI debug
Keluaa Jun 26, 2023
11157da
Protect `view_type`
Keluaa Jun 26, 2023
bb09da6
Backend functions for CUDA and HIP
Keluaa Jun 27, 2023
d5ed62d
Interop with AMDGPU.jl + tests
Keluaa Jun 27, 2023
96ea71e
Renamed package extensions
Keluaa Jun 27, 2023
e3b4c05
Doc + CI fixes
Keluaa Jun 27, 2023
f1ba807
Merged the `Spaces` module into the main module
Keluaa Jun 27, 2023
8e5380e
AMDGPU/HIP fixes + better macro checks
Keluaa Jun 27, 2023
58dda2d
HIP fixes
Keluaa Jun 29, 2023
18e2163
Fixed occasional wrong definitions of methods. Cleanup.
Keluaa Jun 30, 2023
ec37366
Better MPI testing. `TEST_CMAKE_OPTIONS`
Keluaa Jun 30, 2023
da6a131
Small test fix
Keluaa Jun 30, 2023
8274199
Run CI every week
Keluaa Jun 30, 2023
b680778
Rerun CMake when it fails to reconfigure itself
Keluaa Jun 30, 2023
9599918
Handle inaccessible views when printing
Keluaa Jul 3, 2023
46c5974
Update docs
Keluaa Jul 3, 2023
c615f99
Add known issues section
Keluaa Jul 3, 2023
dda9e92
ROCArray wrapping fixes. Cleanup.
Keluaa Jul 3, 2023
da66be9
Added `BackendFunctions.memory_info`.
Keluaa Jul 5, 2023
bded4aa
Added `Wrapper.clean_cmake_files`.
Keluaa Jul 5, 2023
7511b28
RTLD_GLOBAL flag on the wrapper lib
Keluaa Jul 6, 2023
6a45cd3
Fix `unsafe_wrap` with `ROCArray`. Update compat.
Keluaa Jul 10, 2023
2fa36b6
Support `latest` for local Kokkos versions.
Keluaa Jul 10, 2023
2096871
Silent view printing in tests
Keluaa Jul 10, 2023
c035c0f
Use only Julia 1.9
Keluaa Jul 10, 2023
fd22fea
Replace :heavy_check_mark: with :white_check_mark: [skip ci]
Keluaa Sep 21, 2023
0ecdcd6
Minor fixes. Load all extensions when making documentation.
Keluaa Nov 6, 2023
8004c1c
AMDGPU v0.7 support: properly keep ownership of the GPU memory.
Keluaa Nov 6, 2023
f0d7b2e
Update CxxWrap lib compat
Keluaa Nov 6, 2023
5a0798a
Precisions about lock files
Keluaa Nov 7, 2023
b00ab9d
Update compat. Fix `unsafe_wrap` for AMDGPU.jl. Small fixes for tests.
Keluaa Dec 20, 2023
916b255
Add docs from extensions.
Keluaa Dec 20, 2023
a0de284
Merge branch 'compilation_on_demand' of https://github.com/Keluaa/Kok…
Keluaa Dec 20, 2023
0119cf3
Merge remote-tracking branch 'origin/compilation_on_demand' into comp…
Keluaa Jan 3, 2024
91956d6
Make all spaces non-mirrored types for compat with Kokkos 4.2+
Keluaa Jan 3, 2024
17ed7e8
CI for latest Julia version. Use Documenter 1.0.
Keluaa Jan 3, 2024
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
18 changes: 14 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,36 @@ on:
- main
tags: ['*']
pull_request:
schedule:
- cron: 0 8 * * 3

concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
name: Kokkos ${{ matrix.kokkos }} - Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.7'
- '1.8'
- '1.9'
- '1'
- 'nightly'
os:
- ubuntu-latest
arch:
- x64
kokkos:
- '4-latest'
include:
- version: '1.9'
os: ubuntu-latest
arch: x64
kokkos: '3-latest'
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
Expand All @@ -37,6 +46,7 @@ jobs:
- uses: julia-actions/julia-runtest@v1
env:
JULIA_NUM_THREADS: 2
TEST_KOKKOS_VERSION: ${{ matrix.kokkos }}
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v2
with:
Expand All @@ -51,7 +61,7 @@ jobs:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1.8'
version: '1.9'
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: Build and deploy
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ LocalPreferences.toml
/docs/build/
/lib/kokkos_wrapper/.idea/
/lib/kokkos_wrapper/cmake-build-*/
.vscode
.idea
32 changes: 20 additions & 12 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,45 +1,53 @@
name = "Kokkos"
uuid = "3296cea9-b0de-4b57-aba0-ce554b517c3b"
authors = ["Keluaa <[email protected]> and contributors"]
version = "0.4.1"
version = "0.5.3"

[deps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
CxxWrap = "1f15a43c-97ca-5a2a-ae31-89f07a497df4"
FileWatching = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
Pidfile = "fa939f87-e72e-5be4-a000-7fc836dbe307"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
libcxxwrap_julia_jll = "3eaa8342-bff7-56a5-9981-c04077f7cee7"

[compat]
CxxWrap = "0.13"
AMDGPU = "0.7"
CUDA = "4.1, 5"
CxxWrap = "0.14, 0.15"
MPI = "0.20"
CUDA = "4"
Pidfile = "1.3.0"
Preferences = "1"
ProgressMeter = "1"
Requires = "1"
Scratch = "1"
julia = "1.7"
libcxxwrap_julia_jll = "0.9.7"
julia = "1.9"
libcxxwrap_julia_jll = "0.9.7"

[extensions]
CUDAExt = "CUDA"
MPIExt = "MPI"
KokkosAMDGPU = "AMDGPU"
KokkosCUDA = "CUDA"
KokkosMPI = "MPI"

[extras]
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Preferences", "Logging", "MPI", "CUDA"]
test = ["Test", "Preferences", "Logging", "MPI", "CUDA", "AMDGPU"]

[weakdeps]
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
78 changes: 48 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Kokkos.jl: A Kokkos wrapper for Julia
# Kokkos.jl: A Kokkos wrapper for Julia

[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://keluaa.github.io/Kokkos.jl/stable)
[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://keluaa.github.io/Kokkos.jl/dev)
[![Documentation](https://img.shields.io/badge/docs-stable-blue.svg)](https://keluaa.github.io/Kokkos.jl/stable)
[![Dev documentation](https://img.shields.io/badge/docs-dev-blue.svg)](https://keluaa.github.io/Kokkos.jl/dev)
[![Build Status](https://github.com/Keluaa/Kokkos.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/Keluaa/Kokkos.jl/actions/workflows/CI.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/Keluaa/Kokkos.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/Keluaa/Kokkos.jl)

Expand All @@ -20,34 +20,52 @@ written in a separate C++ shared library.
If the library you want to use is configured with CMake, it is possible to configure the project
with `Kokkos.jl`.

This package uses a wrapper library which is compiled before initializing Kokkos.
This package relies on a wrapper library which is compiled when initializing Kokkos, which is
configured with the CMake and Kokkos options set in the configuration options.
Because it is not pre-compiled as an artifact, this maximizes the flexibility of usage of `Kokkos.jl`.
However, most Kokkos functions (and views) are compiled separately on demand, when their respective
Julia method is called for the first time.
The resulting shared library is then cached for the next session.

`Kokkos.jl` currently supports Kokkos v3.7.0, v3.7.1, v4.0.0 and above.
`Kokkos.jl` currently supports Kokkos v3.7, v4.0 and above.
All Kokkos backends should be supported by this package, but not all of them were tested (yet).

### Supported functionalities
* :heavy_check_mark: `Kokkos::initialize`, `Kokkos::finalize` and `Kokkos::InitializationSettings`
* :heavy_check_mark: `Kokkos::View`, `Kokkos::View<T, MyLayout, SomeMemorySpace>` and `Kokkos::view_alloc`
* :x: `Kokkos::MemoryTraits` (planned)
* :heavy_check_mark: `Kokkos::create_mirror`, `Kokkos::create_mirror_view`
* :heavy_check_mark: `Kokkos::deep_copy`
* :heavy_check_mark: `Kokkos::subview`
* :x: `Kokkos::resize`, `Kokkos::realloc` (planned)
* :heavy_check_mark: `Kokkos::fence`
* :heavy_check_mark: All execution spaces (`Kokkos::OpenMP`, `Kokkos::Cuda`...) and memory spaces (`Kokkos::HostSpace`, `Kokkos::CudaSpace`...)
* :x: All parallel patterns (`Kokkos::parallel_for`, `Kokkos::parallel_reduce`, `Kokkos::parallel_scan`), reducers, execution policies and tasking
* :x: Atomics
* :x: All containers (`Kokkos::DualView`, `Kokkos::ScatterView`...) (planned)
* :x: SIMD

### Tested backends
* :heavy_check_mark: `Kokkos::Serial`
* :heavy_check_mark: `Kokkos::OpenMP`
* :x: `Kokkos::Threads`
* :x: `Kokkos::HPX`
* :x: `Kokkos::OpenMPTarget`
* :heavy_check_mark: `Kokkos::Cuda` + interop with [CUDA.jl](https://github.com/JuliaGPU/CUDA.jl)
* :x: `Kokkos::HIP`
* :x: `Kokkos::SYCL`
* :x: `Kokkos::OpenACC`
## Supported functionalities

* :white_check_mark: `Kokkos::initialize`, `Kokkos::finalize` and `Kokkos::InitializationSettings`
* :white_check_mark: `Kokkos::View`, `Kokkos::View<T, MyLayout, SomeMemorySpace>` and `Kokkos::view_alloc`
* :x: `Kokkos::MemoryTraits` (planned)
* :white_check_mark: `Kokkos::create_mirror`, `Kokkos::create_mirror_view`
* :white_check_mark: `Kokkos::deep_copy`
* :white_check_mark: `Kokkos::subview`
* :x: `Kokkos::resize`, `Kokkos::realloc` (planned)
* :white_check_mark: `Kokkos::fence`
* :white_check_mark: All execution spaces (`Kokkos::OpenMP`, `Kokkos::Cuda`...) and memory spaces (`Kokkos::HostSpace`, `Kokkos::CudaSpace`...)
* :x: All parallel patterns (`Kokkos::parallel_for`, `Kokkos::parallel_reduce`, `Kokkos::parallel_scan`), reducers, execution policies and tasking
* :x: Atomics
* :x: All containers (`Kokkos::DualView`, `Kokkos::ScatterView`...) (planned)
* :x: SIMD
* :x: View hooks

## Tested backends

* :white_check_mark: `Kokkos::Serial`
* :white_check_mark: `Kokkos::OpenMP`
* :x: `Kokkos::Threads`
* :x: `Kokkos::HPX`
* :x: `Kokkos::OpenMPTarget`
* :white_check_mark: `Kokkos::Cuda` + interop with [CUDA.jl](https://github.com/JuliaGPU/CUDA.jl)
* :white_check_mark: `Kokkos::HIP` + interop with [AMDGPU.jl](https://github.com/JuliaGPU/AMDGPU.jl)
* :x: `Kokkos::SYCL`
* :x: `Kokkos::OpenACC`

### Known issues

* The NVCC compiler is unable to compile the wrapper library. Use Clang instead (Clang-11 is the
version used to test this backend).
* `Kokkos::Cuda ERROR: Failed to call Kokkos::Cuda::finalize()` message when exiting Julia:
`Kokkos.finalize()` is not yet called automatically upon quitting Julia, as it would require to call
the finalizers of all views before doing so.
* Memory leaks on GPU: this is a side effect of Julia's GC which cannot manage device memory. From
Julia's POV, a `Kokkos.View` is only a pointer in the host memory. Calling `GC.gc(true)` will fix the
issue.
6 changes: 5 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[deps]
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Kokkos = "3296cea9-b0de-4b57-aba0-ce554b517c3b"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
MPIPreferences = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267"

[compat]
Documenter = "0.27"
Documenter = "1"
19 changes: 15 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ push!(LOAD_PATH, joinpath(@__DIR__, "../"))

using Kokkos
using Documenter
using CUDA # For the extension documentation

# For the extensions documentation
using CUDA
using AMDGPU
using MPI

KokkosAMDGPU = Base.get_extension(Kokkos, :KokkosAMDGPU)
KokkosCUDA = Base.get_extension(Kokkos, :KokkosCUDA)
KokkosMPI = Base.get_extension(Kokkos, :KokkosMPI)

ci = get(ENV, "CI", "") == "true"

DocMeta.setdocmeta!(Kokkos, :DocTestSetup, :(using Kokkos); recursive=true)

makedocs(;
modules=[Kokkos],
modules=[Kokkos, KokkosAMDGPU, KokkosCUDA, KokkosMPI],
authors="Keluaa <[email protected]> and contributors",
repo="https://github.com/Keluaa/Kokkos.jl/blob/{commit}{path}#{line}",
sitename="Kokkos.jl",
Expand All @@ -24,15 +32,18 @@ makedocs(;
"Usage" => [
"Calling a Kokkos library" => "calling_c.md",
"Using views in an inaccessible memory space" => "inaccessible_views.md",
"Interoperability with CUDA.jl" => "interop.md",
"Interoperability with CUDA.jl and AMDGPU.jl" => "interop.md",
"MPI" => "MPI.md"
],
"Environment" => "environment.md",
"Execution & Memory Spaces" => "spaces.md",
"Views" => "views.md",
"Compilation" => "compilation.md",
"Library Management" => "library_management.md",
"Configuration options" => "config_options.md"
"Configuration options" => "config_options.md",
"Internals" => [
"Dynamic Compilation" => "dynamic_compilation.md"
]
],
)

Expand Down
4 changes: 4 additions & 0 deletions docs/src/MPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ MPI.Barrier(MPI.COMM_WORLD)
rank != 0 && Kokkos.load_wrapper_lib(; no_compilation=true, no_git=true)
```

### Dynamic Compilation and MPI

See [`DynamicCompilation.compilation_lock`](@ref)


## Passing views to MPI

Expand Down
Loading
Loading