/* * Copyright (c) 2015, PHILIPPE TILLET. All rights reserved. * * This file is part of ISAAC. * * ISAAC is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #ifndef ISAAC_CL_QUEUES_H #define ISAAC_CL_QUEUES_H #include #include #include #include "isaac/common/expression_type.h" #include "isaac/common/numeric_type.h" #include "isaac/driver/dispatch.h" #include "isaac/defines.h" #include "isaac/types.h" namespace isaac { namespace driver { class Buffer; class CommandQueue; class Context; class Platform; class Program; class Kernel; class ProgramCache; class ISAACAPI backend { public: class ISAACAPI workspaces { public: static const size_t SIZE = 8000000; //8MB of temporary workspace per queue static void release(); static driver::Buffer & get(CommandQueue const & key); private: DISABLE_MSVC_WARNING_C4251 static std::map cache_; RESTORE_MSVC_WARNING_C4251 }; class ISAACAPI programs { friend class backend; public: static void release(); static ProgramCache & get(CommandQueue const & queue, expression_type expression, numeric_type dtype); private: DISABLE_MSVC_WARNING_C4251 static std::map, ProgramCache * > cache_; RESTORE_MSVC_WARNING_C4251 }; class ISAACAPI kernels { friend class backend; public: static void release(); static Kernel & get(Program const & program, std::string const & name); private: DISABLE_MSVC_WARNING_C4251 static std::map, Kernel * > cache_; RESTORE_MSVC_WARNING_C4251 }; class ISAACAPI contexts { friend class backend; private: static void init(std::vector const &); static void release(); public: static Context const & get_default(); static Context const & import(CUcontext context); static Context const & import(cl_context context); static void get(std::list &); private: DISABLE_MSVC_WARNING_C4251 static std::list cache_; RESTORE_MSVC_WARNING_C4251 }; class ISAACAPI queues { friend class backend; private: static void init(std::list const &); static void release(); public: static void get(Context const &, std::vector &queues); static CommandQueue & get(Context const &, unsigned int id = 0); private: DISABLE_MSVC_WARNING_C4251 static std::map< Context, std::vector > cache_; RESTORE_MSVC_WARNING_C4251 }; static void init(); static void release(); static void platforms(std::vector &); static void synchronize(Context const &); public: static unsigned int default_device; static cl_command_queue_properties default_queue_properties; }; } } #endif