Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
565677f
Working ray_benchmark miniapp
Waqar-ukaea Jun 3, 2026
8305ab3
Default origin to model bbox + add flag to use volume bbox
Waqar-ukaea Jun 10, 2026
71e9597
Added fmt delimitting + spacing for volume listing
Waqar-ukaea Jun 10, 2026
817a554
Attempting to make use of XDGConfig and failing...
Waqar-ukaea Jun 10, 2026
4eb7af9
Added a flag to specify human readable stdout or csv
Waqar-ukaea Jun 10, 2026
a684290
Set omp pragma schedule to runtime
Waqar-ukaea Jun 10, 2026
c6d71fe
Added cuBQL as a submodule
Waqar-ukaea Apr 27, 2026
ca62ec5
Added required CMake wiring + a CMakePresets.json for offload flags
Waqar-ukaea Apr 28, 2026
a7f5f71
Added constructor setup for a cubql backend
Waqar-ukaea Apr 28, 2026
6b6f070
Added cubql ray tracer header + implmentation stubs
Waqar-ukaea Apr 28, 2026
bd725f5
Added a nvhpc preset
Waqar-ukaea Apr 28, 2026
e569649
Added some guards to ensure that cubql path stays on OMP and doesnt s…
Waqar-ukaea Apr 28, 2026
f16ffe0
Added a TODO comment to fix the loading of libomptarget.so
Waqar-ukaea Apr 29, 2026
ddc5cfd
Working towards creation of a surface BLAS from mesh manager data
Waqar-ukaea Apr 30, 2026
3c832b0
Copy vertices+indices to device and build bvh
Waqar-ukaea Apr 30, 2026
7983ac0
Added objects for storage of bvhs
Waqar-ukaea May 1, 2026
49a400e
Prototyping with codex. Working ray-fire. MAKE SURE TO RESET TO PREVI…
Waqar-ukaea May 1, 2026
812b0f2
Added some additional comments and cleanups
Waqar-ukaea May 6, 2026
cf4346f
Cleaned up the plucker intersection function for cuBQL
Waqar-ukaea May 7, 2026
b8a5c70
Removed constexpr EARLY_EXIT as nvlink couldn't resolve it
Waqar-ukaea May 7, 2026
7b7937c
Fixes for rebase from main
Waqar-ukaea May 14, 2026
615ec15
Updated CMakeLists to make proper use of PRIVATE after rebasing recen…
Waqar-ukaea May 14, 2026
9fa439b
Fix runtime check for available rt libraries
Waqar-ukaea May 15, 2026
6c244a2
Reducing the number of queries in cross check for now since cubql pat…
Waqar-ukaea May 15, 2026
ac20598
Reworked normal/sense handling so normals are calculated and sense ha…
Waqar-ukaea May 15, 2026
d130c41
Added an omp_target_device_probe and put it into the same header as t…
Waqar-ukaea May 15, 2026
d0d7366
Introduced a cubql_backend Context object to store host_id and device_id
Waqar-ukaea May 15, 2026
5a8faf3
Started adding some more abstraction towards two-level traversal scheme
Waqar-ukaea May 15, 2026
2b218aa
Forgot to commit the new file which holds the cuBQL structs
Waqar-ukaea May 15, 2026
afe3024
Two level traversal scheme in place and working
Waqar-ukaea May 18, 2026
089ba15
Fixed sense handling for surface second visit
Waqar-ukaea May 18, 2026
b18eeb9
Refactor to build only a single CuBQLSurfaceMesh and CuBQLSurfaceBLAS…
Waqar-ukaea May 20, 2026
bd12a16
Added point_in_volume query
Waqar-ukaea May 22, 2026
e7e260d
Extended ray tracer cross checks to also do point_in_volume for pincell
Waqar-ukaea May 22, 2026
d16f481
Added new intersection.h and intersection.cpp to contain helpers/stru…
Waqar-ukaea May 22, 2026
2794efd
Added cuBQL support to particle sim
Waqar-ukaea May 22, 2026
84e2200
Abstracted shared intersection logic between ray_fire and point_in_vo…
Waqar-ukaea Jun 1, 2026
7959a44
Added setup for dynamic-ray volume querying
Waqar-ukaea Jun 2, 2026
84ab66c
Abstracted the ray traversal into its own inline function which
Waqar-ukaea Jun 2, 2026
9cb2517
Added a basic batch ray_fire method
Waqar-ukaea Jun 3, 2026
4876116
Working ray benchmark with cubql
Waqar-ukaea Jun 4, 2026
cb7fee9
Some minor cleanup
Waqar-ukaea Jun 15, 2026
7f860db
Implemented concrete mixed precision traversal
Waqar-ukaea Jun 16, 2026
59d99f4
Re-factored ray_benchmark to work with new changes after rebase from …
Waqar-ukaea Jun 18, 2026
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@
[submodule "vendor/GPRT"]
path = vendor/GPRT
url = https://github.com/gprt-org/GPRT.git
[submodule "vendor/cuBQL"]
path = vendor/cuBQL
url = https://github.com/NVIDIA/cuBQL
57 changes: 54 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ option(XDG_ENABLE_LIBMESH "Enable support for the libMesh mesh library" OFF
option(XDG_LINK_MPI "Link with MPI (for dependency compatibility)" OFF)
option(XDG_ENABLE_EMBREE "Enable support for the Embree ray tracing library" ON)
option(XDG_ENABLE_GPRT "Enable support for the GPRT ray tracing library" OFF)
option(XDG_ENABLE_CUBQL "Enable support for the cuBQL ray tracing library" OFF)
option(XDG_BUILD_TESTS "Enable C++ unit testing" ON)
option(XDG_BUILD_TOOLS "Enable tools and miniapps" ON)

Expand All @@ -20,6 +21,10 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose build type" FORCE)
endif()

if(DEFINED XDG_CMAKE_PRESET)
message(STATUS "XDG CMake preset: ${XDG_CMAKE_PRESET}")
endif()

# Compiler options (things in this section may not be platform-portable)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

Expand Down Expand Up @@ -111,6 +116,12 @@ if(XDG_ENABLE_GPRT)
)
endif()

