Skip to content

Commit

Permalink
Allocate local mem with new[]/delete[]
Browse files Browse the repository at this point in the history
Sometimes the amount of memory is only known at runtime and
dynamically sized local arrays are not allowed in c++.
  • Loading branch information
MrBurmark committed Feb 10, 2025
1 parent 579ff77 commit 9963841
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions include/RAJA/pattern/kernel/InitLocalMem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,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

// 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 9963841

Please sign in to comment.