1 // ------------------------------------------------------------- 2 // cuDPP -- CUDA Data Parallel Primitives library 3 // ------------------------------------------------------------- 4 // $Revision: 3572$ 5 // $Date$ 6 // ------------------------------------------------------------- 7 // This source code is distributed under the terms of license.txt 8 // in the root directory of this source distribution. 9 // ------------------------------------------------------------- 10 #ifndef __CUDPP_PLAN_MANAGER_H__ 11 #define __CUDPP_PLAN_MANAGER_H__ 12 13 #include <map> 14 15 class CUDPPPlan; 16 typedef void* KernelPointer; 17 18 /** @brief Singleton manager class for CUDPPPlan objects 19 * 20 * This class manages all active plans in CUDPP. It is a singleton class, 21 * meaning that only one instance can exist. It is created automatically the 22 * first time AddPlan() is called, and destroyed when the last plan is removed 23 * using RemovePlan(). 24 */ 25 class CUDPPPlanManager 26 { 27 public: 28 static CUDPPHandle AddPlan(CUDPPPlan* plan); 29 static bool RemovePlan(CUDPPHandle handle); 30 static CUDPPPlan* GetPlan(CUDPPHandle handle); 31 32 static size_t numCTAs(KernelPointer kernel); 33 static void computeNumCTAs(KernelPointer kernel, 34 size_t bytesDynamicSharedMem, 35 size_t threadsPerBlock); 36 37 protected: 38 static CUDPPPlanManager* m_instance; 39 std::map<CUDPPHandle, CUDPPPlan*> plans; 40 std::map<void*, size_t> numCTAsTable; 41 42 private: 43 44 45 //! @internal Instantiate the plan manager singleton object 46 static void Instantiate(); 47 //! @internal Destroy the plan manager singleton object 48 static void Destroy(); 49 50 private: CUDPPPlanManager()51 CUDPPPlanManager() {} CUDPPPlanManager(const CUDPPPlanManager &)52 CUDPPPlanManager(const CUDPPPlanManager&) {} 53 ~CUDPPPlanManager(); 54 }; 55 56 #endif // __CUDPP_PLAN_MANAGER_H__ 57