This contains my bachelors thesis and associated tex files, code snippets and maybe more. Topic: Data Movement in Heterogeneous Memories with Intel Data Streaming Accelerator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

712 lines
26 KiB

  1. #pragma once
  2. #include <iostream>
  3. #include <unordered_map>
  4. #include <shared_mutex>
  5. #include <mutex>
  6. #include <memory>
  7. #include <sched.h>
  8. #include <numa.h>
  9. #include <numaif.h>
  10. #include <dml/dml.hpp>
  11. namespace dml {
  12. inline const std::string StatusCodeToString(const dml::status_code code) {
  13. switch (code) {
  14. case dml::status_code::ok: return "ok";
  15. case dml::status_code::false_predicate: return "false predicate";
  16. case dml::status_code::partial_completion: return "partial completion";
  17. case dml::status_code::nullptr_error: return "nullptr error";
  18. case dml::status_code::bad_size: return "bad size";
  19. case dml::status_code::bad_length: return "bad length";
  20. case dml::status_code::inconsistent_size: return "inconsistent size";
  21. case dml::status_code::dualcast_bad_padding: return "dualcast bad padding";
  22. case dml::status_code::bad_alignment: return "bad alignment";
  23. case dml::status_code::buffers_overlapping: return "buffers overlapping";
  24. case dml::status_code::delta_delta_empty: return "delta delta empty";
  25. case dml::status_code::batch_overflow: return "batch overflow";
  26. case dml::status_code::execution_failed: return "execution failed";
  27. case dml::status_code::unsupported_operation: return "unsupported operation";
  28. case dml::status_code::queue_busy: return "queue busy";
  29. case dml::status_code::error: return "unknown error";
  30. case dml::status_code::config_error: return "config error";
  31. default: return "unhandled error";
  32. }
  33. }
  34. }
  35. namespace dsacache {
  36. /*
  37. * Class Description:
  38. * Holds all required information on one cache entry and is used
  39. * both internally by the Cache and externally by the user.
  40. *
  41. * Important Usage Notes:
  42. * The pointer is only updated in WaitOnCompletion() which
  43. * therefore must be called by the user at some point in order
  44. * to use the cached data. Using this class as T for
  45. * std::shared_ptr<T> is not recommended as references are
  46. * already counted internally.
  47. *
  48. * Cache Lifetime:
  49. * As long as the instance is referenced, the pointer it stores
  50. * is guaranteed to be either nullptr or pointing to a valid copy.
  51. *
  52. * Implementation Detail:
  53. * Performs self-reference counting with a shared atomic integer.
  54. * Therefore on creating a copy the reference count is increased
  55. * and with the destructor it is deacresed. If the last copy is
  56. * destroyed the actual underlying data is freed and all shared
  57. * variables deleted.
  58. *
  59. * Notes on Thread Safety:
  60. * Class is thread safe in any possible state and performs
  61. * reference counting and deallocation itself entirely atomically.
  62. */
  63. class CacheData {
  64. public:
  65. using dml_handler = dml::handler<dml::mem_copy_operation, std::allocator<uint8_t>>;
  66. private:
  67. // data source and size of the block
  68. uint8_t* src_;
  69. size_t size_;
  70. // global reference counting object
  71. std::atomic<int32_t>* active_;
  72. // global cache-location pointer
  73. std::atomic<uint8_t*>* cache_;
  74. // object-local incomplete cache location pointer
  75. // contract: only access when being in sole posession of handlers
  76. uint8_t* incomplete_cache_;
  77. // dml handler vector pointer which is used
  78. // to wait on caching task completion
  79. std::atomic<std::vector<dml_handler>*>* handlers_;
  80. // deallocates the global cache-location
  81. // and invalidates it
  82. void Deallocate();
  83. public:
  84. CacheData(uint8_t* data, const size_t size);
  85. CacheData(const CacheData& other);
  86. ~CacheData();
  87. // waits on completion of caching operations
  88. // for this task and is safe to be called in
  89. // any state of the object
  90. void WaitOnCompletion();
  91. // returns the cache data location for this
  92. // instance which is valid as long as the
  93. // instance is alive - !!! this may also
  94. // yield a nullptr !!!
  95. void SetTaskHanldersAndCache(uint8_t* cache, std::vector<dml_handler>* handlers);
  96. uint8_t* GetDataLocation() const { return cache_->load(); }
  97. size_t GetSize() const { return size_; }
  98. uint8_t* GetSource() const { return src_; }
  99. int32_t GetRefCount() const { return active_->load(); }
  100. };
  101. /*
  102. * Class Description:
  103. * Class will handle access to data through internal copies.
  104. * These are obtained via work submission to the Intel DSA which takes
  105. * care of asynchronously duplicating the data. The user will define
  106. * where these copies lie and which system nodes will perform the copy.
  107. * This is done through policy functions set during initialization.
  108. *
  109. * Placement Policy:
  110. * The Placement Policy Function decides on which node a particular
  111. * entry is to be placed, given the current executing node and the
  112. * data source node and data size. This in turn means that for one
  113. * datum, multiple cached copies may exist at one time.
  114. *
  115. * Cache Lifetime:
  116. * When accessing the cache, a CacheData-object will be returned.
  117. * As long as this object lives, the pointer which it holds is
  118. * guaranteed to be either nullptr or a valid copy. When destroyed
  119. * the entry is marked for deletion which is only carried out
  120. * when system memory pressure drives an automated cache flush.
  121. *
  122. * Restrictions:
  123. * - Overlapping Pointers may lead to undefined behaviour during
  124. * manual cache invalidation which should not be used if you
  125. * intend to have these types of pointers
  126. * - Cache Invalidation may only be performed manually and gives
  127. * no ordering guarantees. Therefore, it is the users responsibility
  128. * to ensure that results after invalidation have been generated
  129. * using the latest state of data. The cache is best suited
  130. * to static data.
  131. *
  132. * Notes on Thread Safety:
  133. * - Cache is completely thread-safe after initialization
  134. * - CacheData-class will handle deallocation of data itself by
  135. * performing self-reference-counting atomically and only
  136. * deallocating if the last reference is destroyed
  137. * - The internal cache state has one lock which is either
  138. * acquired shared for reading the state (upon accessing an already
  139. * cached element) or unique (accessing a new element, flushing, invalidating)
  140. * - Waiting on copy completion is done over an atomic-wait in copies
  141. * of the original CacheData-instance
  142. * - Overall this class may experience performance issues due to the use
  143. * of locking (in any configuration), lock contention (worsens with higher
  144. * core count, node count and utilization) and atomics (worse in the same
  145. * situations as lock contention)
  146. *
  147. * Improving Performance:
  148. * When data is never shared between threads or memory size for the cache is
  149. * not an issue you may consider having one Cache-instance per thread and removing
  150. * the lock in Cache and modifying the reference counting and waiting mechanisms
  151. * of CacheData accordingly (although this is high effort and will yield little due
  152. * to the atomics not being shared among cores/nodes).
  153. * Otherwise, one Cache-instance per node could also be considered. This will allow
  154. * the placement policy function to be barebones and reduces the lock contention and
  155. * synchronization impact of the atomic variables.
  156. */
  157. class Cache {
  158. public:
  159. // cache policy is defined as a type here to allow flexible usage of the cacher
  160. // given a numa destination node (where the data will be needed), the numa source
  161. // node (current location of the data) and the data size, this function should
  162. // return optimal cache placement
  163. // dst node and returned value can differ if the system, for example, has HBM
  164. // attached accessible directly to node n under a different node id m
  165. typedef int (CachePolicy)(const int numa_dst_node, const int numa_src_node, const size_t data_size);
  166. // copy policy specifies the copy-executing nodes for a given task
  167. // which allows flexibility in assignment for optimizing raw throughput
  168. // or choosing a conservative usage policy
  169. typedef std::vector<int> (CopyPolicy)(const int numa_dst_node, const int numa_src_node, const size_t data_size);
  170. private:
  171. // mutex for accessing the cache state map
  172. // map from [dst-numa-node,map2]
  173. // map2 from [data-ptr,cache-structure]
  174. struct LockedNodeCacheState {
  175. std::shared_mutex cache_mutex_;
  176. std::unordered_map<uint8_t*, CacheData> node_cache_state_;
  177. };
  178. std::unordered_map<uint8_t, LockedNodeCacheState*> cache_state_;
  179. CachePolicy* cache_policy_function_ = nullptr;
  180. CopyPolicy* copy_policy_function_ = nullptr;
  181. // function used to submit a copy task on a specific node to the dml
  182. // engine on that node - will change the current threads node assignment
  183. // to achieve this so take care to restore this
  184. dml::handler<dml::mem_copy_operation, std::allocator<uint8_t>> ExecuteCopy(
  185. const uint8_t* src, uint8_t* dst, const size_t size, const int node
  186. ) const;
  187. // allocates the required memory on the destination node
  188. // and then submits task to the dml library for processing
  189. // and attaches the handlers to the cache data structure
  190. void SubmitTask(CacheData* task, const int dst_node, const int src_node);
  191. // querries the policy functions for the given data and size
  192. // to obtain destination cache node, also returns the datas
  193. // source node for further usage
  194. // output may depend on the calling threads node assignment
  195. // as this is set as the "optimal placement" node
  196. void GetCacheNode(uint8_t* src, const size_t size, int* OUT_DST_NODE, int* OUT_SRC_NODE) const;
  197. // allocates memory of size "size" on the numa node "node"
  198. // and returns nullptr if this is not possible, also may
  199. // try to flush the cache of the requested node to
  200. // alleviate encountered shortage
  201. uint8_t* AllocOnNode(const size_t size, const int node);
  202. // checks whether the cache contains an entry for
  203. // the given data in the given memory node and
  204. // returns it, otherwise returns nullptr
  205. std::unique_ptr<CacheData> GetFromCache(uint8_t* src, const size_t size, const int dst_node);
  206. public:
  207. ~Cache();
  208. Cache() = default;
  209. Cache(const Cache& other) = delete;
  210. // initializes the cache with the two policy functions
  211. // only after this is it safe to use in a threaded environment
  212. void Init(CachePolicy* cache_policy_function, CopyPolicy* copy_policy_function);
  213. // function to perform data access through the cache
  214. std::unique_ptr<CacheData> Access(uint8_t* data, const size_t size);
  215. // flushes the cache of inactive entries
  216. // if node is -1 then the whole cache is
  217. // checked and otherwise the specified
  218. // node - no checks on node validity
  219. void Flush(const int node = -1);
  220. // forces out all entries from the
  221. // cache and therefore will also "forget"
  222. // still-in-use entries, these will still
  223. // be properly deleted, but the cache
  224. // will be fresh - use for testing
  225. void Clear();
  226. void Invalidate(uint8_t* data);
  227. };
  228. }
  229. inline void dsacache::Cache::Clear() {
  230. for (auto& nc : cache_state_) {
  231. std::unique_lock<std::shared_mutex> lock(nc.second->cache_mutex_);
  232. nc.second->node_cache_state_.clear();
  233. }
  234. }
  235. inline void dsacache::Cache::Init(CachePolicy* cache_policy_function, CopyPolicy* copy_policy_function) {
  236. cache_policy_function_ = cache_policy_function;
  237. copy_policy_function_ = copy_policy_function;
  238. // initialize numa library
  239. numa_available();
  240. // obtain all available nodes
  241. // and those we may allocate
  242. // memory on
  243. const int nodes_max = numa_num_configured_nodes();
  244. const bitmask* valid_nodes = numa_get_mems_allowed();
  245. // prepare the cache state with entries
  246. // for all given nodes
  247. for (int node = 0; node < nodes_max; node++) {
  248. if (numa_bitmask_isbitset(valid_nodes, node)) {
  249. void* block = numa_alloc_onnode(sizeof(LockedNodeCacheState), node);
  250. auto* state = new(block)LockedNodeCacheState;
  251. cache_state_.insert({node,state});
  252. }
  253. }
  254. }
  255. inline std::unique_ptr<dsacache::CacheData> dsacache::Cache::Access(uint8_t* data, const size_t size) {
  256. // get destination numa node for the cache
  257. int dst_node = -1;
  258. int src_node = -1;
  259. GetCacheNode(data, size, &dst_node, &src_node);
  260. // TODO: at this point it could be beneficial to check whether
  261. // TODO: the given destination node is present as an entry
  262. // TODO: in the cache state to see if it is valid
  263. // check whether the data is already cached
  264. std::unique_ptr<CacheData> task = GetFromCache(data, size, dst_node);
  265. if (task != nullptr) {
  266. return std::move(task);
  267. }
  268. // at this point the requested data is not present in cache
  269. // and we create a caching task for it
  270. task = std::make_unique<CacheData>(data, size);
  271. {
  272. LockedNodeCacheState* local_cache_state = cache_state_[dst_node];
  273. std::unique_lock<std::shared_mutex> lock(local_cache_state->cache_mutex_);
  274. const auto state = local_cache_state->node_cache_state_.emplace(task->GetSource(), *task);
  275. // if state.second is false then no insertion took place
  276. // which means that concurrently whith this thread
  277. // some other thread must have accessed the same
  278. // resource in which case we return the other
  279. // threads data cache structure
  280. if (!state.second) {
  281. std::cout << "[!] Found another cache instance for 0x" << std::hex << (uint64_t)task->GetSource() << std::dec << std::endl;
  282. return std::move(std::make_unique<CacheData>(state.first->second));
  283. }
  284. }
  285. SubmitTask(task.get(), dst_node, src_node);
  286. return std::move(task);
  287. }
  288. inline uint8_t* dsacache::Cache::AllocOnNode(const size_t size, const int node) {
  289. // allocate data on this node and flush the unused parts of the
  290. // cache if the operation fails and retry once
  291. // TODO: smarter flush strategy could keep some stuff cached
  292. // check currently free memory to see if the data fits
  293. long long int free_space = 0;
  294. numa_node_size64(node, &free_space);
  295. if (free_space < size) {
  296. std::cout << "[!] Memory shortage when allocating " << size << "B on node " << node << std::endl;
  297. // dst node lacks memory space so we flush the cache for this
  298. // node hoping to free enough currently unused entries to make
  299. // the second allocation attempt successful
  300. Flush(node);
  301. // re-test by getting the free space and checking again
  302. numa_node_size64(node, &free_space);
  303. if (free_space < size) {
  304. std::cout << "[x] Memory shortage after flush when allocating " << size << "B on node " << node << std::endl;
  305. return nullptr;
  306. }
  307. }
  308. uint8_t* dst = reinterpret_cast<uint8_t*>(numa_alloc_onnode(size, node));
  309. if (dst == nullptr) {
  310. std::cout << "[x] Allocation try failed for " << size << "B on node " << node << std::endl;
  311. return nullptr;
  312. }
  313. return dst;
  314. }
  315. inline void dsacache::Cache::SubmitTask(CacheData* task, const int dst_node, const int src_node) {
  316. uint8_t* dst = AllocOnNode(task->GetSize(), dst_node);
  317. if (dst == nullptr) {
  318. std::cout << "[x] Allocation failed so we can not cache" << std::endl;
  319. return;
  320. }
  321. // querry copy policy function for the nodes to use for the copy
  322. const std::vector<int> executing_nodes = copy_policy_function_(dst_node, src_node, task->GetSize());
  323. const size_t task_count = executing_nodes.size();
  324. // each task will copy one fair part of the total size
  325. // and in case the total size is not a factor of the
  326. // given task count the last node must copy the remainder
  327. const size_t size = task->GetSize() / task_count;
  328. const size_t last_size = size + task->GetSize() % task_count;
  329. // save the current numa node mask to restore later
  330. // as executing the copy task will place this thread
  331. // on a different node
  332. bitmask* nodemask = numa_get_run_node_mask();
  333. auto handlers = new std::vector<CacheData::dml_handler>();
  334. for (uint32_t i = 0; i < task_count; i++) {
  335. const size_t local_size = i + 1 == task_count ? size : last_size;
  336. const size_t local_offset = i * size;
  337. const uint8_t* local_src = task->GetSource() + local_offset;
  338. uint8_t* local_dst = dst + local_offset;
  339. handlers->emplace_back(ExecuteCopy(local_src, local_dst, local_size, executing_nodes[i]));
  340. }
  341. task->SetTaskHanldersAndCache(dst, handlers);
  342. // restore the previous nodemask
  343. numa_run_on_node_mask(nodemask);
  344. numa_free_nodemask(nodemask);
  345. }
  346. inline dml::handler<dml::mem_copy_operation, std::allocator<uint8_t>> dsacache::Cache::ExecuteCopy(
  347. const uint8_t* src, uint8_t* dst, const size_t size, const int node
  348. ) const {
  349. dml::const_data_view srcv = dml::make_view(src, size);
  350. dml::data_view dstv = dml::make_view(dst, size);
  351. numa_run_on_node(node);
  352. return dml::submit<dml::automatic>(dml::mem_copy.block_on_fault(), srcv, dstv);
  353. }
  354. inline void dsacache::Cache::GetCacheNode(uint8_t* src, const size_t size, int* OUT_DST_NODE, int* OUT_SRC_NODE) const {
  355. // obtain numa node of current thread to determine where the data is needed
  356. const int current_cpu = sched_getcpu();
  357. const int current_node = numa_node_of_cpu(current_cpu);
  358. // obtain node that the given data pointer is allocated on
  359. *OUT_SRC_NODE = -1;
  360. get_mempolicy(OUT_SRC_NODE, NULL, 0, (void*)src, MPOL_F_NODE | MPOL_F_ADDR);
  361. // querry cache policy function for the destination numa node
  362. *OUT_DST_NODE = cache_policy_function_(current_node, *OUT_SRC_NODE, size);
  363. }
  364. inline void dsacache::Cache::Flush(const int node) {
  365. // this lambda is used because below we have two code paths that
  366. // flush nodes, either one single or all successively
  367. const auto FlushNode = [](std::unordered_map<uint8_t*,CacheData>& map) {
  368. // begin at the front of the map
  369. auto it = map.begin();
  370. // loop until we reach the end of the map
  371. while (it != map.end()) {
  372. // if the iterator points to an inactive element
  373. // then we may erase it
  374. if (it->second.GetRefCount() <= 1) {
  375. // erase the iterator from the map
  376. map.erase(it);
  377. // as the erasure invalidated out iterator
  378. // we must start at the beginning again
  379. it = map.begin();
  380. }
  381. else {
  382. // if element is active just move over to the next one
  383. it++;
  384. }
  385. }
  386. };
  387. // we require exclusive lock as we modify the cache state
  388. // node == -1 means that cache on all nodes should be flushed
  389. if (node == -1) {
  390. for (auto& nc : cache_state_) {
  391. std::unique_lock<std::shared_mutex> lock(nc.second->cache_mutex_);
  392. FlushNode(nc.second->node_cache_state_);
  393. }
  394. }
  395. else {
  396. std::unique_lock<std::shared_mutex> lock(cache_state_[node]->cache_mutex_);
  397. FlushNode(cache_state_[node]->node_cache_state_);
  398. }
  399. }
  400. inline std::unique_ptr<dsacache::CacheData> dsacache::Cache::GetFromCache(uint8_t* src, const size_t size, const int dst_node) {
  401. // the best situation is if this data is already cached
  402. // which we check in an unnamed block in which the cache
  403. // is locked for reading to prevent another thread
  404. // from marking the element we may find as unused and
  405. // clearing it
  406. LockedNodeCacheState* local_cache_state = cache_state_[dst_node];
  407. // lock the cache state in shared-mode because we read
  408. std::shared_lock<std::shared_mutex> lock(local_cache_state->cache_mutex_);
  409. // search for the data in our cache state structure at the given node
  410. const auto search = local_cache_state->node_cache_state_.find(src);
  411. // if the data is in our structure we continue
  412. if (search != local_cache_state->node_cache_state_.end()) {
  413. // now check whether the sizes match
  414. if (search->second.GetSize() >= size) {
  415. // return a unique copy of the entry which uses the object
  416. // lifetime and destructor to safely handle deallocation
  417. return std::move(std::make_unique<CacheData>(search->second));
  418. }
  419. else {
  420. // if the sizes missmatch then we clear the current entry from cache
  421. // which will cause its deletion only after the last possible outside
  422. // reference is also destroyed
  423. local_cache_state->node_cache_state_.erase(search);
  424. }
  425. }
  426. return nullptr;
  427. }
  428. void dsacache::Cache::Invalidate(uint8_t* data) {
  429. // as the cache is modified we must obtain a unique writers lock
  430. // loop through all per-node-caches available
  431. for (auto node : cache_state_) {
  432. std::unique_lock<std::shared_mutex> lock(node.second->cache_mutex_);
  433. // search for an entry for the given data pointer
  434. auto search = node.second->node_cache_state_.find(data);
  435. if (search != node.second->node_cache_state_.end()) {
  436. // if the data is represented in-cache
  437. // then it will be erased to re-trigger
  438. // caching on next access
  439. node.second->node_cache_state_.erase(search);
  440. }
  441. }
  442. }
  443. inline dsacache::Cache::~Cache() {
  444. for (auto node : cache_state_) {
  445. node.second->~LockedNodeCacheState();
  446. numa_free(reinterpret_cast<void*>(node.second), sizeof(LockedNodeCacheState));
  447. }
  448. }
  449. inline dsacache::CacheData::CacheData(uint8_t* data, const size_t size) {
  450. src_ = data;
  451. size_ = size;
  452. active_ = new std::atomic<int32_t>(1);
  453. cache_ = new std::atomic<uint8_t*>();
  454. handlers_ = new std::atomic<std::vector<dml_handler>*>();
  455. incomplete_cache_ = nullptr;
  456. }
  457. inline dsacache::CacheData::CacheData(const dsacache::CacheData& other) {
  458. // we copy the ptr to the global atomic reference counter
  459. // and increase the amount of active references
  460. active_ = other.active_;
  461. const int current_active = active_->fetch_add(1);
  462. src_ = other.src_;
  463. size_ = other.size_;
  464. cache_ = other.cache_;
  465. incomplete_cache_ = other.incomplete_cache_;
  466. handlers_ = other.handlers_;
  467. }
  468. inline dsacache::CacheData::~CacheData() {
  469. // due to fetch_sub returning the preivously held value
  470. // we must subtract one locally to get the current value
  471. const int32_t v = active_->fetch_sub(1) - 1;
  472. // if the returned value is zero or lower
  473. // then we must execute proper deletion
  474. // as this was the last reference
  475. if (v <= 0) {
  476. // on deletion we must ensure that all offloaded
  477. // operations have completed successfully
  478. WaitOnCompletion();
  479. // only then can we deallocate the memory
  480. Deallocate();
  481. delete active_;
  482. delete cache_;
  483. delete handlers_;
  484. }
  485. }
  486. inline void dsacache::CacheData::Deallocate() {
  487. // although deallocate should only be called from
  488. // a safe context to do so, it can not hurt to
  489. // defensively perform the operation atomically
  490. // and check for incomplete cache if no deallocation
  491. // takes place for the retrieved local cache
  492. uint8_t* cache_local = cache_->exchange(nullptr);
  493. if (cache_local != nullptr) numa_free(cache_local, size_);
  494. else if (incomplete_cache_ != nullptr) numa_free(incomplete_cache_, size_);
  495. else;
  496. }
  497. inline void dsacache::CacheData::WaitOnCompletion() {
  498. // first check if waiting is even neccessary as a valid
  499. // cache pointer signals that no waiting is to be performed
  500. if (cache_->load() != nullptr) {
  501. return;
  502. }
  503. // then check if the handlers are available
  504. handlers_->wait(nullptr);
  505. // exchange the global handlers pointer with nullptr to have a local
  506. // copy - this signals that this thread is the sole owner and therefore
  507. // responsible for waiting for them
  508. std::vector<dml_handler>* local_handlers = handlers_->exchange(nullptr);
  509. // ensure that no other thread snatched the handlers before us
  510. // and in case one did, wait again and then return
  511. if (local_handlers == nullptr) {
  512. WaitOnCompletion();
  513. return;
  514. }
  515. // at this point we are responsible for waiting for the handlers
  516. // and handling any error that comes through them gracefully
  517. bool error = false;
  518. for (auto& handler : *local_handlers) {
  519. auto result = handler.get();
  520. if (result.status != dml::status_code::ok) {
  521. std::cerr << "[x] Encountered bad status code for operation: " << dml::StatusCodeToString(result.status) << std::endl;
  522. // if one of the copy tasks failed we abort the whole task
  523. // after all operations are completed on it
  524. error = true;
  525. }
  526. }
  527. // at this point all handlers have been waited for
  528. // and therefore may be decomissioned
  529. delete local_handlers;
  530. // handle errors now by aborting the cache
  531. if (error) {
  532. cache_->store(nullptr);
  533. numa_free(incomplete_cache_, size_);
  534. }
  535. else {
  536. cache_->store(incomplete_cache_);
  537. }
  538. // notify all waiting threads so they wake up quickly
  539. cache_->notify_all();
  540. handlers_->notify_all();
  541. }
  542. void dsacache::CacheData::SetTaskHanldersAndCache(uint8_t* cache, std::vector<dml_handler>* handlers) {
  543. incomplete_cache_ = cache;
  544. handlers_->store(handlers);
  545. handlers_->notify_one();
  546. }