Skip to content
Open
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
2 changes: 1 addition & 1 deletion .githash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
321fb12e0f01f8fb792cb0a49ff877bb6502ad7d
86b2fc85f92faef95641763738c2b71f0d4d056a
3 changes: 2 additions & 1 deletion lib/cunumeric_jl_wrapper/include/accessors.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2025 Northwestern University,
/* Copyright 2026 Northwestern University,
* Carnegie Mellon University University
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,6 +15,7 @@
*
* Author(s): David Krasowska <krasow@u.northwestern.edu>
* Ethan Meitz <emeitz@andrew.cmu.edu>
* Nader Rahhal <naderrahhal2026@u.northwestern.edu>
*/

#pragma once
Expand Down
20 changes: 20 additions & 0 deletions lib/cunumeric_jl_wrapper/include/ndarray_c_api.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/* Copyright 2026 Northwestern University,
* Carnegie Mellon University University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author(s): David Krasowska <krasow@u.northwestern.edu>
* Ethan Meitz <emeitz@andrew.cmu.edu>
* Nader Rahhal <naderrahhal2026@u.northwestern.edu>
*/

#ifndef NDARRAY_C_API_H
#define NDARRAY_C_API_H

Expand Down
3 changes: 2 additions & 1 deletion lib/cunumeric_jl_wrapper/include/types.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2025 Northwestern University,
/* Copyright 2026 Northwestern University,
* Carnegie Mellon University University
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,6 +15,7 @@
*
* Author(s): David Krasowska <krasow@u.northwestern.edu>
* Ethan Meitz <emeitz@andrew.cmu.edu>
* Nader Rahhal <naderrahhal2026@u.northwestern.edu>
*/

#pragma once
Expand Down
3 changes: 2 additions & 1 deletion lib/cunumeric_jl_wrapper/include/ufi.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2025 Northwestern University,
/* Copyright 2026 Northwestern University,
* Carnegie Mellon University University
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,6 +15,7 @@
*
* Author(s): David Krasowska <krasow@u.northwestern.edu>
* Ethan Meitz <emeitz@andrew.cmu.edu>
* Nader Rahhal <naderrahhal2026@u.northwestern.edu>
*/

#pragma once
Expand Down
3 changes: 2 additions & 1 deletion lib/cunumeric_jl_wrapper/src/cuda.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2025 Northwestern University,
/* Copyright 2026 Northwestern University,
* Carnegie Mellon University University
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,6 +15,7 @@
*
* Author(s): David Krasowska <krasow@u.northwestern.edu>
* Ethan Meitz <emeitz@andrew.cmu.edu>
* Nader Rahhal <naderrahhal2026@u.northwestern.edu>
*/

#include "cuda.h"
Expand Down
20 changes: 20 additions & 0 deletions lib/cunumeric_jl_wrapper/src/memory.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/* Copyright 2026 Northwestern University,
* Carnegie Mellon University University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author(s): David Krasowska <krasow@u.northwestern.edu>
* Ethan Meitz <emeitz@andrew.cmu.edu>
* Nader Rahhal <naderrahhal2026@u.northwestern.edu>
*/

#include <cupynumeric.h>
#include <cupynumeric/runtime.h>
#include <deps/realm/machine.h>
Expand Down
20 changes: 20 additions & 0 deletions lib/cunumeric_jl_wrapper/src/ndarray.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/* Copyright 2026 Northwestern University,
* Carnegie Mellon University University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author(s): David Krasowska <krasow@u.northwestern.edu>
* Ethan Meitz <emeitz@andrew.cmu.edu>
* Nader Rahhal <naderrahhal2026@u.northwestern.edu>
*/

