Skip to content

Commit

Permalink
Merge pull request #1790 from LLNL/bugfix/burmark1/InitLocalMem
Browse files Browse the repository at this point in the history
Use dynamically allocated buffer instead of dynamically sized local array in kernel InitLocalMem
  • Loading branch information
MrBurmark authored Feb 13, 2025
2 parents 579ff77 + 982851f commit 647b177
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions include/RAJA/pattern/kernel/InitLocalMem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <iostream>
#include <type_traits>
#include <memory>

namespace RAJA
{
Expand Down Expand Up @@ -83,23 +84,15 @@ struct StatementExecutor<statement::InitLocalMem<RAJA::cpu_tile_mem,
Pos, typename camp::decay<Data>::param_tuple_t>::value_type;

// Initialize memory
#ifdef RAJA_COMPILER_MSVC
// MSVC doesn't like taking a pointer to stack allocated data?!?!
varType* ptr = new varType[camp::get<Pos>(data.param_tuple).size()];
camp::get<Pos>(data.param_tuple).set_data(ptr);
#else
varType Array[camp::get<Pos>(data.param_tuple).size()];
camp::get<Pos>(data.param_tuple).set_data(&Array[0]);
#endif
auto local_mem =
std::make_unique<varType[]>(camp::get<Pos>(data.param_tuple).size());
camp::get<Pos>(data.param_tuple).set_data(local_mem.get());

// Initialize others and execute
exec_expanded<others...>(data);

// Cleanup and return
camp::get<Pos>(data.param_tuple).set_data(nullptr);
#ifdef RAJA_COMPILER_MSVC
delete[] ptr;
#endif
}

template<typename Data>
Expand Down

0 comments on commit 647b177

Please sign in to comment.