-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements for accessing ascent-catalyst, plus examples (#1162)
* Adjust SetupCatalyst.cmake to match official docs * Initial attempt at adding catalyst build * Make build_ascent_cuda_perlmutter.sh executable * Fixes for building catalyst * Set catalyst install directory * Move libcatalyst-ascent.so to expected directory * Add initial catalyst example * Copy ascent-catalyst-mpi example if MPI is found * Rename ascent-catalyst to ascent-catalyst-mpi * Add non-mpi catalyst example, other fixes * Remove leftover instance of _mpi
- Loading branch information
Showing
10 changed files
with
289 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright (c) Lawrence Livermore National Security, LLC and other Ascent | ||
# Project developers. See top-level LICENSE AND COPYRIGHT files for dates and | ||
# other details. No copyright assignment is required to contribute to Ascent. | ||
############################################################################### | ||
|
||
############################################################################### | ||
# | ||
# Example that shows how to use an installed instance of Ascent in another | ||
# CMake-based build system. | ||
# | ||
# To build: | ||
# cmake -DAscent_DIR={ascent install path} -B build -S . | ||
# cp ascent_actions.yaml build | ||
# cd build | ||
# make | ||
# ./ascent_catalyst_mpi_example | ||
# | ||
# In order to run directly in a sub directory below ascent-catalyst_mpi in an ascent install, | ||
# set Ascent_DIR to ../../.. | ||
# | ||
# cmake -DAscent_DIR=../../.. -B build -S . | ||
# cp ascent_actions.yaml build | ||
# cd build | ||
# make | ||
# ./ascent_catalyst_mpi_example | ||
# | ||
############################################################################### | ||
|
||
cmake_minimum_required(VERSION 3.9) | ||
|
||
project(ascent_catalyst_mpi) | ||
|
||
# | ||
# Use CMake's find_package to import ascent's targets | ||
# | ||
# PATHS is just a hint if someone runs this example from the Ascent install | ||
# tree without setting up an environment hint to find Ascent | ||
find_package(Ascent REQUIRED | ||
NO_DEFAULT_PATH | ||
PATHS ${CMAKE_SOURCE_DIR}/../../../) | ||
|
||
find_package(MPI REQUIRED COMPONENTS CXX) | ||
|
||
find_package(catalyst 2.0 REQUIRED) | ||
|
||
# create our example | ||
add_executable(ascent_catalyst_mpi_example ascent_catalyst_mpi_example.cpp) | ||
|
||
# link to ascent and catalyst | ||
target_link_libraries(ascent_catalyst_mpi_example ascent::ascent_mpi catalyst::catalyst) | ||
|
||
# if cuda is in the mix: | ||
# we need to make sure CUDA_RESOLVE_DEVICE_SYMBOLS is on for our target | ||
# (it propgates some way magically in 3.14, but not in 3.21) | ||
if(CMAKE_CUDA_COMPILER) | ||
set_property(TARGET ascent_catalyst_mpi_example PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
- | ||
action: "add_scenes" | ||
scenes: | ||
s1: | ||
plots: | ||
p1: | ||
type: "pseudocolor" | ||
field: "braid" | ||
image_name: "out_ascent_catalyst_mpi_example" |
63 changes: 63 additions & 0 deletions
63
src/examples/ascent-catalyst-mpi/ascent_catalyst_mpi_example.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// | ||
// Copyright (c) Lawrence Livermore National Security, LLC and other Ascent | ||
// Project developers. See top-level LICENSE AND COPYRIGHT files for dates and | ||
// other details. No copyright assignment is required to contribute to Ascent. | ||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// | ||
|
||
//----------------------------------------------------------------------------- | ||
/// | ||
/// file: ascent_catalyst_mpi_example.cpp | ||
/// | ||
//----------------------------------------------------------------------------- | ||
|
||
#include <catalyst.h> | ||
#include <conduit_blueprint.hpp> | ||
#include <conduit_cpp_to_c.hpp> | ||
|
||
#include <mpi.h> | ||
#include <iostream> | ||
|
||
using namespace conduit; | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
MPI_Init(&argc, &argv); | ||
|
||
MPI_Comm mpi_comm = MPI_COMM_WORLD; | ||
int par_rank, par_size; | ||
MPI_Comm_rank(mpi_comm, &par_rank); | ||
MPI_Comm_size(mpi_comm, &par_size); | ||
|
||
// Custom catalyst implementations require that we use conduit's C API | ||
conduit_node *initialize = conduit_node_create(); | ||
conduit_node_set_path_char8_str(initialize, "catalyst_load/implementation", "ascent"); | ||
conduit_node_set_path_char8_str(initialize, "catalyst/scripts/my_actions", "ascent_actions.yaml"); | ||
catalyst_initialize(initialize); | ||
|
||
if (par_rank == 0) | ||
{ | ||
conduit_node *about = conduit_node_create(); | ||
catalyst_about(about); | ||
conduit_node_print(about); | ||
} | ||
|
||
// create an example dataset | ||
conduit::Node mesh; | ||
conduit::blueprint::mesh::examples::braid("uniform", 10, 10, 10, mesh); | ||
|
||
// to make a multi domain example, offset the x coords by par_rank | ||
mesh["coordsets/coords/origin/x"] = -10 + 20 * par_rank; | ||
|
||
// We can still use conduit's C++ API | ||
conduit::Node data; | ||
data["catalyst/channels/grid/data"].set_external(mesh); | ||
|
||
// We just have to convert cpp_nodes into c_nodes before passing them to catalyst | ||
conduit_node *data_converted = c_node(&data); | ||
catalyst_execute(data_converted); | ||
|
||
conduit_node *finalize = conduit_node_create(); | ||
catalyst_finalize(finalize); | ||
|
||
MPI_Finalize(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright (c) Lawrence Livermore National Security, LLC and other Ascent | ||
# Project developers. See top-level LICENSE AND COPYRIGHT files for dates and | ||
# other details. No copyright assignment is required to contribute to Ascent. | ||
############################################################################### | ||
|
||
############################################################################### | ||
# | ||
# Example that shows how to use an installed instance of Ascent in another | ||
# CMake-based build system. | ||
# | ||
# To build: | ||
# cmake -DAscent_DIR={ascent install path} -B build -S . | ||
# cp ascent_actions.yaml build | ||
# cd build | ||
# make | ||
# ./ascent_catalyst_example | ||
# | ||
# In order to run directly in a sub directory below ascent-catalyst in an ascent install, | ||
# set Ascent_DIR to ../../.. | ||
# | ||
# cmake -DAscent_DIR=../../.. -B build -S . | ||
# cp ascent_actions.yaml build | ||
# cd build | ||
# make | ||
# ./ascent_catalyst_example | ||
# | ||
############################################################################### | ||
|
||
cmake_minimum_required(VERSION 3.9) | ||
|
||
project(ascent_catalyst) | ||
|
||
# | ||
# Use CMake's find_package to import ascent's targets | ||
# | ||
# PATHS is just a hint if someone runs this example from the Ascent install | ||
# tree without setting up an environment hint to find Ascent | ||
find_package(Ascent REQUIRED | ||
NO_DEFAULT_PATH | ||
PATHS ${CMAKE_SOURCE_DIR}/../../../) | ||
|
||
find_package(catalyst 2.0 REQUIRED) | ||
|
||
# create our example | ||
add_executable(ascent_catalyst_example ascent_catalyst_example.cpp) | ||
|
||
# link to ascent and catalyst | ||
target_link_libraries(ascent_catalyst_example ascent::ascent catalyst::catalyst) | ||
|
||
# if cuda is in the mix: | ||
# we need to make sure CUDA_RESOLVE_DEVICE_SYMBOLS is on for our target | ||
# (it propgates some way magically in 3.14, but not in 3.21) | ||
if(CMAKE_CUDA_COMPILER) | ||
set_property(TARGET ascent_catalyst_example PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
- | ||
action: "add_scenes" | ||
scenes: | ||
s1: | ||
plots: | ||
p1: | ||
type: "pseudocolor" | ||
field: "braid" | ||
image_name: "out_ascent_catalyst_example" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// | ||
// Copyright (c) Lawrence Livermore National Security, LLC and other Ascent | ||
// Project developers. See top-level LICENSE AND COPYRIGHT files for dates and | ||
// other details. No copyright assignment is required to contribute to Ascent. | ||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// | ||
|
||
//----------------------------------------------------------------------------- | ||
/// | ||
/// file: ascent_catalyst_example.cpp | ||
/// | ||
//----------------------------------------------------------------------------- | ||
|
||
#include <catalyst.h> | ||
#include <conduit_blueprint.hpp> | ||
#include <conduit_cpp_to_c.hpp> | ||
|
||
#include <iostream> | ||
|
||
using namespace conduit; | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
// Custom catalyst implementations require that we use conduit's C API | ||
conduit_node *initialize = conduit_node_create(); | ||
conduit_node_set_path_char8_str(initialize, "catalyst_load/implementation", "ascent"); | ||
conduit_node_set_path_char8_str(initialize, "catalyst/scripts/my_actions", "ascent_actions.yaml"); | ||
catalyst_initialize(initialize); | ||
|
||
conduit_node *about = conduit_node_create(); | ||
catalyst_about(about); | ||
conduit_node_print(about); | ||
|
||
// create an example dataset | ||
conduit::Node mesh; | ||
conduit::blueprint::mesh::examples::braid("uniform", 10, 10, 10, mesh); | ||
|
||
// We can still use conduit's C++ API | ||
conduit::Node data; | ||
data["catalyst/channels/grid/data"].set_external(mesh); | ||
|
||
// We just have to convert cpp_nodes into c_nodes before passing them to catalyst | ||
conduit_node *data_converted = c_node(&data); | ||
catalyst_execute(data_converted); | ||
|
||
conduit_node *finalize = conduit_node_create(); | ||
catalyst_finalize(finalize); | ||
} |