C: Some fixes in BLAS

This commit is contained in:
Philippe Tillet
2015-06-26 08:08:22 -07:00
parent b0cd25ac4b
commit e6cecc5a09
6 changed files with 19 additions and 2 deletions

View File

@@ -23,6 +23,7 @@ public:
bool operator<(Buffer const &) const;
bool operator==(Buffer const &) const;
HANDLE_TYPE(cl::Buffer, CUdeviceptr)& handle();
HANDLE_TYPE(cl::Buffer, CUdeviceptr) const & handle() const;
private:
backend_type backend_;
Context context_;

View File

@@ -36,6 +36,9 @@ bool Buffer::operator<(Buffer const & other) const
HANDLE_TYPE(cl::Buffer, CUdeviceptr) & Buffer::handle()
{ return h_; }
HANDLE_TYPE(cl::Buffer, CUdeviceptr) const & Buffer::handle() const
{ return h_; }
}
}

View File

@@ -17,13 +17,13 @@ namespace driver
Program::Program(Context const & context, std::string const & source) : backend_(context.backend_), context_(context), source_(source), h_(backend_)
{
// std::cout << source << std::endl;
std::string cache_path = context.cache_path_;
switch(backend_)
{
#ifdef ISAAC_WITH_CUDA
case CUDA:
{
// std::cout << source << std::endl;
std::string prefix = context_.device_.name() + "cuda";
std::string sha1 = tools::sha1(prefix + source);

View File

@@ -161,7 +161,7 @@ extern "C"
is::array x(N, TYPE_ISAAC, cl::Buffer(mx), offx, incx);\
clRetainMemObject(mx);\
\
is::array y(N, TYPE_ISAAC, cl::Buffer(my), offy, incy);\
is::array y(M, TYPE_ISAAC, cl::Buffer(my), offy, incy);\
clRetainMemObject(my);\
\
is::driver::Context const & context = A.context();\

View File

@@ -10,6 +10,7 @@ template<class T> struct BLAS;
template<> struct BLAS<float> { template<class FT, class DT> static FT F(FT SAXPY, DT ) { return SAXPY; } };
template<> struct BLAS<double> { template<class FT, class DT> static DT F(FT , DT DAXPY) { return DAXPY; } };
#define CHANDLE(X) (*X.data().handle().cl)()
/*------ Simple Vector ---------*/
template<class T>
class simple_vector_base

View File

@@ -1,6 +1,7 @@
#include <cmath>
#include "common.hpp"
#include "isaac/array.h"
#include "isaac/wrap/clBLAS.h"
namespace ad = isaac;
@@ -17,6 +18,9 @@ void test_row_wise_reduction(T epsilon, simple_vector_base<T> & cy, simple_matri
simple_vector<T> bufy(M);
simple_vector<T> bufx(N);
ad::driver::CommandQueue queue = ad::driver::queues[y.context()][0];
cl_command_queue clqueue = (*queue.handle().cl)();
T yi = 0, xi = 0;
#define TEST_OPERATION(NAME, SIZE1, SIZE2, REDUCTION, ASSIGNMENT, GPU_REDUCTION, RES, BUF, CRES)\
std::cout << NAME "..." << std::flush;\
@@ -38,6 +42,14 @@ void test_row_wise_reduction(T epsilon, simple_vector_base<T> & cy, simple_matri
else\
std::cout << std::endl;
ad::int_t offA = A.start()[0] + A.start()[1]*A.ld();
// TEST_OPERATION("GEMV(COL, NoTrans)", M, N, yi+=cA(i,j)*cx[j], cy[i] = yi,
// BLAS<T>::F(clblasSgemv, clblasDgemv)(clblasColumnMajor, clblasNoTrans, M, N, 1, CHANDLE(A), offA, A.ld(),
// CHANDLE(x), x.start()[0], x.stride()[0], 0, CHANDLE(y), y.start()[0], y.start()[1],
// 1, &clqueue, 0, NULL, NULL), y, bufy, cy);
TEST_OPERATION("y = A.x", M, N, yi+=cA(i,j)*cx[j], cy[i] = yi, y = dot(A,x), y, bufy, cy);
TEST_OPERATION("x = A'.y", N, M, xi+=cA(j,i)*cy[j], cx[i] = xi, x = dot(trans(A),y), x, bufx, cx);