Apologies for accidentally not replying to the list last email....
Thank you, Karl, I'd forgotten that because we have that Definition as part of the java cpp setup. With #define VIENNACL_WITH_OPENCL, though now I'm getting compile errors. Are there possibly missing includes? I've checked this against the blas2.cpp example, and don't see any missing. As well I cant seem to find the suggested imports that you recommended several weeks back. I've attached theu pdated .cpp file with the correct #define as well as pasted it below the partial error dump. Thanks again for your time, Andy g++ DenseVectorMmul.cpp -I/usr/include/viennacl/ -o denseVec /tmp/ccSoGpk2.o: In function `viennacl::ocl::handle_inc_dec_helper<_cl_mem*>::dec(_cl_mem*&)': DenseVectorMmul.cpp:(.text._ZN8viennacl3ocl21handle_inc_dec_helperIP7_cl_memE3decERS3_[_ZN8viennacl3ocl21handle_inc_dec_helperIP7_cl_memE3decERS3_]+0x17): undefined reference to `clReleaseMemObject' /tmp/ccSoGpk2.o: In function `viennacl::ocl::handle_inc_dec_helper<_cl_program*>::dec(_cl_program*&)': DenseVectorMmul.cpp:(.text._ZN8viennacl3ocl21handle_inc_dec_helperIP11_cl_programE3decERS3_[_ZN8viennacl3ocl21handle_inc_dec_helperIP11_cl_programE3decERS3_]+0x17): undefined reference to `clReleaseProgram' /tmp/ccSoGpk2.o: In function `viennacl::ocl::handle_inc_dec_helper<_cl_kernel*>::dec(_cl_kernel*&)': DenseVectorMmul.cpp:(.text._ZN8viennacl3ocl21handle_inc_dec_helperIP10_cl_kernelE3decERS3_[_ZN8viennacl3ocl21handle_inc_dec_helperIP10_cl_kernelE3decERS3_]+0x17): undefined reference to `clReleaseKernel' /tmp/ccSoGpk2.o: In function `viennacl::ocl::handle_inc_dec_helper<_cl_command_queue*>::inc(_cl_command_queue*&)': DenseVectorMmul.cpp:(.text._ZN8viennacl3ocl21handle_inc_dec_helperIP17_cl_command_queueE3incERS3_[_ZN8viennacl3ocl21handle_inc_dec_helperIP17_cl_command_queueE3incERS3_]+0x17): undefined reference to `clRetainCommandQueue' /tmp/ccSoGpk2.o: In function `viennacl::ocl::handle_inc_dec_helper<_cl_command_queue*>::dec(_cl_command_queue*&)': DenseVectorMmul.cpp:(.text._ZN8viennacl3ocl21handle_inc_dec_helperIP17_cl_command_queueE3decERS3_[_ZN8viennacl3ocl21handle_inc_dec_helperIP17_cl_command_queueE3decERS3_]+0x17): undefined reference to `clReleaseCommandQueue' /tmp/ccSoGpk2.o: In function `viennacl::ocl::handle_inc_dec_helper<_cl_context*>::inc(_cl_context*&)': DenseVectorMmul.cpp:(.text._ZN8viennacl3ocl21handle_inc_dec_helperIP11_cl_contextE3incERS3_[_ZN8viennacl3ocl21handle_inc_dec_helperIP11_cl_contextE3incERS3_]+0x17): undefined reference to `clRetainContext' /tmp/ccSoGpk2.o: In function `viennacl::ocl::handle_inc_dec_helper<_cl_context*>::dec(_cl_context*&)': {....snip.....} DenseVectorMmul.cpp: #define VIENNACL_WITH_OPENCL #include "viennacl/context.hpp" #include "viennacl/matrix.hpp" #include "viennacl/tools/random.hpp" // C_vec = A_dense_matrix %*% B_vec. // compile line w/o OpenMP: g++ DenseVectorMmul.cpp -I/usr/include/viennacl/ -o denseVec int main() { // trying to recreate javacpp wrapper functionalliy as closely as possible // so not using typedef, unsigned ints, etc, and defining templates as doubles // creating buffers as int/double arrays and then setting pointers to them. // (not 100% sure that this is how javacpp passes pointers but should be close.) //typedef double ScalarType; // using unsigned ints here to suppress warnings/errors w/o using -fpermissive` // in acuallity, we cast `int`s from jni/javacpp. unsigned int m = 200; unsigned int n = 100; // create an OpenCL context which we will pass directly to the constructors // of the Matrix and vector viennacl::context oclCtx(viennacl::OPENCL_MEMORY); double A_values[m * n] = {0}; viennacl::tools::uniform_random_numbers<double> randomNumber; for (int i = 0; i < m * n; i++) { A_values[i] = randomNumber(); } double* A_values_ptr = A_values; // this is currently the constructor that we're using through scala/javacpp. const viennacl::matrix<double,viennacl::row_major> A_dense_matrix(A_values_ptr, oclCtx.memory_type() , m, n); double B_values[n] = {0}; for (int i = 0; i < n; i++) { B_values[i] = randomNumber(); } double* B_values_ptr = B_values; // this is currently the constructor that we're using through scala/javacpp. viennacl::vector<double> B_vec(B_values_ptr, oclCtx.memory_type(), n, 0, 1); // perform multiplication and pass result to a vector constructor viennacl::vector<double> C_vec(viennacl::linalg::prod(A_dense_matrix , B_vec)); // print out vec std::cout << "ViennaCL: " << C_vec << std::endl; // just exit with success for now if there are no runtime errors. return EXIT_SUCCESS; } ________________________________ From: Karl Rupp <r...@iue.tuwien.ac.at> Sent: Thursday, September 15, 2016 5:14:36 PM To: Andrew Palumbo; ViennaCL-devel@lists.sourceforge.net Subject: Re: [ViennaCL-devel] Matrix * Vector CL_OUT_OF_RESOURCES error Hi, > Attached and below is the the matrix and vector setup that I'm using > from scala. > > I've also attached it as DenseVectorMmul.cpp. > > > When i the snippet below, I get the following error: > > terminate called after throwing an instance of 'viennacl::memory_exception' > what(): ViennaCL: Internal memory error: not initialised! > Aborted (core dumped) you need to either #define VIENNACL_WITH_OPENCL at the very top or add -DVIENNACL_WITH_OPENCL to your compiler call. Best regards, Karli > > > > > > > #include "viennacl/matrix.hpp" > #include "viennacl/compressed_matrix.hpp" > #include "viennacl/vector.hpp" > #include "viennacl/tools/random.hpp" > #include "viennacl/context.hpp" > > > // C_vec = A_dense_matrix %*% B_vec. > > // compile line w/o OpenMP: g++ DenseVectorMmul.cpp > -I/usr/include/viennacl/ -o denseVec > > > > int main() > { > // trying to recreate javacpp wrapper functionalliy as closely as possible > // so not using typedef, unsigned ints, etc, and defining templates as > doubles > // creating buffers as int/double arrays and then setting pointers to > them. > // (not 100% sure that this is how javacpp passes pointers but should > be close.) > > > //typedef double ScalarType; > > // using unsigned ints here to suppress warnings/errors w/o using > -fpermissive` > // in acuallity, we cast `int`s from jni/javacpp. > unsigned int m = 200; > unsigned int n = 100; > > // create an OpenCL context which we will pass directly to the > constructors > // of the Matrix and vector > viennacl::context oclCtx(viennacl::OPENCL_MEMORY); > > double A_values[m * n] = {0}; > > viennacl::tools::uniform_random_numbers<double> randomNumber; > for (int i = 0; i < m * n; i++) { > A_values[i] = randomNumber(); > } > > double* A_values_ptr = A_values; > > // this is currently the constructor that we're using through > scala/javacpp. > const viennacl::matrix<double,viennacl::row_major> > A_dense_matrix(A_values_ptr, oclCtx.memory_type() > , m, n); > > double B_values[n] = {0}; > > for (int i = 0; i < n; i++) { > B_values[i] = randomNumber(); > } > > double* B_values_ptr = B_values; > > // this is currently the constructor that we're using through > scala/javacpp. > viennacl::vector<double> B_vec(B_values_ptr, oclCtx.memory_type(), n, > 0, 1); > > // perform multiplication and pass result to a vector constructor > viennacl::vector<double> C_vec(viennacl::linalg::prod(A_dense_matrix , > B_vec)); > > // print out vec > std::cout << "ViennaCL: " << C_vec << std::endl; > > > // just exit with success for now if there are no runtime errors. > > return EXIT_SUCCESS; > } > > ------------------------------------------------------------------------ > *From:* Andrew Palumbo <ap....@outlook.com> > *Sent:* Wednesday, September 14, 2016 9:49:32 PM > *To:* Karl Rupp; ViennaCL-devel@lists.sourceforge.net > *Subject:* Re: [ViennaCL-devel] Matrix * Vector CL_OUT_OF_RESOURCES error > > > Hi Karl, > > > Thanks, Yeah I'll try to mock one up in C++ and see if i can reproduce > it. (still working in java via javacpp so it can be tough to debug on > my end). Will send you a C++ snippit soon. > > > Thanks, > > > Andy > > ------------------------------------------------------------------------ > *From:* Karl Rupp <r...@iue.tuwien.ac.at> > *Sent:* Wednesday, September 14, 2016 7:09:13 PM > *To:* Andrew Palumbo; ViennaCL-devel@lists.sourceforge.net > *Subject:* Re: [ViennaCL-devel] Matrix * Vector CL_OUT_OF_RESOURCES error > > Hi Andrew, > >> I've been getting a CL_OUT_OF_RESOURCES error when I try to do (somthing >> like) the following with A OpenCL Contex in a unit testt: >> >> >> viennacl::matrix<double,viennacl::row_major> mxA >> >> viennacl::vector<double> vecB >> >> >> // add some data to both mxA and vecB >> >> >> viennacl::vector<double> vecB = viennacl::linalg::prod(mxA, vecB) >> >> This seems right and everything works when using an OpenMP Context, but >> when I try to read the data off of the GPU in (with in an openCL >> Context) using backend::memory_read, I get the CL_OUT_OF_RESOURCES error. > > You get a CL_OUT_OF_RESOURCES error if one of the previous kernels or > data manipulations seg-faulted. Although unlikely, it may also be a > problem with the matrix-vector product kernel. Is there any chance you > can send a working code snippet to reproduce the problem? > > Best regards, > Karli > > >> >> >> If I dont make the backend::memory_read call, that test will pass, but >> my next unit test; A Matrix * Matrix test will fail. >> >> >> Does the Vector product or memory_read seem wrong to you? >> >> >> Thanks, >> >> >> Andy >> >> >> >> >> >> >> ------------------------------------------------------------------------------ >> >> >> >> _______________________________________________ >> ViennaCL-devel mailing list >> ViennaCL-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/viennacl-devel >> >
#define VIENNACL_WITH_OPENCL #include "viennacl/context.hpp" #include "viennacl/matrix.hpp" #include "viennacl/tools/random.hpp" // C_vec = A_dense_matrix %*% B_vec. // compile line w/o OpenMP: g++ DenseVectorMmul.cpp -I/usr/include/viennacl/ -o denseVec int main() { // trying to recreate javacpp wrapper functionalliy as closely as possible // so not using typedef, unsigned ints, etc, and defining templates as doubles // creating buffers as int/double arrays and then setting pointers to them. // (not 100% sure that this is how javacpp passes pointers but should be close.) //typedef double ScalarType; // using unsigned ints here to suppress warnings/errors w/o using -fpermissive` // in acuallity, we cast `int`s from jni/javacpp. unsigned int m = 200; unsigned int n = 100; // create an OpenCL context which we will pass directly to the constructors // of the Matrix and vector viennacl::context oclCtx(viennacl::OPENCL_MEMORY); double A_values[m * n] = {0}; viennacl::tools::uniform_random_numbers<double> randomNumber; for (int i = 0; i < m * n; i++) { A_values[i] = randomNumber(); } double* A_values_ptr = A_values; // this is currently the constructor that we're using through scala/javacpp. const viennacl::matrix<double,viennacl::row_major> A_dense_matrix(A_values_ptr, oclCtx.memory_type() , m, n); double B_values[n] = {0}; for (int i = 0; i < n; i++) { B_values[i] = randomNumber(); } double* B_values_ptr = B_values; // this is currently the constructor that we're using through scala/javacpp. viennacl::vector<double> B_vec(B_values_ptr, oclCtx.memory_type(), n, 0, 1); // perform multiplication and pass result to a vector constructor viennacl::vector<double> C_vec(viennacl::linalg::prod(A_dense_matrix , B_vec)); // print out vec std::cout << "ViennaCL: " << C_vec << std::endl; // just exit with success for now if there are no runtime errors. return EXIT_SUCCESS; }
------------------------------------------------------------------------------
_______________________________________________ ViennaCL-devel mailing list ViennaCL-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/viennacl-devel