|
Sierra Toolkit
Version of the Day
|
00001 /*------------------------------------------------------------------------*/ 00002 /* Copyright 2010 Sandia Corporation. */ 00003 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ 00004 /* license for use of this work by or on behalf of the U.S. Government. */ 00005 /* Export of this program may require a license from the */ 00006 /* United States Government. */ 00007 /*------------------------------------------------------------------------*/ 00008 00009 #include <stk_algsup/CudaMemoryMgr.hpp> 00010 00011 namespace stk_classic { 00012 00013 #ifdef STK_HAVE_CUDA 00014 00015 CudaMemoryMgr& get_singleton() 00016 { 00017 static CudaMemoryMgr cuda_memory_mgr; 00018 return cuda_memory_mgr; 00019 } 00020 00021 #endif 00022 00023 CudaMemoryMgr::~CudaMemoryMgr() 00024 { 00025 #ifdef STK_HAVE_CUDA 00026 std::map<const void*,const void*>::iterator 00027 iter = device_to_host_map.begin(), 00028 iter_end = device_to_host_map.end(); 00029 00030 for(; iter!=iter_end; ++iter) { 00031 //cast away const so we can free the pointer: 00032 void* dev_ptr = const_cast<void*>(iter->first); 00033 CUDA_CALL( cudaFree(dev_ptr) ); 00034 } 00035 #endif 00036 } 00037 00038 }//namespace stk_classic 00039