From 7e5350d56e4b8e14f6f9812095ca29aa4265b719 Mon Sep 17 00:00:00 2001 From: David Beckingsale Date: Mon, 17 Jul 2023 10:42:52 -0700 Subject: [PATCH] setExecutionSpace thread safety(#230) Co-authored-by: Neela Kausik --- src/chai/ArrayManager.cpp | 2 ++ src/chai/ArrayManager.hpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/chai/ArrayManager.cpp b/src/chai/ArrayManager.cpp index 946ff5ce..b3290d2d 100644 --- a/src/chai/ArrayManager.cpp +++ b/src/chai/ArrayManager.cpp @@ -16,6 +16,8 @@ namespace chai { +thread_local ExecutionSpace ArrayManager::m_current_execution_space; +thread_local bool ArrayManager::m_synced_since_last_kernel = false; PointerRecord ArrayManager::s_null_record = PointerRecord(); diff --git a/src/chai/ArrayManager.hpp b/src/chai/ArrayManager.hpp index 8963cfd3..bc957f1b 100644 --- a/src/chai/ArrayManager.hpp +++ b/src/chai/ArrayManager.hpp @@ -489,7 +489,7 @@ class ArrayManager /*! * Current execution space. */ - ExecutionSpace m_current_execution_space; + static thread_local ExecutionSpace m_current_execution_space; /** * Default space for new allocations. @@ -536,7 +536,7 @@ class ArrayManager * Whether or not a synchronize has been performed since the launch of the last * GPU context */ - bool m_synced_since_last_kernel = false; + static thread_local bool m_synced_since_last_kernel; #if defined(CHAI_ENABLE_GPU_SIMULATION_MODE) /*!