forked from trilinos/Trilinos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge Pull Request trilinos#12076 from trilinos/Trilinos/master_merge…
…_20230721_175808 Automatically Merged using Trilinos Master Merge AutoTester PR Title: Trilinos Master Merge PR Generator: Auto PR created to promote from master_merge_20230721_175808 branch to master PR Author: trilinos-autotester
- Loading branch information
Showing
87 changed files
with
5,291 additions
and
1,125 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
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
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
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
66 changes: 66 additions & 0 deletions
66
packages/phalanx/src/Phalanx_Kokkos_Tools_CheckStreams.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,66 @@ | ||
#include "Phalanx_Kokkos_Tools_CheckStreams.hpp" | ||
#include "Phalanx_KokkosDeviceTypes.hpp" | ||
#include "Kokkos_Core.hpp" | ||
#include "Teuchos_Assert.hpp" | ||
#include <limits> | ||
|
||
// ********************************** | ||
// Ideally, we would like to also check allocations, deallocations, | ||
// deep_copy, create_mirror, create_mirror_view, and | ||
// create_mirror_view_and_copy as well. The kokkos tools will need to | ||
// be modified to pass in the device id for these functions. For now | ||
// we can only check parallel_* and fencing. | ||
// ********************************** | ||
|
||
// Lambdas can only be converted to function pointers if they do not capture. | ||
// Using a global non-static variable in an unnamed namespace to "capture" the | ||
// device id. | ||
#if defined(KOKKOS_ENABLE_CUDA) || defined(KOKKOS_ENABLE_HIP) | ||
namespace { | ||
uint32_t phalanx_default_stream_device_id = std::numeric_limits<uint32_t>::max(); | ||
|
||
void phalanx_kt_parallel_x_callback(char const *label, uint32_t device_id, | ||
uint64_t * /*kernel_id*/) | ||
{ | ||
TEUCHOS_TEST_FOR_EXCEPTION(device_id == phalanx_default_stream_device_id, | ||
std::runtime_error, | ||
"\"ERROR: the kernel \"" << label | ||
<< "\" with device id=" << device_id | ||
<< " is the same as the default stream id=" | ||
<< phalanx_default_stream_device_id); | ||
} | ||
|
||
void phalanx_kt_fence_callback(char const *label, uint32_t device_id, | ||
uint64_t * /*fence_id*/) | ||
{ | ||
TEUCHOS_TEST_FOR_EXCEPTION(device_id == phalanx_default_stream_device_id, | ||
std::runtime_error, | ||
"\"ERROR: the fence \"" << label | ||
<< "\" with device id=" << device_id | ||
<< " is the same as the default stream id=" | ||
<< phalanx_default_stream_device_id); | ||
} | ||
} | ||
#endif | ||
|
||
void PHX::set_enforce_no_default_stream_use() | ||
{ | ||
#if defined(KOKKOS_ENABLE_CUDA) || defined(KOKKOS_ENABLE_HIP) | ||
phalanx_default_stream_device_id = Kokkos::Tools::Experimental::device_id(PHX::Device()); | ||
|
||
Kokkos::Tools::Experimental::set_begin_parallel_for_callback(phalanx_kt_parallel_x_callback); | ||
Kokkos::Tools::Experimental::set_begin_parallel_reduce_callback(phalanx_kt_parallel_x_callback); | ||
Kokkos::Tools::Experimental::set_begin_parallel_scan_callback(phalanx_kt_parallel_x_callback); | ||
Kokkos::Tools::Experimental::set_begin_fence_callback(phalanx_kt_fence_callback); | ||
#endif | ||
} | ||
|
||
void PHX::unset_enforce_no_default_stream_use() | ||
{ | ||
#if defined(KOKKOS_ENABLE_CUDA) || defined(KOKKOS_ENABLE_HIP) | ||
Kokkos::Tools::Experimental::set_begin_parallel_for_callback(nullptr); | ||
Kokkos::Tools::Experimental::set_begin_parallel_reduce_callback(nullptr); | ||
Kokkos::Tools::Experimental::set_begin_parallel_scan_callback(nullptr); | ||
Kokkos::Tools::Experimental::set_begin_fence_callback(nullptr); | ||
#endif | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/phalanx/src/Phalanx_Kokkos_Tools_CheckStreams.hpp
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,15 @@ | ||
#ifndef PHALANX_KOKKOS_TOOLS_VERIFYSTREAM_HPP | ||
#define PHALANX_KOKKOS_TOOLS_VERIFYSTREAM_HPP | ||
|
||
namespace PHX { | ||
/// Function that sets kokkos-tools callbacks to make sure that the | ||
/// default stream is not being using in any kokkos calls. Checks | ||
/// are only active for cuda and hip backends as the id for the | ||
/// serial backend is always the same. | ||
void set_enforce_no_default_stream_use(); | ||
|
||
/// Function that unsets kokkos-tools callbacks. | ||
void unset_enforce_no_default_stream_use(); | ||
} | ||
|
||
#endif |
Oops, something went wrong.