Skip to content

Commit f352a5f

Browse files
Removing dynamic stack allocation fix
1 parent bd9f2fb commit f352a5f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

include/RAJA/pattern/kernel/InitLocalMem.hpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,23 @@ struct StatementExecutor<statement::InitLocalMem<RAJA::cpu_tile_mem,camp::idx_se
7777
using varType = typename camp::tuple_element_t<Pos, typename camp::decay<Data>::param_tuple_t>::value_type;
7878

7979
// Initialize memory
80+
#ifdef RAJA_COMPILER_MSVC
81+
// MSVC doesn't like taking a pointer to stack allocated data?!?!
8082
varType *ptr = new varType[camp::get<Pos>(data.param_tuple).size()];
8183
camp::get<Pos>(data.param_tuple).set_data(ptr);
82-
84+
#else
85+
varType Array[camp::get<Pos>(data.param_tuple).size()];
86+
camp::get<Pos>(data.param_tuple).set_data(&Array[0]);
87+
#endif
8388

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

8792
// Cleanup and return
8893
camp::get<Pos>(data.param_tuple).set_data(nullptr);
94+
#ifdef RAJA_COMPILER_MSVC
8995
delete[] ptr;
96+
#endif
9097
}
9198

9299

0 commit comments

Comments
 (0)