Skip to content

Commit

Permalink
use cuda tag and let cmake use other backends
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetyusufoglu committed Nov 28, 2024
1 parent f920100 commit 88ac3f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 32 deletions.
7 changes: 0 additions & 7 deletions example/useCuBLASInAlpaka/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ set(_TARGET_NAME useCuBLASInAlpaka)

project(${_TARGET_NAME} LANGUAGES CXX)

# Check if the cmake variables to see if the Acc option is Cuda Only.
if(NOT alpaka_ACC_GPU_CUDA_ONLY_MODE)
# Print a warning and skip target creation
message(WARNING "Skipping build of 'useCuBLASInAlpaka' because alpaka_ACC_GPU_CUDA_ONLY_MODE is not enabled.")
return()
endif()

# Add cuBLAS library
find_package(CUDA REQUIRED)
set(CUDA_LIBRARIES ${CUDA_LIBRARIES} cublas)
Expand Down
27 changes: 2 additions & 25 deletions example/useCuBLASInAlpaka/src/useCuBLASInAlpaka.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ void initializeMatrix(DataType* buffer, Idx rows, Idx cols)
}
}

// In standard projects, you typically do not execute the code with any available accelerator.
// Instead, a single accelerator is selected once from the active accelerators and the kernels are executed with the
// selected accelerator only. If you use the example as the starting point for your project, you can rename the
// example() function to main() and move the accelerator tag to the function body.
template<alpaka::concepts::Tag TAccTag>
auto example(TAccTag const&) -> int
auto main() -> int
{
using Dim1D = alpaka::DimInt<1>;

Expand All @@ -48,7 +43,7 @@ auto example(TAccTag const&) -> int

// Define the accelerator and queue
// Use Cuda Accelerator. Cmake Acc flags should be set to Cuda-Only
using Acc = alpaka::TagToAcc<TAccTag, Dim1D, Idx>;
using Acc = alpaka::TagToAcc<alpaka::TagGpuCudaRt, Dim1D, Idx>;
using Queue = alpaka::Queue<Acc, alpaka::Blocking>;

auto const platformHost = alpaka::PlatformCpu{};
Expand Down Expand Up @@ -182,21 +177,3 @@ auto example(TAccTag const&) -> int
cublasDestroy(cublasHandle);
return EXIT_SUCCESS;
}

auto main() -> int
{
std::cout << "Check enabled accelerator tags:" << std::endl;
alpaka::printTagNames<alpaka::EnabledAccTags>();
// Execute the example once for each enabled accelerator.
// If you would like to execute it for a single accelerator only you can use the following code.
// \code{.cpp}
// auto tag = TagCpuSerial;
// return example(tag);
// \endcode
//
// valid tags:
// TagCpuSerial, TagGpuHipRt, TagGpuCudaRt, TagCpuOmp2Blocks, TagCpuTbbBlocks,
// TagCpuOmp2Threads, TagCpuSycl, TagCpuTbbBlocks, TagCpuThreads,
// TagFpgaSyclIntel, TagGenericSycl, TagGpuSyclIntel
return alpaka::executeForEachAccTag([=](auto const& tag) { return example(tag); });
}

0 comments on commit 88ac3f2

Please sign in to comment.