Skip to content
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
79 changes: 78 additions & 1 deletion cpp/librtcx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
include(cmake/rapids_config.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-export)
include(rapids-find)
rapids_cpm_init()
endif()

Expand All @@ -23,7 +25,11 @@ project(
option(RTCX_STATIC_LINK_NVRTC "Use static linking for NVRTC" OFF)
option(RTCX_STATIC_LINK_NVJITLINK "Use static linking for nvJitLink" OFF)

find_package(CUDAToolkit REQUIRED)
rapids_find_package(
CUDAToolkit REQUIRED
BUILD_EXPORT_SET rtcx-exports
INSTALL_EXPORT_SET rtcx-exports
)

if(NOT TARGET zstd)
set(CPM_DOWNLOAD_zstd ON)
Expand Down Expand Up @@ -87,3 +93,74 @@ if(RTCX_STATIC_LINK_NVJITLINK)
else()
target_compile_definitions(rtcx PRIVATE RTCX_STATIC_LINK_LIBNVJITLINK=0)
endif()

# =============================================================================
# Install / Export
# =============================================================================
include(GNUInstallDirs)
include(${rapids-cmake-dir}/cmake/install_lib_dir.cmake)
rapids_cmake_install_lib_dir(lib_dir)

# Option to control install (default ON when built standalone, OFF when used as subdirectory)
option(RTCX_INSTALL "Enable installation of rtcx targets" ${PROJECT_IS_TOP_LEVEL})

set(rtcx_install_code_string
[=[
# Embed functions (add_embed, embed_includes, embed_blob, embed)
# are included automatically so consumers don't need explicit include().
include("${CMAKE_CURRENT_LIST_DIR}/embed.cmake")

# Set rtcx_LIBCXX_DIR for consumers using embed_includes with libcxx headers.
set(rtcx_LIBCXX_DIR "${PACKAGE_PREFIX_DIR}/share/rtcx/libcxx")
]=]
)

string(
CONFIGURE
[=[
# Embed functions (add_embed, embed_includes, embed_blob, embed)
# are included automatically so consumers don't need explicit include().
include("@CMAKE_CURRENT_SOURCE_DIR@/embed.cmake")

# Set rtcx_LIBCXX_DIR for consumers using embed_includes with libcxx headers.
set(rtcx_LIBCXX_DIR "@CMAKE_CURRENT_SOURCE_DIR@/libcxx")
]=]
rtcx_build_code_string
@ONLY
)

if(NOT RTCX_INSTALL)
set(rtcx_exclude_from_install EXCLUDE_FROM_ALL)
endif()

install(
TARGETS rtcx
EXPORT rtcx-exports
ARCHIVE DESTINATION ${lib_dir}
INCLUDES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
${rtcx_exclude_from_install}
)

if(RTCX_INSTALL)
install(FILES rtcx.hpp sha256.hpp embed.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rtcx)
install(FILES embed.cmake embed.in.cpp DESTINATION ${lib_dir}/cmake/rtcx)
install(DIRECTORY libcxx/ DESTINATION ${CMAKE_INSTALL_DATADIR}/rtcx/libcxx)

rapids_export(
INSTALL rtcx
EXPORT_SET rtcx-exports
GLOBAL_TARGETS rtcx
NAMESPACE rtcx::
FINAL_CODE_BLOCK rtcx_install_code_string
)
endif()

# Build-tree export (always, so CPM consumers can find_package from the build tree)
rapids_export(
BUILD rtcx
EXPORT_SET rtcx-exports
GLOBAL_TARGETS rtcx
NAMESPACE rtcx::
FINAL_CODE_BLOCK rtcx_build_code_string
)
1 change: 1 addition & 0 deletions cpp/librtcx/RAPIDS_BRANCH
1 change: 1 addition & 0 deletions cpp/librtcx/VERSION
6 changes: 3 additions & 3 deletions cpp/librtcx/cmake/rapids_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: Apache-2.0
# cmake-format: on
# =============================================================================
file(READ "${CMAKE_CURRENT_LIST_DIR}/../../../VERSION" _rapids_version)
file(READ "${CMAKE_CURRENT_LIST_DIR}/../VERSION" _rapids_version)
if(_rapids_version MATCHES [[^([0-9][0-9])\.([0-9][0-9])\.([0-9][0-9])]])
set(RAPIDS_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(RAPIDS_VERSION_MINOR "${CMAKE_MATCH_2}")
Expand All @@ -19,11 +19,11 @@ else()
)
endif()

file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/../../../RAPIDS_BRANCH" RAPIDS_BRANCH)
file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/../RAPIDS_BRANCH" RAPIDS_BRANCH)
if(NOT RAPIDS_BRANCH)
message(
FATAL_ERROR
"Could not determine branch name to use for checking out rapids-cmake. The file \"${CMAKE_CURRENT_LIST_DIR}/../../../RAPIDS_BRANCH\" is missing."
"Could not determine branch name to use for checking out rapids-cmake. The file \"${CMAKE_CURRENT_LIST_DIR}/../RAPIDS_BRANCH\" is missing."
)
endif()

Expand Down
16 changes: 8 additions & 8 deletions cpp/librtcx/embed.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
# cmake-format: on
# =============================================================================

if(NOT TARGET zstd)
message(
FATAL_ERROR "zstd library is required for JIT embedding. Please ensure it is found by CMake."
)
endif()

# This function initializes a target for JIT embedding. It must be called before any calls to
# embed_includes() or embed_blob() for the target. It creates a dedicated INTERFACE library target
# that is used to track registered files and dependencies via target properties. The TARGET argument
Expand Down Expand Up @@ -274,8 +268,14 @@ function(embed TARGET)

set(RUNNER "${TARGET}__jit_embed_run")
add_executable(${RUNNER} EXCLUDE_FROM_ALL "${EMBED_SCRIPT}")
target_include_directories(${RUNNER} PRIVATE ${ZSTD_INCLUDE_DIR})
target_link_libraries(${RUNNER} PRIVATE ${CMAKE_DL_LIBS} zstd)
target_link_libraries(${RUNNER} PRIVATE ${CMAKE_DL_LIBS})
if(NOT ARG_COMPRESSION STREQUAL "none")
if(NOT TARGET zstd)
message(FATAL_ERROR "embed(): zstd target is required when COMPRESSION is not none.")
endif()
target_include_directories(${RUNNER} PRIVATE ${ZSTD_INCLUDE_DIR})
target_link_libraries(${RUNNER} PRIVATE zstd)
endif()
set_target_properties(${RUNNER} PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED YES)
target_include_directories(${RUNNER} PRIVATE ${CMAKE_CURRENT_FUNCTION_LIST_DIR})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
partition_and_pack,
unpack_and_concat,
)
from cudf_streaming.testing import assert_eq
from rapidsmpf.integrations.ray import RapidsMPFActor, setup_ray_ucxx_cluster
from rapidsmpf.memory.buffer_resource import BufferResource
from rapidsmpf.memory.spill import unspill_partitions
from rapidsmpf.shuffler import Shuffler
from rapidsmpf.testing import assert_eq


