-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
space-time-stack: allow demangled names
- Loading branch information
1 parent
0becae4
commit 9cc8f85
Showing
11 changed files
with
221 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
//@HEADER | ||
// ************************************************************************ | ||
// | ||
// Kokkos v. 4.0 | ||
// Copyright (2022) National Technology & Engineering | ||
// Solutions of Sandia, LLC (NTESS). | ||
// | ||
// Under the terms of Contract DE-NA0003525 with NTESS, | ||
// the U.S. Government retains certain rights in this software. | ||
// | ||
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://kokkos.org/LICENSE for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//@HEADER | ||
|
||
#ifndef KOKKOSTOOLS_COMMON_UTILS_DEMANGLE_HPP | ||
#define KOKKOSTOOLS_COMMON_UTILS_DEMANGLE_HPP | ||
|
||
#include <string> | ||
|
||
#if defined(__GXX_ABI_VERSION) | ||
#define HAVE_GCC_ABI_DEMANGLE | ||
#endif | ||
|
||
#if defined(HAVE_GCC_ABI_DEMANGLE) | ||
#include <cxxabi.h> | ||
#endif // HAVE_GCC_ABI_DEMANGLE | ||
|
||
namespace KokkosTools { | ||
|
||
//! Demangle @p mangled_name. | ||
inline std::string demangleName(const std::string_view mangled_name) { | ||
#if defined(HAVE_GCC_ABI_DEMANGLE) | ||
int status = 0; | ||
|
||
char* demangled_name = | ||
abi::__cxa_demangle(mangled_name.data(), nullptr, nullptr, &status); | ||
|
||
if (demangled_name) { | ||
std::string ret(demangled_name); | ||
std::free(demangled_name); | ||
return ret; | ||
} | ||
#endif | ||
return std::string(mangled_name); | ||
} | ||
|
||
/** | ||
* @brief Demangle @p mangled_name. | ||
* | ||
* This function supports @c Kokkos convention from @c Kokkos::Impl::ParallelConstructName. | ||
* | ||
* For instance, a kernel launched with a tag would appear as "<functor type>/<tag type>". | ||
*/ | ||
inline std::string demangleNameKokkos(const std::string_view mangled_name) { | ||
if (size_t pos = mangled_name.find('/', 0); pos != std::string_view::npos && pos > 0) { | ||
/// An explicit copy of the first part of the string is needed, because @c abi::__cxa_demangle | ||
/// will parse the pointer until its NULL-terminated. | ||
return demangleName(std::string(mangled_name.substr(0, pos))) | ||
.append("/") | ||
.append(demangleName(mangled_name.substr(pos + 1, mangled_name.size()))); | ||
} else { | ||
return demangleName(mangled_name); | ||
} | ||
} | ||
|
||
} // namespace KokkosTools | ||
|
||
#endif // KOKKOSTOOLS_COMMON_UTILS_DEMANGLE_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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(space-time-stack) |
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,18 @@ | ||
# A function to add such "simple" tests in 'tests/CMakeLists.txt' might be a good option. | ||
add_executable(test_space_time_stack_demangling) | ||
target_sources( | ||
test_space_time_stack_demangling | ||
PRIVATE | ||
test_demangling.cpp | ||
) | ||
target_link_libraries( | ||
test_space_time_stack_demangling | ||
PRIVATE | ||
Kokkos::kokkos kokkostools | ||
) | ||
add_test( | ||
NAME test_space_time_stack_demangling | ||
COMMAND $<TARGET_FILE:test_space_time_stack_demangling> | ||
--kokkos-tools-libs=$<TARGET_FILE:kp_space_time_stack> | ||
--kokkos-tools-args=1e-9 | ||
) |
Oops, something went wrong.