From db264360fa8eb13137b51d3cd96d52eb623c1e00 Mon Sep 17 00:00:00 2001 From: Bernhard Manfred Gruber Date: Fri, 12 Jan 2024 18:13:38 +0100 Subject: [PATCH] Add verbose output to alpaka-ls --- example/ls/src/ls.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/example/ls/src/ls.cpp b/example/ls/src/ls.cpp index aa62091978c7..feb829397639 100644 --- a/example/ls/src/ls.cpp +++ b/example/ls/src/ls.cpp @@ -5,21 +5,46 @@ #include +#include + struct PerAcc { + bool verbose; + template void operator()() const { auto const platform = alpaka::Platform{}; std::cout << alpaka::getAccName() << '\n'; for(auto const& dev : alpaka::getDevs(platform)) + { std::cout << '\t' << alpaka::getName(dev) << '\n'; + if(verbose) + { + auto const props = alpaka::getAccDevProps(dev); + auto const globalMem = alpaka::getMemBytes(dev); + + std::cout << "\t\tMultiProcessorCount " << props.m_multiProcessorCount << '\n'; + std::cout << "\t\tGlobalMemSizeBytes " << globalMem << '\n'; + std::cout << "\t\tSharedMemSizeBytes " << props.m_sharedMemSizeBytes << '\n'; + + std::cout << "\t\tGridBlockExtentMax " << props.m_gridBlockExtentMax << '\n'; + std::cout << "\t\tBlockThreadExtentMax " << props.m_blockThreadExtentMax << '\n'; + std::cout << "\t\tThreadElemExtentMax " << props.m_threadElemExtentMax << '\n'; + + std::cout << "\t\tGridBlockCountMax " << props.m_gridBlockCountMax << '\n'; + std::cout << "\t\tBlockThreadCountMax " << props.m_blockThreadCountMax << '\n'; + std::cout << "\t\tThreadElemCountMax " << props.m_threadElemCountMax << '\n'; + } + } } }; -int main() +int main(int argc, char const* argv[]) { + auto const verbose = argc >= 2 && std::string_view{argv[1]} == "-v"; + using Idx = int; using Dim = alpaka::DimInt<1>; - alpaka::meta::forEachType>(PerAcc{}); + alpaka::meta::forEachType>(PerAcc{verbose}); }