class ShufflingActor(RapidsMPFActor):
Expand Down
66 changes: 66 additions & 0 deletions python/cudf_streaming/cudf_streaming/testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION.
# SPDX-License-Identifier: Apache-2.0

"""Testing utilities for cudf_streaming."""

from __future__ import annotations

from typing import TYPE_CHECKING

import pylibcudf

from rmm.pylibrmm.stream import DEFAULT_STREAM

if TYPE_CHECKING:
from rmm.pylibrmm.stream import Stream


def assert_eq(
left: pylibcudf.Table,
right: pylibcudf.Table,
*,
sort_rows: int | None = None,
stream: Stream | None = None,
) -> None:
"""
Assert that two tables are equivalent using pylibcudf.

Parameters
----------
left
plc.Table to compare.
right
plc.Table to compare.
sort_rows
If not None, sort both tables by this column before comparing.
An ``int`` is treated as a column index.
stream
CUDA stream to use for the comparison.

Raises
------
AssertionError
If the two tables do not compare equal.
"""
if stream is None:
stream = DEFAULT_STREAM

if sort_rows is not None:
column_order = [pylibcudf.types.Order.ASCENDING]
null_precedence = [pylibcudf.types.NullOrder.BEFORE]
left = pylibcudf.sorting.stable_sort_by_key(
left,
pylibcudf.Table([left.columns()[sort_rows]]),
column_order,
null_precedence,
stream=stream,
)
right = pylibcudf.sorting.stable_sort_by_key(
right,
pylibcudf.Table([right.columns()[sort_rows]]),
column_order,
null_precedence,
stream=stream,
)
if not pylibcudf.table_equality.tables_equal(left, right, stream=stream):
raise AssertionError(f"Table are not equal with {sort_rows=}")
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
packed_data_from_cudf_packed_columns,
unpack_and_concat,
)
from cudf_streaming.testing import assert_eq
from rapidsmpf.coll import AllGather
from rapidsmpf.memory.buffer_resource import BufferResource
from rapidsmpf.testing import assert_eq

