Skip to content

Commit

Permalink
vtkConduitSource: Support mesh data from external memory spaces
Browse files Browse the repository at this point in the history
Includes the following MRs squashed for easy of rebasing:

commit 695023a3b300ae42fc4ce1fff6042cc7d771969c
Author: Dan Lipsa <[email protected]>
Date:   Thu Oct 31 13:56:35 2024 -0400

    No need for memorySpace parameter

commit cbd3489deab1cd280ea62bef6b36054487db88cf
Author: Dan Lipsa <[email protected]>
Date:   Thu Oct 31 13:12:53 2024 -0400

    Use IsDevicePointer instead of IsDirectAccessPossible

commit 6e749affe252d5dc05ec5aa00d8f1717a974835f
Author: Dan Lipsa <[email protected]>
Date:   Thu Oct 24 20:29:18 2024 -0400

    Add error logging

commit 144af51fc79f82ec832b11e740065c2464452af8
Author: Dan Lipsa <[email protected]>
Date:   Thu Oct 24 16:18:51 2024 -0400

    Use cudaPointerGetAttributes to ask if device or host pointer

commit 9a46db52454719f6ddb4f0595d5ca03e4efdd259
Author: Dan Lipsa <[email protected]>
Date:   Fri Sep 27 09:47:55 2024 -0400

    No conversion for vtkmDataArray

commit b52093c55353e60ba90b3dbe671362fb850b1647
Author: Dan Lipsa <[email protected]>
Date:   Thu Sep 26 10:37:21 2024 -0400

    vtkErrorMacro is not available in a static method

commit c318c5bf89de83ced7294b6f79dd02aecadffce7
Author: Dan Lipsa <[email protected]>
Date:   Thu Sep 5 11:26:15 2024 -0400

    Add vtkConduitArrayUtilities to classes of IOCatalystConduit

commit f84ef340f5a40127f6006e38102ae0dd4b47cd44
Author: Dan Lipsa <[email protected]>
Date:   Thu Sep 5 09:24:36 2024 -0400

    Remove not needed link with catalyst

commit 908563b1ebda7cc47e22d6a4bf92cf5d14a309aa
Author: Jaswant Panchumarti <[email protected]>
Date:   Tue Dec 19 17:45:09 2023 -0500

    vtkConduitSource: Support mesh data from external memory spaces
  • Loading branch information
jspanchu authored and danlipsa committed Dec 27, 2024
1 parent fb2bcce commit 469de6c
Show file tree
Hide file tree
Showing 12 changed files with 1,745 additions and 70 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Add external memory support for vtkConduitSource

`vtkConduitSource` can now keep point coordinates, cell connectivity
and field values from conduit on an accelerator device such as CUDA or
HIP. This is done by testing pointers in conduit to see if they are
stored on a device or on the host memory. Note that you must
configure and build VTK with VTK-m configured for the appropriate
device, otherwise data will be transfered to the host memory.
40 changes: 38 additions & 2 deletions IO/CatalystConduit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,47 @@
set(classes
vtkConduitArrayUtilities
vtkConduitSource
vtkConduitToDataObject
vtkDataObjectToConduit)

if (TARGET vtkm::cuda)
list(APPEND classes vtkConduitArrayUtilities)
endif()

vtk_module_add_module(VTK::IOCatalystConduit
CLASSES ${classes})
CLASSES ${classes}
NOWRAP_CLASSES ${nowrap_classes})

if (VTK_KOKKOS_BACKEND STREQUAL "HIP")
set(VTK_KOKKOS_BACKEND_HIP 1)
endif()

configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/vtkDeviceMemoryType.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/vtkDeviceMemoryType.h"
@ONLY)


if (TARGET vtkm::cuda)
# Temporarily suppress "has address taken but no possible call to it" warnings,
# until we figure out its implications.
# We are disabling all warnings as nvlink has no known way to suppress
# individual warning types.
string(APPEND CMAKE_CUDA_FLAGS " -Xnvlink -w")

