diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 845c2400fae7..b74c45b86243 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -22,6 +22,7 @@ add_subdirectory("heatEquation/") add_subdirectory("helloWorld/") add_subdirectory("helloWorldLambda/") add_subdirectory("kernelSpecialization/") +add_subdirectory("ls/") add_subdirectory("monteCarloIntegration/") add_subdirectory("openMPSchedule/") add_subdirectory("parallelLoopPatterns/") diff --git a/example/ls/CMakeLists.txt b/example/ls/CMakeLists.txt new file mode 100644 index 000000000000..f3034cd1673e --- /dev/null +++ b/example/ls/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright 2023 Bernhard Manfred Gruber +# SPDX-License-Identifier: ISC + +cmake_minimum_required(VERSION 3.22) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + +project(alpaka-ls LANGUAGES CXX) +if(NOT TARGET alpaka::alpaka) + option(alpaka_USE_SOURCE_TREE "Use alpaka's source tree instead of an alpaka installation" OFF) + if(alpaka_USE_SOURCE_TREE) + set(alpaka_BUILD_EXAMPLES OFF) # Don't build the examples recursively + add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../.." "${CMAKE_BINARY_DIR}/alpaka") + else() + find_package(alpaka REQUIRED) + endif() +endif() + +alpaka_add_executable(${PROJECT_NAME} src/ls.cpp) +target_link_libraries(${PROJECT_NAME} PUBLIC alpaka::alpaka) +set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER example) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}) diff --git a/example/ls/src/ls.cpp b/example/ls/src/ls.cpp new file mode 100644 index 000000000000..aa62091978c7 --- /dev/null +++ b/example/ls/src/ls.cpp @@ -0,0 +1,25 @@ +// Copyright 2023 Bernhard Manfred Gruber +// SPDX-License-Identifier: ISC + +#include "alpaka/test/acc/TestAccs.hpp" + +#include + +struct PerAcc +{ + 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'; + } +}; + +int main() +{ + using Idx = int; + using Dim = alpaka::DimInt<1>; + alpaka::meta::forEachType>(PerAcc{}); +}