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-12-21 17:04:09 -05:00
|
|
|
|
2015-04-29 15:50:57 -04:00
|
|
|
#ifndef ISAAC_BACKEND_BINDER_H
|
|
|
|
#define ISAAC_BACKEND_BINDER_H
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include "isaac/driver/buffer.h"
|
2016-04-02 18:19:33 -04:00
|
|
|
#include "isaac/symbolic/expression/expression.h"
|
2015-04-29 15:50:57 -04:00
|
|
|
|
|
|
|
namespace isaac
|
|
|
|
{
|
|
|
|
|
2016-04-02 18:19:33 -04:00
|
|
|
class array_base;
|
|
|
|
|
|
|
|
|
|
|
|
enum fusion_policy_t
|
2015-04-29 15:50:57 -04:00
|
|
|
{
|
2016-04-02 18:19:33 -04:00
|
|
|
FUSE_INDEPENDENT,
|
|
|
|
FUSE_SEQUENTIAL
|
2015-04-29 15:50:57 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class symbolic_binder
|
|
|
|
{
|
2016-04-02 18:19:33 -04:00
|
|
|
class cmp
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmp(driver::backend_type backend) : backend_(backend) {}
|
|
|
|
|
|
|
|
bool operator()(handle_t const & x, handle_t const & y) const
|
|
|
|
{
|
|
|
|
if(backend_==driver::OPENCL)
|
|
|
|
return x.cl < y.cl;
|
|
|
|
else
|
|
|
|
return x.cu < y.cu;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
driver::backend_type backend_;
|
|
|
|
};
|
|
|
|
|
2015-04-29 15:50:57 -04:00
|
|
|
public:
|
2016-04-02 18:19:33 -04:00
|
|
|
symbolic_binder(driver::backend_type backend);
|
2015-04-29 15:50:57 -04:00
|
|
|
virtual ~symbolic_binder();
|
2016-04-02 18:19:33 -04:00
|
|
|
virtual bool bind(handle_t const &, bool) = 0;
|
|
|
|
virtual unsigned int get(handle_t const &, bool) = 0;
|
2015-08-21 13:06:20 -04:00
|
|
|
unsigned int get();
|
2015-04-29 15:50:57 -04:00
|
|
|
protected:
|
|
|
|
unsigned int current_arg_;
|
2016-04-02 18:19:33 -04:00
|
|
|
std::map<handle_t,unsigned int, cmp> memory;
|
2015-04-29 15:50:57 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-09-30 15:31:41 -04:00
|
|
|
class bind_sequential : public symbolic_binder
|
2015-04-29 15:50:57 -04:00
|
|
|
{
|
|
|
|
public:
|
2016-04-02 18:19:33 -04:00
|
|
|
bind_sequential(driver::backend_type backend);
|
|
|
|
bool bind(handle_t const & a, bool);
|
|
|
|
unsigned int get(handle_t const & a, bool);
|
2015-04-29 15:50:57 -04:00
|
|
|
};
|
|
|
|
|
2015-09-30 15:31:41 -04:00
|
|
|
class bind_independent : public symbolic_binder
|
2015-04-29 15:50:57 -04:00
|
|
|
{
|
|
|
|
public:
|
2016-04-02 18:19:33 -04:00
|
|
|
bind_independent(driver::backend_type backend);
|
|
|
|
bool bind(handle_t const & a, bool);
|
|
|
|
unsigned int get(const handle_t &a, bool);
|
2015-04-29 15:50:57 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|