diff --git a/include/alpaka/dev/Traits.hpp b/include/alpaka/dev/Traits.hpp index 16de5b48f8a5..ca7b358ca8a4 100644 --- a/include/alpaka/dev/Traits.hpp +++ b/include/alpaka/dev/Traits.hpp @@ -7,6 +7,8 @@ #include "alpaka/core/Common.hpp" #include "alpaka/core/Concepts.hpp" +#include +#include #include #include #include @@ -65,11 +67,22 @@ namespace alpaka return trait::GetDev::getDev(t); } - //! \return The device name. + namespace detail + { + inline auto trim(std::string s) -> std::string + { + auto const pred = [](char c) { return !std::isspace(c); }; + s.erase(std::find_if(rbegin(s), rend(s), pred).base(), end(s)); + s.erase(begin(s), std::find_if(begin(s), end(s), pred)); + return s; + } + } // namespace detail + + //! \return The device name with leading/trailing space characters trimmed off. template ALPAKA_FN_HOST auto getName(TDev const& dev) -> std::string { - return trait::GetName::getName(dev); + return detail::trim(trait::GetName::getName(dev)); } //! \return The memory on the device in Bytes. Returns 0 if querying memory