list(TRANSFORM nowrap_classes APPEND ".cxx" OUTPUT_VARIABLE nowrap_sources)
set(cuda_impl ${nowrap_sources})
set_source_files_properties(${cuda_impl} PROPERTIES LANGUAGE CUDA)

vtk_module_set_properties(VTK::IOCatalystConduit
CUDA_SEPARABLE_COMPILATION ON)

vtk_module_compile_options(VTK::IOCatalystConduit
PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:-Xcudafe --diag_suppress=extra_semicolon>)

find_package(CUDAToolkit REQUIRED)
vtk_module_link(VTK::IOCatalystConduit PRIVATE CUDA::cudart)
endif ()


vtk_add_test_mangling(VTK::IOCatalystConduit)
add_subdirectory(Catalyst)
38 changes: 36 additions & 2 deletions IO/CatalystConduit/Testing/Cxx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,49 @@
vtk_add_test_cxx(vtkConduitCxxTests tests
NO_VALID NO_OUTPUT
TestDataObjectToConduit.cxx
TestConduitSource.cxx)
TestConduitSource.cxx
TestConduitSourceExternalMemorySpaces.cxx)

vtk_test_cxx_executable(vtkConduitCxxTests tests)

if (TARGET VTK::ParallelMPI)
vtk_add_test_mpi(vtkConduitCxxTests-MPI mpitests
TESTING_DATA NO_VALID NO_OUTPUT
TestDataObjectToConduit.cxx
TestConduitSource.cxx)
TestConduitSource.cxx
TestConduitSourceExternalMemorySpaces.cxx)

vtk_test_cxx_executable(vtkConduitCxxTests-MPI mpitests)
endif()

if (TARGET vtkm::cuda)
foreach(src IN LISTS tests)
string(REPLACE "," ";" src ${src})
list(GET src 0 src)

set_source_files_properties(${src} PROPERTIES LANGUAGE CUDA)
endforeach()

#the tests aren't scoped as a child directory of vtkAcceleratorsVTKmDataModel
#so we need to redo this logic
vtkm_get_cuda_flags(CMAKE_CUDA_FLAGS)

# Temporarily suppress "has address taken but no possible call to it" warnings,
# until we figure out its implications.
# We are disabling all warnings as nvlink has no known way to suppress
# individual warning types.
string(APPEND CMAKE_CUDA_FLAGS " -Xnvlink -w")
endif()

if (TARGET vtkm::cuda)
# When cuda is enabled VTK::AcceleratorsVTKmDataModel is built statically but with fpic
# enabled so the tests are also built with fpic enabled
set_target_properties(vtkConduitCxxTests PROPERTIES
CUDA_ARCHITECTURES OFF
POSITION_INDEPENDENT_CODE ON
)
set_target_properties(vtkConduitCxxTests-MPI PROPERTIES
CUDA_ARCHITECTURES OFF
POSITION_INDEPENDENT_CODE ON
)
endif()
2 changes: 0 additions & 2 deletions IO/CatalystConduit/Testing/Cxx/TestConduitSource.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,6 @@ inline unsigned int GetLinearIndex3D(unsigned int i, unsigned int j, unsigned in
//----------------------------------------------------------------------------
void CreateMixedUnstructuredMesh2D(unsigned int npts_x, unsigned int npts_y, conduit_cpp::Node& res)
{
conduit_cpp::Node mesh;
CreateCoords(npts_x, npts_y, 1, res);

const unsigned int nele_x = npts_x - 1;
Expand Down Expand Up @@ -965,7 +964,6 @@ void CreateWedgeAndPyramidUnstructuredMesh(
void CreateMixedUnstructuredMesh(
unsigned int nptsX, unsigned int nptsY, unsigned int nptsZ, conduit_cpp::Node& res)
{
conduit_cpp::Node mesh;
CreateCoords(nptsX, nptsY, nptsZ, res);

res["state/time"] = 3.1415;
Expand Down
Loading

0 comments on commit 469de6c

Please sign in to comment.