if(XDG_ENABLE_CUBQL)
list(APPEND VENDOR_PATHS
vendor/cuBQL
)
endif()

if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
option(XDG_GIT_SUBMODULE "Check submodules during build" ON)
if(XDG_GIT_SUBMODULE)
Expand Down Expand Up @@ -175,11 +186,12 @@ if (NOT XDG_ENABLE_MOAB AND NOT XDG_ENABLE_LIBMESH)
endif()

# Ensure at least one ray tracing backend is enabled
if (NOT XDG_ENABLE_EMBREE AND NOT XDG_ENABLE_GPRT)
if (NOT XDG_ENABLE_EMBREE AND NOT XDG_ENABLE_GPRT AND NOT XDG_ENABLE_CUBQL)
message(FATAL_ERROR
"No ray tracing backend enabled. Enable at least one of:\n"
" -DXDG_ENABLE_EMBREE=ON\n"
" -DXDG_ENABLE_GPRT=ON")
" -DXDG_ENABLE_GPRT=ON\n"
" -DXDG_ENABLE_CUBQL=ON")
endif()

# GPRT
Expand All @@ -188,6 +200,11 @@ if (XDG_ENABLE_GPRT)
add_subdirectory(vendor/GPRT)
endif()

if (XDG_ENABLE_CUBQL)
set(CUBQL_OMP ON CACHE BOOL "Build cuBQL with OpenMP target offload" FORCE)
add_subdirectory(vendor/cuBQL)
endif()

list(APPEND xdg_sources
src/geometry/measure.cpp
src/geometry/plucker.cpp
Expand Down Expand Up @@ -221,6 +238,23 @@ dbl_deviceCode

endif()

if (XDG_ENABLE_CUBQL)
list(APPEND xdg_sources
src/cuBQL/triangles.cpp
src/cuBQL/intersection.cpp
src/cuBQL/ray_tracer.cpp
)

# We need a precompile definition to switch to using the cuBQL math types in the shared
# plucker intersection code. The compile definition is used in dp__math.h
set_source_files_properties(
src/cuBQL/ray_tracer.cpp
src/cuBQL/intersection.cpp
PROPERTIES COMPILE_DEFINITIONS XDG_DP_MATH_CUBQL
)

endif()

if (XDG_ENABLE_LIBMESH)
list(APPEND xdg_sources
src/libmesh/mesh_manager.cpp
Expand Down Expand Up @@ -281,7 +315,12 @@ if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
endif()

# attempt to find OpenMP and include it if found
find_package(OpenMP)
if (XDG_ENABLE_CUBQL)
find_package(OpenMP REQUIRED)
else()
find_package(OpenMP)
endif()

if (OpenMP_CXX_FOUND)
target_link_libraries(xdg PRIVATE OpenMP::OpenMP_CXX)
target_compile_definitions(xdg PRIVATE XDG_HAVE_OPENMP)
Expand Down Expand Up @@ -319,6 +358,18 @@ if (XDG_ENABLE_GPRT)
target_link_options(xdg PRIVATE -Wl,--unresolved-symbols=ignore-in-shared-libs)
endif()

if (XDG_ENABLE_CUBQL)
target_compile_definitions(xdg PUBLIC XDG_ENABLE_CUBQL)
target_link_libraries(xdg PRIVATE $<BUILD_INTERFACE:cuBQL>)
# TODO: Stop relying on LD_LIBRARY_PATH for LLVM OpenMP offload runtimes.
# As a temporary measure whilst figuring out our way around cuBQL this is
# okay but in the long run we should aim for a more robust solutions here.
# Clang injects libomptarget when offload flags are supplied by presets, but
# CMake does not currently add that compiler runtime directory to RPATH.
# Add targeted BUILD_RPATH handling for libomptarget/libomp, and decide
# whether install RPATH should remain environment-module based or be opt-in.
endif()

target_link_libraries(xdg PRIVATE fmt::fmt)

# ==========================
Expand Down
68 changes: 68 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"version": 3,
"configurePresets": [
{
"name": "base",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_CXX_FLAGS": "$env{PRESET_CXX_FLAGS} $env{LLVM_CXX_FLAGS} $env{COMMON_CXX_FLAGS}",
"XDG_CMAKE_PRESET": "${presetName}"
},
"environment": {
"COMMON_CXX_FLAGS": ""
}
},
{
"name": "llvm",
"inherits": ["base"],
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++"
},
"environment": {
"LLVM_CXX_FLAGS": "-fopenmp -fopenmp-cuda-mode"
}
},
{
"name": "cubql_llvm_ada",
"inherits": ["llvm"],
"displayName": "cuBQL LLVM OpenMP offload RTX 2000 Ada",
"cacheVariables": {
"XDG_ENABLE_CUBQL": "ON"
},
"environment": {
"PRESET_CXX_FLAGS": "-fopenmp-targets=nvptx64 -Xopenmp-target -march=sm_80"
}
},
{
"name": "nvhpc",
"inherits": ["base"],
"cacheVariables": {
"CMAKE_C_COMPILER": "nvc",
"CMAKE_CXX_COMPILER": "nvc++"
}
},
{
"name": "cubql_nvhpc_ada",
"inherits": ["nvhpc"],
"displayName": "cuBQL NVHPC OpenMP offload RTX 2000 Ada",
"cacheVariables": {
"XDG_ENABLE_CUBQL": "ON"
},
"environment": {
"PRESET_CXX_FLAGS": "-mp=gpu -Minfo=mp -gpu=cc89"
}
}
],
"buildPresets": [
{
"name": "cubql_llvm_ada",
"configurePreset": "cubql_llvm_ada"
},
{
"name": "cubql_nvhpc_ada",
"configurePreset": "cubql_nvhpc_ada"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#pragma once

#ifdef XDG_ENABLE_GPRT
#include "xdg/error.h"

// --------------------------------------------------------------------------------------
// Vulkan probe functions to check for ray tracing capable devices at runtime
// --------------------------------------------------------------------------------------
#ifdef XDG_ENABLE_GPRT

#include <cstring>
#include <string>
#include <vector>
Expand Down Expand Up @@ -90,5 +94,47 @@ inline bool system_has_vk_device()
missing);
return false;
}
#endif