if TYPE_CHECKING:
import rmm.mr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
from cudf_streaming.streaming import ChannelMetadata
from cudf_streaming.streaming.bloom_filter import BloomFilter
from cudf_streaming.streaming.table_chunk import TableChunk
from cudf_streaming.testing import assert_eq
from rapidsmpf.streaming.core.actor import define_actor, run_actor_network
from rapidsmpf.streaming.core.leaf_actor import (
pull_from_channel,
push_to_channel,
)
from rapidsmpf.streaming.core.message import Message
from rapidsmpf.testing import assert_eq

if TYPE_CHECKING:
from collections.abc import Awaitable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
split_and_pack,
unpack_and_concat,
)
from cudf_streaming.testing import assert_eq
from rapidsmpf.memory.buffer_resource import BufferResource
from rapidsmpf.memory.spill import spill_partitions, unspill_partitions
from rapidsmpf.testing import assert_eq
from rmm.pylibrmm.stream import DEFAULT_STREAM

if TYPE_CHECKING:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
unpack_and_concat,
)
from cudf_streaming.streaming.table_chunk import TableChunk
from cudf_streaming.testing import assert_eq
from rapidsmpf.streaming.core.actor import run_actor_network
from rapidsmpf.streaming.core.leaf_actor import (
pull_from_channel,
push_to_channel,
)
from rapidsmpf.streaming.core.message import Message
from rapidsmpf.testing import assert_eq

if TYPE_CHECKING:
from rapidsmpf.streaming.chunks.partition import PartitionMapChunk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
partition_and_pack,
unpack_and_concat,
)
from cudf_streaming.testing import assert_eq
from rapidsmpf.memory.buffer_resource import BufferResource
from rapidsmpf.memory.spill import unspill_partitions
from rapidsmpf.shuffler import (
Shuffler,
)
from rapidsmpf.testing import assert_eq

if TYPE_CHECKING:
import rmm.mr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
packed_data_from_cudf_packed_columns,
unpack_and_concat,
)
from cudf_streaming.testing import assert_eq
from rapidsmpf.coll.sparse_alltoall import SparseAlltoall
from rapidsmpf.memory.buffer_resource import BufferResource
from rapidsmpf.testing import assert_eq

if TYPE_CHECKING:
import rmm.mr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
unpack_and_concat,
)
from cudf_streaming.streaming.table_chunk import TableChunk
from cudf_streaming.testing import assert_eq
from rapidsmpf.streaming.chunks.packed_data import PackedDataChunk
from rapidsmpf.streaming.coll.allgather import AllGather, allgather
from rapidsmpf.streaming.core.actor import define_actor, run_actor_network
Expand All @@ -23,7 +24,6 @@
push_to_channel,
)
from rapidsmpf.streaming.core.message import Message
from rapidsmpf.testing import assert_eq

if TYPE_CHECKING:
from collections.abc import Awaitable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import pytest

from cudf_streaming.streaming.table_chunk import TableChunk
from cudf_streaming.testing import assert_eq
from rapidsmpf.streaming.chunks.arbitrary import ArbitraryChunk
from rapidsmpf.streaming.core.actor import define_actor, run_actor_network
from rapidsmpf.streaming.core.leaf_actor import (
pull_from_channel,
push_to_channel,
)
from rapidsmpf.streaming.core.message import Message
from rapidsmpf.testing import assert_eq


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
import pytest

from cudf_streaming.streaming.table_chunk import TableChunk
from cudf_streaming.testing import assert_eq
from rapidsmpf.streaming.core.actor import run_actor_network
from rapidsmpf.streaming.core.fanout import FanoutPolicy, fanout
from rapidsmpf.streaming.core.leaf_actor import (
pull_from_channel,
push_to_channel,
)
from rapidsmpf.streaming.core.message import Message
from rapidsmpf.testing import assert_eq

_INT64 = plc.DataType(plc.TypeId.INT64)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import pylibcudf as plc

from cudf_streaming.streaming.table_chunk import TableChunk
from cudf_streaming.testing import assert_eq
from rapidsmpf.streaming.core.actor import run_actor_network
from rapidsmpf.streaming.core.leaf_actor import (
pull_from_channel,
push_to_channel,
)
from rapidsmpf.streaming.core.message import Message
from rapidsmpf.testing import assert_eq

if TYPE_CHECKING:
from rapidsmpf.streaming.core.channel import Channel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
unpack_and_concat as streaming_unpack_and_concat,
)
from cudf_streaming.streaming.table_chunk import TableChunk
from cudf_streaming.testing import assert_eq
from rapidsmpf.shuffler import PartitionAssignment
from rapidsmpf.streaming.coll.shuffler import (
ShufflerAsync,
Expand All @@ -30,7 +31,6 @@
push_to_channel,
)
from rapidsmpf.streaming.core.message import Message
from rapidsmpf.testing import assert_eq

if TYPE_CHECKING:
from collections.abc import Awaitable
Expand Down
Loading
Loading