diff --git a/include/isaac/driver/buffer.h b/include/isaac/driver/buffer.h index 3e8bfb853..2782b2ba4 100644 --- a/include/isaac/driver/buffer.h +++ b/include/isaac/driver/buffer.h @@ -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_; diff --git a/lib/driver/buffer.cpp b/lib/driver/buffer.cpp index fde34364d..8743e1246 100644 --- a/lib/driver/buffer.cpp +++ b/lib/driver/buffer.cpp @@ -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_; } + } } diff --git a/lib/driver/program.cpp b/lib/driver/program.cpp index a381b1526..977eff3b5 100644 --- a/lib/driver/program.cpp +++ b/lib/driver/program.cpp @@ -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); diff --git a/lib/wrap/clBLAS.cpp b/lib/wrap/clBLAS.cpp index 8c86c06c9..ce1915191 100644 --- a/lib/wrap/clBLAS.cpp +++ b/lib/wrap/clBLAS.cpp @@ -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();\ diff --git a/tests/linalg/common.hpp b/tests/linalg/common.hpp index 3f00ff301..42978dc22 100644 --- a/tests/linalg/common.hpp +++ b/tests/linalg/common.hpp @@ -10,6 +10,7 @@ template struct BLAS; template<> struct BLAS { template static FT F(FT SAXPY, DT ) { return SAXPY; } }; template<> struct BLAS { template static DT F(FT , DT DAXPY) { return DAXPY; } }; +#define CHANDLE(X) (*X.data().handle().cl)() /*------ Simple Vector ---------*/ template class simple_vector_base diff --git a/tests/linalg/mreduction.cpp b/tests/linalg/mreduction.cpp index 621fc6b29..cfacce2a1 100644 --- a/tests/linalg/mreduction.cpp +++ b/tests/linalg/mreduction.cpp @@ -1,6 +1,7 @@ #include #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 & cy, simple_matri simple_vector bufy(M); simple_vector 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 & 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::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);