// --------------------------------------------------------------------------------------
// OpenMP target probe functions to check for devices capable of running cuBQL at runtime
// --------------------------------------------------------------------------------------

#ifdef XDG_ENABLE_CUBQL

#include <omp.h>

inline bool system_has_omp_target_device()
{
const int device_count = omp_get_num_devices();
if (device_count <= 0) {
warning("No OpenMP target devices found; cuBQL ray tracer unavailable.");
return false;
}

const int host_id = omp_get_initial_device();
for (int device_id = 0; device_id < device_count; ++device_id) {
int value = 1;
void* d_value = omp_target_alloc(sizeof(int), device_id);
if (!d_value) continue;

const int copy_result = omp_target_memcpy(d_value,
&value,
sizeof(int),
0,
0,
device_id,
host_id);
omp_target_free(d_value, device_id);

if (copy_result == 0) {
write_message("Found OpenMP target device {}.", device_id);
return true;
}
}

warning("OpenMP target devices were found, but none accepted target allocation; cuBQL ray tracer unavailable.");
return false;
}

#endif
8 changes: 5 additions & 3 deletions include/xdg/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ enum class MeshLibrary {
// Ray Tracing library identifier
enum class RTLibrary {
EMBREE,
GPRT
GPRT,
CUBQL
};

static const std::map<MeshLibrary, std::string> MESH_LIB_TO_STR =
Expand All @@ -67,7 +68,8 @@ static const std::map<MeshLibrary, std::string> MESH_LIB_TO_STR =
static const std::map<RTLibrary, std::string> RT_LIB_TO_STR =
{
{RTLibrary::EMBREE, "EMBREE"},
{RTLibrary::GPRT, "GPRT"}
{RTLibrary::GPRT, "GPRT"},
{RTLibrary::CUBQL, "CUBQL"}
};

// Mesh identifer type
Expand Down Expand Up @@ -148,4 +150,4 @@ struct formatter<xdg::MeshLibrary> : fmt::formatter<std::string> {

}

#endif // include guard
#endif // include guard
30 changes: 30 additions & 0 deletions include/xdg/cuBQL/cuBQL_backend.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef _XDG_CUBQL_BACKEND_H
#define _XDG_CUBQL_BACKEND_H

#include <cstddef>
#include <type_traits>
#include <utility>
#include <vector>

#include <omp.h>

// Guards to prevent CUDA headers from being included in host code, which causes
// failed compilation with LLVM-clang.
#if defined(__CUDA_ARCH__) && !defined(__CUDACC__)
#undef __CUDA_ARCH__
#endif

#include "xdg/error.h"

namespace xdg::cubql {

struct Context {
int gpuID {0};
int hostID {omp_get_initial_device()};
};



} // namespace xdg::cubql

#endif // include guard
Loading
Loading