Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
cd5065e
initial commit for launch loop optimization
artv3 Nov 25, 2025
484ff1a
add structs to store gpu thread/block info in launch ctx
artv3 Nov 25, 2025
18f332b
add cuda variant and add build guards for cpu
artv3 Dec 2, 2025
21f6184
Merge branch 'develop' into artv3/launch-loop-opt
artv3 Dec 2, 2025
73f224a
rework to support dim3 copy in ctx
artv3 Dec 11, 2025
8a02fee
Merge branch 'artv3/launch-loop-opt' of https://github.com/LLNL/RAJA …
artv3 Dec 11, 2025
1fbe50b
minor clean up pass
artv3 Dec 11, 2025
672889e
make format
artv3 Dec 11, 2025
5908a20
Update include/RAJA/pattern/launch/launch_core.hpp
artv3 Dec 11, 2025
316e019
Merge branch 'develop' into artv3/launch-loop-opt
rhornung67 Dec 15, 2025
4d9f800
clean up pass
artv3 Dec 18, 2025
d9ce271
update with develop and fix merge conflicts
artv3 Dec 18, 2025
85aef5a
fix build error
artv3 Dec 18, 2025
0469302
take develop submodule
artv3 Dec 18, 2025
4a695f2
cuda backend
artv3 Dec 18, 2025
f91a498
make style
artv3 Dec 18, 2025
d21c41f
omp backend
artv3 Dec 18, 2025
40a5c1b
seq backend + make style
artv3 Dec 18, 2025
e0f4825
clean up pass
artv3 Dec 18, 2025
96e99d5
Update include/RAJA/pattern/launch/launch_context_policy.hpp
artv3 Dec 18, 2025
a9f0cca
minor clean up
artv3 Dec 18, 2025
7d4595b
minor clean up
artv3 Dec 18, 2025
c23f76f
Merge branch 'artv3/launch-loop-opt' of github.com:LLNL/RAJA into art…
artv3 Dec 18, 2025
c990a4f
revert changes to example
artv3 Dec 18, 2025
f7939fd
remove specialization from launch policy
artv3 Dec 18, 2025
c24331c
make work for function pointers
artv3 Dec 18, 2025
0518138
store dim3 based on launch context type - hip
artv3 Dec 19, 2025
d5da29a
rework omp backend
artv3 Dec 19, 2025
af88dbb
update sequential backend
artv3 Dec 19, 2025
21ad0a8
get things building for cuda -- need a good clean up pass
artv3 Dec 19, 2025
646a95b
cuda clean up pass
artv3 Dec 19, 2025
597641b
clean up ordering in hip launch
artv3 Dec 19, 2025
5403737
clean up ordering
artv3 Dec 19, 2025
e41e970
make style
artv3 Dec 19, 2025
7c95430
use constexpt for getting dim values
artv3 Dec 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions include/RAJA/pattern/launch/launch_context_policy.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*!
******************************************************************************
*
* \file
*
* \brief RAJA header file containing template types of RAJA::LaunchContextT
*
******************************************************************************
*/

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Copyright (c) 2016-25, Lawrence Livermore National Security, LLC
// and RAJA project contributors. See the RAJA/LICENSE file for details.
//
// SPDX-License-Identifier: (BSD-3-Clause)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

#ifndef RAJA_pattern_context_policy_HPP
#define RAJA_pattern_context_policy_HPP

