2015-12-19 21:35:35 -05:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
2015-04-29 15:50:57 -04:00
|
|
|
#ifndef ISAAC_CL_QUEUES_H
|
|
|
|
#define ISAAC_CL_QUEUES_H
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <list>
|
2015-07-31 00:41:03 -07:00
|
|
|
#include <vector>
|
2015-04-29 15:50:57 -04:00
|
|
|
|
2015-08-06 12:05:12 -07:00
|
|
|
#include "isaac/common/expression_type.h"
|
|
|
|
#include "isaac/common/numeric_type.h"
|
|
|
|
|
2015-08-25 12:41:21 -04:00
|
|
|
#include "isaac/driver/dispatch.h"
|
2015-07-21 22:02:36 -07:00
|
|
|
#include "isaac/defines.h"
|
2015-08-04 10:53:39 -07:00
|
|
|
#include "isaac/types.h"
|
2015-04-29 15:50:57 -04:00
|
|
|
|
|
|
|
namespace isaac
|
|
|
|
{
|
|
|
|
namespace driver
|
|
|
|
{
|
|
|
|
|
2015-11-27 18:43:46 -05:00
|
|
|
class Buffer;
|
2015-07-31 00:41:03 -07:00
|
|
|
class CommandQueue;
|
2015-08-03 11:13:31 -07:00
|
|
|
class Context;
|
|
|
|
class Platform;
|
2015-08-04 11:11:38 -07:00
|
|
|
class ProgramCache;
|
2015-07-31 00:41:03 -07:00
|
|
|
|
2015-07-30 21:02:30 -07:00
|
|
|
class ISAACAPI backend
|
2015-04-29 15:50:57 -04:00
|
|
|
{
|
|
|
|
public:
|
2015-11-27 18:43:46 -05:00
|
|
|
class ISAACAPI workspaces
|
|
|
|
{
|
|
|
|
public:
|
2015-12-18 00:38:11 -05:00
|
|
|
static const size_t SIZE = 8000000; //8MB of temporary workspace per queue
|
2015-11-27 18:43:46 -05:00
|
|
|
static void release();
|
|
|
|
static driver::Buffer & get(CommandQueue const & key);
|
|
|
|
private:
|
|
|
|
DISABLE_MSVC_WARNING_C4251
|
|
|
|
static std::map<CommandQueue, Buffer * > cache_;
|
|
|
|
RESTORE_MSVC_WARNING_C4251
|
|
|
|
};
|
|
|
|
|
2015-08-05 12:07:51 -07:00
|
|
|
class ISAACAPI programs
|
2015-07-31 15:47:41 -07:00
|
|
|
{
|
2015-08-03 17:37:19 -07:00
|
|
|
friend class backend;
|
2015-07-31 15:47:41 -07:00
|
|
|
public:
|
2015-08-04 00:53:52 -07:00
|
|
|
static void release();
|
2015-08-04 10:53:39 -07:00
|
|
|
static ProgramCache & get(CommandQueue const & queue, expression_type expression, numeric_type dtype);
|
2015-07-31 15:47:41 -07:00
|
|
|
private:
|
2015-08-05 11:13:49 -07:00
|
|
|
DISABLE_MSVC_WARNING_C4251
|
2015-08-04 10:53:39 -07:00
|
|
|
static std::map<std::tuple<CommandQueue, expression_type, numeric_type>, ProgramCache * > cache_;
|
2015-08-05 11:13:49 -07:00
|
|
|
RESTORE_MSVC_WARNING_C4251
|
|
|
|
|
2015-07-31 15:47:41 -07:00
|
|
|
};
|
|
|
|
|
2015-08-05 12:07:51 -07:00
|
|
|
class ISAACAPI contexts
|
2015-08-03 16:05:57 -07:00
|
|
|
{
|
|
|
|
friend class backend;
|
2015-08-03 20:20:27 -07:00
|
|
|
private:
|
|
|
|
static void init(std::vector<Platform> const &);
|
|
|
|
static void release();
|
2015-08-03 16:05:57 -07:00
|
|
|
public:
|
|
|
|
static Context const & get_default();
|
2015-11-21 13:57:05 -05:00
|
|
|
static Context const & import(CUcontext context);
|
2015-08-03 16:05:57 -07:00
|
|
|
static Context const & import(cl_context context);
|
|
|
|
static void get(std::list<Context const *> &);
|
|
|
|
private:
|
2015-08-05 11:13:49 -07:00
|
|
|
DISABLE_MSVC_WARNING_C4251
|
2015-08-03 20:20:27 -07:00
|
|
|
static std::list<Context const *> cache_;
|
2015-08-05 11:13:49 -07:00
|
|
|
RESTORE_MSVC_WARNING_C4251
|
2015-08-03 16:05:57 -07:00
|
|
|
};
|
|
|
|
|
2015-08-05 12:07:51 -07:00
|
|
|
class ISAACAPI queues
|
2015-08-03 16:05:57 -07:00
|
|
|
{
|
|
|
|
friend class backend;
|
2015-08-03 20:20:27 -07:00
|
|
|
private:
|
|
|
|
static void init(std::list<Context const *> const &);
|
|
|
|
static void release();
|
2015-08-03 16:05:57 -07:00
|
|
|
public:
|
2015-08-03 20:20:27 -07:00
|
|
|
static void get(Context const &, std::vector<CommandQueue *> &queues);
|
2015-09-30 15:31:41 -04:00
|
|
|
static CommandQueue & get(Context const &, unsigned int id = 0);
|
2015-08-03 16:05:57 -07:00
|
|
|
private:
|
2015-08-05 11:13:49 -07:00
|
|
|
DISABLE_MSVC_WARNING_C4251
|
2015-08-03 20:20:27 -07:00
|
|
|
static std::map< Context, std::vector<CommandQueue*> > cache_;
|
2015-08-05 11:13:49 -07:00
|
|
|
RESTORE_MSVC_WARNING_C4251
|
2015-08-03 16:05:57 -07:00
|
|
|
};
|
|
|
|
|
2015-08-03 20:20:27 -07:00
|
|
|
static void init();
|
2015-07-31 15:47:41 -07:00
|
|
|
static void release();
|
2015-08-03 16:05:57 -07:00
|
|
|
|
2015-08-03 20:20:27 -07:00
|
|
|
static void platforms(std::vector<Platform> &);
|
|
|
|
static void synchronize(Context const &);
|
2015-08-03 16:05:57 -07:00
|
|
|
|
2015-04-29 15:50:57 -04:00
|
|
|
public:
|
2015-07-30 21:02:30 -07:00
|
|
|
static unsigned int default_device;
|
2015-08-12 00:46:51 -07:00
|
|
|
static cl_command_queue_properties default_queue_properties;
|
2015-04-29 15:50:57 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|