Sierra Toolkit  Version of the Day
CudaMemoryMgr.cpp
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 #include <stk_algsup/CudaMemoryMgr.hpp>
10 
11 namespace stk_classic {
12 
13 #ifdef STK_HAVE_CUDA
14 
15 CudaMemoryMgr& get_singleton()
16 {
17  static CudaMemoryMgr cuda_memory_mgr;
18  return cuda_memory_mgr;
19 }
20 
21 #endif
22 
24 {
25 #ifdef STK_HAVE_CUDA
26  std::map<const void*,const void*>::iterator
27  iter = device_to_host_map.begin(),
28  iter_end = device_to_host_map.end();
29 
30  for(; iter!=iter_end; ++iter) {
31  //cast away const so we can free the pointer:
32  void* dev_ptr = const_cast<void*>(iter->first);
33  CUDA_CALL( cudaFree(dev_ptr) );
34  }
35 #endif
36 }
37 
38 }//namespace stk_classic
39 
Sierra Toolkit.