Skip to content

Commit

Permalink
Add alpaka-ls
Browse files Browse the repository at this point in the history
This is a small tool, checked in as example, to print all enabled
accelerators with their devices.

Co-authored-by: Simeon Ehrig <[email protected]>
  • Loading branch information
bernhardmgruber and SimeonEhrig committed Nov 29, 2023
1 parent cce9b43 commit 7f316d9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
Expand Down
21 changes: 21 additions & 0 deletions example/ls/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
25 changes: 25 additions & 0 deletions example/ls/src/ls.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2023 Bernhard Manfred Gruber
// SPDX-License-Identifier: ISC

#include "alpaka/test/acc/TestAccs.hpp"

#include <alpaka/alpaka.hpp>

struct PerAcc
{
template<typename TAcc>
void operator()() const
{
auto const platform = alpaka::Platform<TAcc>{};
std::cout << alpaka::getAccName<TAcc>() << '\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<alpaka::test::EnabledAccs<Dim, Idx>>(PerAcc{});
}

0 comments on commit 7f316d9

Please sign in to comment.