forked from ComputationalRadiationPhysics/picongpu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed 'thirdParty/cupla/' changes from 98dd7f2f6..22dfdf457
22dfdf457 Merge pull request ComputationalRadiationPhysics#194 from psychocoderHPC/topic-updateAlpakaTo0.6.0rc4 c598470d3 Merge pull request ComputationalRadiationPhysics#193 from psychocoderHPC/topic-CILatestContainer c54d1dec3 Merge commit 'b7ec15f0c9bbbcf983277bb119cb551ce7d2d2d2' into topic-updateAlpakaTo0.6.0rc4 b7ec15f0c Squashed 'alpaka/' changes from 01f22779da..daf599b113 e8f8952c1 CUDA 9.2 use GCC 6 0384a58c5 CI: update container to v1.1 git-subtree-dir: thirdParty/cupla git-subtree-split: 22dfdf4574d529b26523ce66368aaf2caea16566
- Loading branch information
1 parent
d218b26
commit 7284556
Showing
25 changed files
with
847 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# | ||
# Copyright 2014-2020 Erik Zenker, Benjamin Worpitz, Jan Stephan, Sergei Bastrakov | ||
# | ||
# This file exemplifies usage of alpaka. | ||
# | ||
# Permission to use, copy, modify, and/or distribute this software for any | ||
# purpose with or without fee is hereby granted, provided that the above | ||
# copyright notice and this permission notice appear in all copies. | ||
# | ||
# THE SOFTWARE IS PROVIDED “AS IS” AND ISC DISCLAIMS ALL WARRANTIES WITH | ||
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY | ||
# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
# | ||
|
||
################################################################################ | ||
# Required CMake version. | ||
|
||
cmake_minimum_required(VERSION 3.15) | ||
|
||
set_property(GLOBAL PROPERTY USE_FOLDERS ON) | ||
|
||
################################################################################ | ||
# Project. | ||
|
||
set(_TARGET_NAME openMPSchedule) | ||
|
||
project(${_TARGET_NAME}) | ||
|
||
#------------------------------------------------------------------------------- | ||
# Find alpaka. | ||
|
||
if(NOT TARGET alpaka::alpaka) | ||
option(USE_ALPAKA_SOURCE_TREE "Use alpaka's source tree instead of an alpaka installation" OFF) | ||
|
||
if(USE_ALPAKA_SOURCE_TREE) | ||
# Don't build the examples recursively | ||
set(alpaka_BUILD_EXAMPLES OFF) | ||
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../.." "${CMAKE_BINARY_DIR}/alpaka") | ||
else() | ||
find_package(alpaka REQUIRED) | ||
endif() | ||
endif() | ||
|
||
#------------------------------------------------------------------------------- | ||
# Add executable. | ||
|
||
alpaka_add_executable( | ||
${_TARGET_NAME} | ||
src/openMPSchedule.cpp) | ||
target_link_libraries( | ||
${_TARGET_NAME} | ||
PUBLIC alpaka::alpaka) | ||
|
||
set_target_properties(${_TARGET_NAME} PROPERTIES FOLDER example) | ||
|
||
add_test(NAME ${_TARGET_NAME} COMMAND ${_TARGET_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
/* Copyright 2019-2020 Benjamin Worpitz, Erik Zenker, Sergei Bastrakov | ||
* | ||
* This file exemplifies usage of alpaka. | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED “AS IS” AND ISC DISCLAIMS ALL WARRANTIES WITH | ||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#include <alpaka/alpaka.hpp> | ||
#include <alpaka/example/ExampleDefaultAcc.hpp> | ||
|
||
#include <cstdint> | ||
#include <iostream> | ||
|
||
// This example only makes sense with alpaka AccCpuOmp2Blocks backend enabled | ||
// and OpenMP runtime supporting at least 3.0. Disable it for other cases. | ||
#if defined _OPENMP && _OPENMP >= 200805 && ALPAKA_ACC_CPU_B_OMP2_T_SEQ_ENABLED | ||
|
||
//############################################################################# | ||
//! OpenMP schedule demonstration kernel | ||
//! | ||
//! Prints distribution of alpaka thread indices between OpenMP threads. | ||
//! Its operator() is reused in other kernels of this example. | ||
//! Sets no schedule explicitly, so the default is used, controlled by the OMP_SCHEDULE environment variable. | ||
struct OpenMPScheduleDefaultKernel | ||
{ | ||
//----------------------------------------------------------------------------- | ||
template<typename TAcc> | ||
ALPAKA_FN_ACC auto operator()(TAcc const& acc) const -> void | ||
{ | ||
// For simplicity assume 1d index space throughout this example | ||
using Idx = alpaka::Idx<TAcc>; | ||
Idx const globalThreadIdx = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc)[0]; | ||
|
||
// Print work distribution between threads for illustration | ||
printf( | ||
"alpaka global thread index %u is processed by OpenMP thread %d\n", | ||
static_cast<std::uint32_t>(globalThreadIdx), | ||
omp_get_thread_num()); | ||
} | ||
}; | ||
|
||
//############################################################################# | ||
//! Kernel that sets the schedule via a static member. | ||
//! We inherit OpenMPScheduleDefaultKernel just to reuse its operator(). | ||
struct OpenMPScheduleMemberKernel : public OpenMPScheduleDefaultKernel | ||
{ | ||
//! Static member to set OpenMP schedule to be used by the AccCpuOmp2Blocks accelerator. | ||
//! This member is only checked for when the OmpSchedule trait is not specialized for this kernel type. | ||
//! Note that constexpr is not required, however otherwise there has to be an external definition. | ||
static constexpr auto ompSchedule = alpaka::omp::Schedule{alpaka::omp::Schedule::Static, 1}; | ||
}; | ||
|
||
//############################################################################# | ||
//! Kernel that sets the schedule via trait specialization. | ||
//! We inherit OpenMPScheduleDefaultKernel just to reuse its operator(). | ||
//! The schedule trait specialization is given underneath this struct. | ||
//! It has a higher priority than the internal static member. | ||
struct OpenMPScheduleTraitKernel : public OpenMPScheduleDefaultKernel | ||
{ | ||
}; | ||
|
||
namespace alpaka | ||
{ | ||
namespace traits | ||
{ | ||
//! Schedule trait specialization for OpenMPScheduleTraitKernel. | ||
//! This is the most general way to define a schedule. | ||
//! In case neither the trait nor the member are provided, alpaka does not set any runtime schedule and the | ||
//! schedule used is defined by omp_set_schedule() called on the user side, or otherwise by the OMP_SCHEDULE | ||
//! environment variable. | ||
template<typename TAcc> | ||
struct OmpSchedule<OpenMPScheduleTraitKernel, TAcc> | ||
{ | ||
template<typename TDim, typename... TArgs> | ||
ALPAKA_FN_HOST static auto getOmpSchedule( | ||
OpenMPScheduleTraitKernel const& kernelFnObj, | ||
Vec<TDim, Idx<TAcc>> const& blockThreadExtent, | ||
Vec<TDim, Idx<TAcc>> const& threadElemExtent, | ||
TArgs const&... args) -> alpaka::omp::Schedule | ||
{ | ||
// Determine schedule at runtime for the given kernel and run parameters. | ||
// For this particular example kernel, TArgs is an empty pack and can be removed. | ||
alpaka::ignore_unused(kernelFnObj); | ||
alpaka::ignore_unused(blockThreadExtent); | ||
alpaka::ignore_unused(threadElemExtent); | ||
alpaka::ignore_unused(args...); | ||
|
||
return alpaka::omp::Schedule{alpaka::omp::Schedule::Dynamic, 2}; | ||
} | ||
}; | ||
} // namespace traits | ||
} // namespace alpaka | ||
|
||
auto main() -> int | ||
{ | ||
// Fallback for the CI with disabled sequential backend | ||
# if defined(ALPAKA_CI) && !defined(ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED) | ||
return EXIT_SUCCESS; | ||
# else | ||
using Idx = std::size_t; | ||
|
||
// OpenMP schedule illustrated by this example only has effect with | ||
// with the AccCpuOmp2Blocks accelerator. | ||
// This example also assumes 1d for simplicity. | ||
using Acc = alpaka::AccCpuOmp2Blocks<alpaka::DimInt<1>, Idx>; | ||
std::cout << "Using alpaka accelerator: " << alpaka::getAccName<Acc>() << std::endl; | ||
|
||
// Defines the synchronization behavior of a queue | ||
using QueueProperty = alpaka::Blocking; | ||
using Queue = alpaka::Queue<Acc, QueueProperty>; | ||
|
||
// Select a device | ||
auto const devAcc = alpaka::getDevByIdx<Acc>(0u); | ||
|
||
// Create a queue on the device | ||
Queue queue(devAcc); | ||
|
||
// Define the work division | ||
Idx const threadsPerGrid = 16u; | ||
Idx const elementsPerThread = 1u; | ||
auto const workDiv = alpaka::getValidWorkDiv<Acc>( | ||
devAcc, | ||
threadsPerGrid, | ||
elementsPerThread, | ||
false, | ||
alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); | ||
|
||
// Run the kernel setting no schedule explicitly. | ||
// In this case the schedule is controlled by the OMP_SCHEDULE environment variable. | ||
std::cout << "OpenMPScheduleDefaultKernel setting no schedule explicitly:\n"; | ||
alpaka::exec<Acc>(queue, workDiv, OpenMPScheduleDefaultKernel{}); | ||
alpaka::wait(queue); | ||
|
||
// Run the kernel setting the schedule via a trait | ||
std::cout << "\n\nOpenMPScheduleMemberKernel setting the schedule via a static member:\n"; | ||
alpaka::exec<Acc>(queue, workDiv, OpenMPScheduleMemberKernel{}); | ||
alpaka::wait(queue); | ||
|
||
// Run the kernel setting the schedule via a trait | ||
std::cout << "\n\nOpenMPScheduleTraitKernel setting the schedule via trait:\n"; | ||
alpaka::exec<Acc>(queue, workDiv, OpenMPScheduleTraitKernel{}); | ||
alpaka::wait(queue); | ||
|
||
return EXIT_SUCCESS; | ||
# endif | ||
} | ||
#else | ||
auto main() -> int | ||
{ | ||
std::cout << "This example is disabled, as it requires OpenMP runtime version >= 3.0 and alpaka accelerator" | ||
<< " AccCpuOmp2Blocks\n"; | ||
return EXIT_SUCCESS; | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.