#include <cupynumeric.h>
#include <cupynumeric/ndarray.h>
#include <cupynumeric/operators.h>
Expand Down
2 changes: 1 addition & 1 deletion lib/cunumeric_jl_wrapper/src/types.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2025 Northwestern University,
/* Copyright 2026 Northwestern University,
* Carnegie Mellon University University
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
10 changes: 8 additions & 2 deletions lib/cunumeric_jl_wrapper/src/wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2025 Northwestern University,
/* Copyright 2026 Northwestern University,
* Carnegie Mellon University University
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,6 +15,7 @@
*
* Author(s): David Krasowska <krasow@u.northwestern.edu>
* Ethan Meitz <emeitz@andrew.cmu.edu>
* Nader Rahhal <naderrahhal2026@u.northwestern.edu>
*/

#include <initializer_list>
Expand Down Expand Up @@ -92,6 +93,10 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& mod) {
using jlcxx::Parametric;
using jlcxx::TypeVar;

// Map C++ complex types to Julia complex types
mod.map_type<std::complex<double>>("ComplexF64");
mod.map_type<std::complex<float>>("ComplexF32");

// These are the types/dims used to generate templated functions
// i.e. only these types/dims can be used from Julia side
using fp_types = ParameterList<double, float>;
Expand All @@ -100,7 +105,8 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& mod) {

using all_types =
ParameterList<double, float, int8_t, int16_t, int32_t, int64_t, uint8_t,
uint16_t, uint32_t, uint64_t, bool>;
uint16_t, uint32_t, uint64_t, bool, std::complex<double>,
std::complex<float>>;
using allowed_dims = ParameterList<
std::integral_constant<int_t, 1>, std::integral_constant<int_t, 2>,
std::integral_constant<int_t, 3>, std::integral_constant<int_t, 4>>;
Expand Down
35 changes: 27 additions & 8 deletions src/cuNumeric.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#= Copyright 2025 Northwestern University,
#= Copyright 2026 Northwestern University,
* Carnegie Mellon University University
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,6 +15,7 @@
*
* Author(s): David Krasowska <krasow@u.northwestern.edu>
* Ethan Meitz <emeitz@andrew.cmu.edu>
* Nader Rahhal <naderrahhal2026@u.northwestern.edu>
=#

module cuNumeric
Expand All @@ -34,8 +35,20 @@ const DEFAULT_INT = Int32

const SUPPORTED_INT_TYPES = Union{Int32,Int64}
const SUPPORTED_FLOAT_TYPES = Union{Float32,Float64}
const SUPPORTED_NUMERIC_TYPES = Union{SUPPORTED_INT_TYPES,SUPPORTED_FLOAT_TYPES}
const SUPPORTED_TYPES = Union{SUPPORTED_INT_TYPES,SUPPORTED_FLOAT_TYPES,Bool} #* TODO Test UInt, Complex
const SUPPORTED_COMPLEX_TYPES = Union{ComplexF32,ComplexF64}
const SUPPORTED_NUMERIC_TYPES = Union{
SUPPORTED_INT_TYPES,SUPPORTED_FLOAT_TYPES,SUPPORTED_COMPLEX_TYPES
}
# const SUPPORTED_TYPES = Union{SUPPORTED_INT_TYPES,SUPPORTED_FLOAT_TYPES,Bool} #* TODO Test UInt, Complex

const SUPPORTED_TYPES = Union{
Bool,
Int8,Int16,Int32,Int64,
UInt8,UInt16,UInt32,UInt64,
Float16,Float32,Float64,
ComplexF32,ComplexF64,
String,
}

# const MAX_DIM = 6 # idk what we compiled?

Expand Down Expand Up @@ -123,6 +136,7 @@ include("ndarray/broadcast.jl")
include("ndarray/ndarray.jl")
include("ndarray/unary.jl")
include("ndarray/binary.jl")
include("ndarray/experimental.jl")

# scoping macro
include("scoping.jl")
Expand Down Expand Up @@ -169,16 +183,14 @@ end
const RUNTIME_INACTIVE = -1
const RUNTIME_ACTIVE = 0
const _runtime_ref = Ref{Int}(RUNTIME_INACTIVE)
const _start_lock = ReentrantLock()
const _start_lock = ReentrantLock()

runtime_started() = _runtime_ref[] == RUNTIME_ACTIVE

function _start_runtime()

Libdl.dlopen(CUPYNUMERIC_LIB_PATH, Libdl.RTLD_GLOBAL | Libdl.RTLD_NOW)
Libdl.dlopen(CUPYNUMERIC_WRAPPER_LIB_PATH, Libdl.RTLD_GLOBAL | Libdl.RTLD_NOW)


AA = ArgcArgv(String[])
# AA = ArgcArgv([Base.julia_cmd()[1]])
cuNumeric.initialize_cunumeric(AA.argc, getargv(AA))
Expand All @@ -188,7 +200,6 @@ function _start_runtime()

Base.atexit(my_on_exit)


return RUNTIME_ACTIVE
end

Expand Down Expand Up @@ -223,9 +234,17 @@ function __init__()

global cuNumeric_config_str = version_config_setup()

_is_precompiling() && return
_is_precompiling() && return nothing

ensure_runtime!()

# Register existing C++ library with Legate runtime for UFI support
lib = get_lib()
Legate._ufi_interface_register(lib)

async_handle = Legate._get_async_handle()
request_ptr = Legate._get_request_ptr()
Legate._initialize_async_system(async_handle, request_ptr)
end

end #module cuNumeric
73 changes: 73 additions & 0 deletions src/ndarray/experimental.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#= Copyright 2026 Northwestern University,
* Carnegie Mellon University University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author(s): David Krasowska <krasow@u.northwestern.edu>
* Ethan Meitz <emeitz@andrew.cmu.edu>
* Nader Rahhal <naderrahhal2026@u.northwestern.edu>
=#

function Experimental(setting::Bool)
task_local_storage(:Experimental, setting)
end

function assert_experimental()
if get(task_local_storage(), :Experimental, false) !== true
throw(
ArgumentError(
"Experimental features are disabled." *
" Use `cuNumeric.Experimental(true)` to enable them.",
),
)
end
end

function _test_task(args::Vector{Legate.TaskArgument})
a, b, scalar = args
@inbounds @simd for i in eachindex(a)
b[i] = a[i] * scalar
end
end

function test_task_interface(in_arr::NDArray{T}, scalar::Float32) where {T}
assert_experimental()

out_arr = cuNumeric.zeros(T, Base.size(in_arr))

rt = Legate.get_runtime()
lib = get_lib()

my_task = Legate.wrap_task(_test_task)

task = Legate.create_julia_task(rt, lib, my_task)

input_vars = Vector{Legate.Variable}()
output_vars = Vector{Legate.Variable}()

push!(input_vars, Legate.add_input(task, get_store(in_arr)))
push!(output_vars, Legate.add_output(task, get_store(out_arr)))

Legate.default_alignment(task, input_vars, output_vars)
Legate.add_scalar(task, Legate.Scalar(scalar))

Legate.submit_task(rt, task)

# In single-threaded mode, we must wait to avoid deadlock
# (Main thread blocks on data access, preventing async_worker from running)
if Threads.nthreads() == 1
Legate.wait_ufi()
end

return out_arr
end
3 changes: 2 additions & 1 deletion src/ndarray/ndarray.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#= Copyright 2025 Northwestern University,
#= Copyright 2026 Northwestern University,
* Carnegie Mellon University University
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,6 +15,7 @@
*
* Author(s): David Krasowska <krasow@u.northwestern.edu>
* Ethan Meitz <emeitz@andrew.cmu.edu>
* Nader Rahhal <naderrahhal2026@u.northwestern.edu>
=#

export unwrap
Expand Down
2 changes: 1 addition & 1 deletion test/tests/linalg.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#= Copyright 2025 Northwestern University,
#= Copyright 2026 Northwestern University,
* Carnegie Mellon University University
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Loading