namespace RAJA
{

template<typename LaunchContextPolicy>
class LaunchContextT;

class LaunchContextDefaultPolicy;

#if defined(RAJA_CUDA_ACTIVE) || defined(RAJA_HIP_ACTIVE)
class LaunchContextDim3Policy;
#endif

namespace detail
{


template<typename T, typename = void>
struct has_single_call_operator : std::false_type
{};

template<typename T>
struct has_single_call_operator<
T,
std::enable_if_t<
!std::is_same_v<decltype(&std::decay_t<T>::operator()), void>>>
: std::true_type
{};

template<typename T>
struct function_traits
{};

template<typename R, typename... Args>
struct function_traits<R(Args...)>
{
using result_type = R;
static constexpr std::size_t arity = sizeof...(Args);

template<std::size_t N>
struct arg
{
static_assert(N < arity, "argument index out of range");
using type = typename std::tuple_element<N, std::tuple<Args...>>::type;
};
};

template<typename R, typename... Args>
struct function_traits<R (*)(Args...)> : function_traits<R(Args...)>
{};

template<typename R, typename... Args>
struct function_traits<R (&)(Args...)> : function_traits<R(Args...)>
{};

template<typename C, typename R, typename... Args>
struct function_traits<R (C::*)(Args...) const> : function_traits<R(Args...)>
{
using functional_type = C;
};

template<typename C, typename R, typename... Args>
struct function_traits<R (C::*)(Args...)> : function_traits<R(Args...)>
{
using functional_type = C;
};

template<typename T,
bool hasCallOp = has_single_call_operator<std::decay_t<T>>::value>
struct functional_traits : function_traits<std::decay_t<T>>
{};

template<typename T>
struct functional_traits<T, true>
: function_traits<decltype(&std::decay_t<T>::operator())>
{};

template<typename T, typename = void>
struct has_arg0 : std::false_type
{};

template<typename T>
struct has_arg0<T,
typename std::enable_if_t<!std::is_same_v<
typename functional_traits<T>::template arg<0>::type,
void>>> : std::true_type
{};

template<typename T, bool HasArg0 = has_arg0<T>::value>
struct launch_context_type
{
using type = LaunchContextT<LaunchContextDefaultPolicy>;
};

template<typename T>
struct launch_context_type<T, true>
{
using type = typename functional_traits<T>::template arg<0>::type;
};


} // namespace detail

} // namespace RAJA
#endif
53 changes: 36 additions & 17 deletions include/RAJA/pattern/launch/launch_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "RAJA/config.hpp"
#include "RAJA/internal/get_platform.hpp"
#include "RAJA/pattern/launch/launch_context_policy.hpp"
#include "RAJA/util/StaticLayout.hpp"
#include "RAJA/util/macros.hpp"
#include "RAJA/util/plugins.hpp"
Expand Down Expand Up @@ -176,21 +177,20 @@ struct LaunchParams
Threads apply(Threads const& a) { return (threads = a); }
};

class LaunchContext
class LaunchContextBase
{
public:
// Bump style allocator used to
// get memory from the pool
size_t shared_mem_offset;

void* shared_mem_ptr;

#if defined(RAJA_SYCL_ACTIVE)
// SGS ODR issue
mutable ::sycl::nd_item<3>* itm;
#endif

RAJA_HOST_DEVICE LaunchContext()
RAJA_HOST_DEVICE LaunchContextBase()
: shared_mem_offset(0),
shared_mem_ptr(nullptr)
{}
Expand All @@ -209,20 +209,6 @@ class LaunchContext
return static_cast<T*>(mem_ptr);
}

/*
//Odd dependecy with atomics is breaking CI builds
template<typename T, size_t DIM, typename IDX_T=RAJA::Index_type, ptrdiff_t
z_stride=DIM-1, typename arg, typename... args> RAJA_HOST_DEVICE auto
getSharedMemoryView(size_t bytes, arg idx, args... idxs)
{
T * mem_ptr = &((T*) shared_mem_ptr)[shared_mem_offset];

shared_mem_offset += bytes*sizeof(T);
return RAJA::View<T, RAJA::Layout<DIM, IDX_T, z_stride>>(mem_ptr, idx,
idxs...);
}
*/

RAJA_HOST_DEVICE void releaseSharedMemory()
{
// On the cpu/gpu we want to restart the count
Expand All @@ -243,6 +229,39 @@ class LaunchContext
}
};

template<>
class LaunchContextT<LaunchContextDefaultPolicy> : public LaunchContextBase
{
public:
static constexpr bool hasDim3 = false;

using LaunchContextBase::LaunchContextBase;
};

// Preserve backwards compatibility
using LaunchContext = LaunchContextT<LaunchContextDefaultPolicy>;

#if defined(RAJA_CUDA_ACTIVE) || defined(RAJA_HIP_ACTIVE)
template<>
class LaunchContextT<LaunchContextDim3Policy> : public LaunchContextBase
{
public:
static constexpr bool hasDim3 = true;

dim3 thread_id;
dim3 block_dim;

LaunchContextT() : LaunchContextBase(), thread_id(), block_dim() {}

RAJA_DEVICE
LaunchContextT(dim3 thread, dim3 block)
: LaunchContextBase(),
thread_id(thread),
block_dim(block)
{}
};
#endif

template<typename LAUNCH_POLICY>
struct LaunchExecute;

Expand Down
Loading