Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clSPARSE does not build with OpenCL 2.0 on Debian #162

Open
ghisvail opened this issue Oct 14, 2015 · 24 comments
Open

clSPARSE does not build with OpenCL 2.0 on Debian #162

ghisvail opened this issue Oct 14, 2015 · 24 comments

Comments

@ghisvail
Copy link
Contributor

Using the latest v0.6.2.0 tag, clSPARSE fails to build on Debian testing / unstable with the following error message:

clsparse-0.6.2.0/src/library/include/clSPARSE-private.hpp:31:21: fatal error: CL/cl.hpp: No such file or directory

Despite explicitly passing -DBUILD_CLVERSION=2.0 to CMake.

@kknox
Copy link
Contributor

kknox commented Oct 14, 2015

We have soft plans to switch the library internals to boost.compute, which will remove references to cl.hpp (see #138). There is no ETA on this though, we only have a proof-of-concept at this point.

@ghisvail
Copy link
Contributor Author

Alright I will hold on then.

@ghisvail
Copy link
Contributor Author

Any news on this?

@kknox
Copy link
Contributor

kknox commented Apr 22, 2016

The momentum to convert the internals to boost.compute has stopped; we don't have the resources at this time. However, I am working on getting approval to check-in cl.hpp pushed through.

@pavanky
Copy link

pavanky commented Jun 28, 2016

@ghisvail can you check if clsparse compiles on debian with #187 ? You may need to run cmake with -DUSE_SYSTEM_CL2HPP=ON.

@ghisvail
Copy link
Contributor Author

@pavanky I'll try to find some time to look at this by the end of the week. Cheers for the heads-up.

@ghisvail
Copy link
Contributor Author

ghisvail commented Jul 2, 2016

I refreshed the packaging with 9677ec3, but cannot get the build to succeed. This is the cmake command run by the package build process:

cmake ../src -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_INSTALL_LOCALSTATEDIR=/var -DBUILD_BENCHMARKS=OFF -DBUILD_CLVERSION=2.0 -DBUILD_TESTS=OFF -DSUFFIX_LIB=/x86_64-linux-gnu -DUSE_SYSTEM_CL2HPP=ON

and the build log output:

make[1]: Entering directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu'
/usr/bin/cmake -H"/<<PKGBUILDDIR>>/src" -B"/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu" --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start "/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/CMakeFiles" "/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/CMakeFiles/progress.marks"
make -f CMakeFiles/Makefile2 all
make[2]: Entering directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu'
make -f library/CMakeFiles/clSPARSE.dir/build.make library/CMakeFiles/clSPARSE.dir/depend
make[3]: Entering directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu'
[  2%] Generating ../include/kernels/source-provider.cpp
cd "/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/library" && /usr/bin/cmake -DCL_DIR="/<<PKGBUILDDIR>>/src/library/kernels" -DOUTPUT="/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/include/kernels/source-provider.cpp" -P /<<PKGBUILDDIR>>/src/cmake/cl2cpp_raw.cmake
-- running cl2cpp_raw
SpGEMM_EM_kernels
SpGEMM_ESC_0_1_kernels
SpGEMM_ESC_2heap_kernels
SpGEMM_ESC_bitonic_kernels
SpGEMM_computeNnzCt_kernels
SpGEMM_copyCt2C_kernels
atomic_reduce
blas1
control
conversion_utils
csrmm_adaptive
csrmm_general
csrmv_adaptive
csrmv_general
dot
elementwise_transform
matrix_utils
reduce
reduce_by_key
scan
sort_by_key_common
sort_by_key_int
sort_by_key_uint
cd "/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu" && /usr/bin/cmake -E cmake_depends "Unix Makefiles" "/<<PKGBUILDDIR>>/src" "/<<PKGBUILDDIR>>/src/library" "/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu" "/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/library" "/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/library/CMakeFiles/clSPARSE.dir/DependInfo.cmake" --color=
Scanning dependencies of target clSPARSE
make[3]: Leaving directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu'
make -f library/CMakeFiles/clSPARSE.dir/build.make library/CMakeFiles/clSPARSE.dir/build
make[3]: Entering directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu'
[  5%] Building CXX object library/CMakeFiles/clSPARSE.dir/clsparse-init.cpp.o
cd "/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/library" && /usr/bin/c++   -DBUILD_CLVERSION=200 -DCLSPARSE_INDEX_SIZEOF=4 -DclSPARSE_EXPORTS -I"/<<PKGBUILDDIR>>/src/library" -I"/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/library" -I"/<<PKGBUILDDIR>>/src/include" -I"/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/include" -I"/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/clsparseTimer"  -m64 -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wall -pedantic -Wdate-time -D_FORTIFY_SOURCE=2  -fPIC -fvisibility=hidden -fvisibility-inlines-hidden   -std=c++11 -pedantic -o CMakeFiles/clSPARSE.dir/clsparse-init.cpp.o -c "/<<PKGBUILDDIR>>/src/library/clsparse-init.cpp"
In file included from /<<PKGBUILDDIR>>/src/library/include/clSPARSE-private.hpp:26:0,
                 from /<<PKGBUILDDIR>>/src/library/clsparse-init.cpp:21:
/<<PKGBUILDDIR>>/src/include/clSPARSE.h:39:2: error: #error clSPARSE does not yet implement OpenCL 2.0 interfaces
 #error clSPARSE does not yet implement OpenCL 2.0 interfaces
  ^
In file included from /<<PKGBUILDDIR>>/src/library/include/clSPARSE-private.hpp:36:0,
                 from /<<PKGBUILDDIR>>/src/library/clsparse-init.cpp:21:
/<<PKGBUILDDIR>>/src/library/include/clSPARSE-2x.hpp: In member function 'void clsparseCsrMatrixPrivate::clear()':
/<<PKGBUILDDIR>>/src/library/include/clSPARSE-2x.hpp:181:46: error: 'rowBlocks' was not declared in this scope
         values = col_indices = row_pointer = rowBlocks = nullptr;
                                              ^
/<<PKGBUILDDIR>>/src/library/include/clSPARSE-2x.hpp:182:9: error: 'rowBlockSize' was not declared in this scope
         rowBlockSize = 0;
         ^
/<<PKGBUILDDIR>>/src/library/clsparse-init.cpp: At global scope:
/<<PKGBUILDDIR>>/src/library/clsparse-init.cpp:71:2: warning: extra ';' [-Wpedantic]
 };
  ^
/<<PKGBUILDDIR>>/src/library/clsparse-init.cpp:80:2: warning: extra ';' [-Wpedantic]
 };
  ^
/<<PKGBUILDDIR>>/src/library/clsparse-init.cpp:89:2: warning: extra ';' [-Wpedantic]
 };
  ^
/<<PKGBUILDDIR>>/src/library/clsparse-init.cpp:98:2: warning: extra ';' [-Wpedantic]
 };
  ^
library/CMakeFiles/clSPARSE.dir/build.make:69: recipe for target 'library/CMakeFiles/clSPARSE.dir/clsparse-init.cpp.o' failed
make[3]: *** [library/CMakeFiles/clSPARSE.dir/clsparse-init.cpp.o] Error 1
make[3]: Leaving directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu'
CMakeFiles/Makefile2:88: recipe for target 'library/CMakeFiles/clSPARSE.dir/all' failed
make[2]: *** [library/CMakeFiles/clSPARSE.dir/all] Error 2
make[2]: Leaving directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu'
Makefile:152: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu'

@pavanky
Copy link

pavanky commented Jul 2, 2016

@ghisvail can you remove explicitly passing BUILD_CLVERSION ?

@ghisvail
Copy link
Contributor Author

ghisvail commented Jul 5, 2016

@pavanky same outcome

@pavanky
Copy link

pavanky commented Jul 5, 2016

@ghisvail I was able to compile the library with a minor patch after configuring with the following command on debian testing.

cmake ../src -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_INSTALL_LOCALSTATEDIR=/var -DBUILD_BENCHMARKS=OFF -DBUILD_TESTS=OFF -DSUFFIX_LIB=/x86_64-linux-gnu -DUSE_SYSTEM_CL2HPP=ON
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0bdec76..bf1940a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -18,6 +18,8 @@
 # PUBLIC keywords
 cmake_minimum_required( VERSION 2.8.12 )

+ADD_DEFINITIONS(-DCL_USE_DEPRECATED_OPENCL_1_2_APIS)
+
 if( CMAKE_GENERATOR MATCHES "NMake" )
        option( NMAKE_COMPILE_VERBOSE "Print VERBOSE compile/link msgs to the console" OFF )
        if( NMAKE_COMPILE_VERBOSE )

@ghisvail
Copy link
Contributor Author

ghisvail commented Jul 5, 2016

Thanks for looking at it. Then, it should be fine if we were able to compile, unless you want me to double-check ?

@pavanky
Copy link

pavanky commented Jul 5, 2016

@ghisvail I sent in this PR: #189 may be wait until it is resolved?

Can you also raise a debian bug to update the cl2.hpp header? Khronos moved the headers to a github repo now: https://github.com/KhronosGroup/OpenCL-CLHPP

The version available in debian testing is a bit buggy.

@ghisvail
Copy link
Contributor Author

ghisvail commented Jul 5, 2016

The version available in debian testing is a bit buggy.

Is the 2.0.9 release enough? Or do you need anything newer?

@pavanky
Copy link

pavanky commented Jul 5, 2016

@ghisvail This commit seems to be the issue: KhronosGroup/OpenCL-CLHPP@befe77b

It was made after the release of 2.0.9. May be you can ask upstream to make a new release?

@ghisvail
Copy link
Contributor Author

ghisvail commented Jul 5, 2016

I have just sent the bug reports to the Debian maintainers of the OpenCL headers asking for an update. Meanwhile, I'll check with upstream whether they are happy to do a release. Worst case, this commit could be cherry-picked onto 2.0.9 I presume.

@ghisvail
Copy link
Contributor Author

ghisvail commented Aug 8, 2016

@pavanky I saw your PR was merged, which means clSPARSE can now probably be built in Debian.

Any plans to tag a new release out soon ?

@ghisvail
Copy link
Contributor Author

I can confirm that the current tip of develop can be successfully built on Debian. Closing.

@ghisvail
Copy link
Contributor Author

My bad. OpenCL 1.2 builds fine, but OpenCL 2.0 still fails.

@ghisvail ghisvail reopened this Aug 10, 2016
@ghisvail
Copy link
Contributor Author

You can get a build going with the following patch:

diff --git a/src/include/clSPARSE.h b/src/include/clSPARSE.h
index 0af7f5a..43e6bd5 100644
--- a/src/include/clSPARSE.h
+++ b/src/include/clSPARSE.h
@@ -36,7 +36,7 @@ extern "C" {
 #if( BUILD_CLVERSION < 200 )
 #include "clSPARSE-1x.h"
 #else
-#error clSPARSE does not yet implement OpenCL 2.0 interfaces
+//#error clSPARSE does not yet implement OpenCL 2.0 interfaces
 #include "clSPARSE-2x.h"
 #endif

diff --git a/src/library/include/clSPARSE-2x.hpp b/src/library/include/clSPARSE-2x.hpp
index 7a5f0aa..b3e79fe 100644
--- a/src/library/include/clSPARSE-2x.hpp
+++ b/src/library/include/clSPARSE-2x.hpp
@@ -178,8 +178,7 @@ public:
     void clear( )
     {
         num_rows = num_cols = num_nonzeros = 0;
-        values = col_indices = row_pointer = rowBlocks = nullptr;
-        rowBlockSize = 0;
+        values = col_indices = row_pointer = nullptr;
     }

     clsparseIdx_t nnz_per_row() const

and start a build with OpenCL 2.0, but it leads to more errors:

[ 22%] Building CXX object library/CMakeFiles/clSPARSE.dir/internal/data-types/csr-meta.cpp.o
In file included from /home/ghislain/debian/packages/clsparse/src/library/internal/clsparse-control.hpp:22:0,
                 from /home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:21:
/home/ghislain/debian/packages/clsparse/src/library/../clsparseTimer/clsparseTimer-device.hpp:75:45: warning: ignoring attributes on template argument ‘cl_uint {aka unsigned int}’ [-Wignored-attributes]
     typedef std::pair< std::string, cl_uint > idPair;
                                             ^
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp: In function ‘clsparseMetaSizeResult clsparseCsrMetaSize(clsparseCsrMatrix*, clsparseControl)’:
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:32:44: error: ‘matrix_meta’ does not name a type
         sizeResult.metaSize = static_cast< matrix_meta* >( pCsrMatx->meta )->rowBlockSize;
                                            ^~~~~~~~~~~
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:32:55: error: expected ‘>’ before ‘*’ token
         sizeResult.metaSize = static_cast< matrix_meta* >( pCsrMatx->meta )->rowBlockSize;
                                                       ^
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:32:55: error: expected ‘(’ before ‘*’ token
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:32:57: error: expected primary-expression before ‘>’ token
         sizeResult.metaSize = static_cast< matrix_meta* >( pCsrMatx->meta )->rowBlockSize;
                                                         ^
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:32:76: error: ‘void*’ is not a pointer-to-object type
         sizeResult.metaSize = static_cast< matrix_meta* >( pCsrMatx->meta )->rowBlockSize;
                                                                            ^~
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:32:90: error: expected ‘)’ before ‘;’ token
         sizeResult.metaSize = static_cast< matrix_meta* >( pCsrMatx->meta )->rowBlockSize;
                                                                                          ^
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:37:30: warning: ignoring attributes on template argument ‘clsparseIdx_t {aka unsigned int}’ [-Wignored-attributes]
     clMemRAII< clsparseIdx_t > rCsrrow_pointer( control->queue( ), pCsrMatx->row_pointer );
                              ^
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp: In function ‘clsparseStatus clsparseCsrMetaCreate(clsparseCsrMatrix*, clsparseControl)’:
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:56:30: warning: ignoring attributes on template argument ‘clsparseIdx_t {aka unsigned int}’ [-Wignored-attributes]
     clMemRAII< clsparseIdx_t > rCsrrow_pointer( control->queue( ), pCsrMatx->row_pointer );
                              ^
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:59:5: error: ‘matrix_meta’ was not declared in this scope
     matrix_meta* meta_ptr = nullptr;
     ^~~~~~~~~~~
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:59:18: error: ‘meta_ptr’ was not declared in this scope
     matrix_meta* meta_ptr = nullptr;
                  ^~~~~~~~
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:62:33: error: ‘matrix_meta’ does not name a type
         meta_ptr = static_cast< matrix_meta* >( pCsrMatx->meta );
                                 ^~~~~~~~~~~
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:62:44: error: expected ‘>’ before ‘*’ token
         meta_ptr = static_cast< matrix_meta* >( pCsrMatx->meta );
                                            ^
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:62:44: error: expected ‘(’ before ‘*’ token
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:62:46: error: expected primary-expression before ‘>’ token
         meta_ptr = static_cast< matrix_meta* >( pCsrMatx->meta );
                                              ^
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:62:65: error: expected ‘)’ before ‘;’ token
         meta_ptr = static_cast< matrix_meta* >( pCsrMatx->meta );
                                                                 ^
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:63:16: error: type ‘<type error>’ argument given to ‘delete’, expected pointer
         delete meta_ptr;
                ^~~~~~~~
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:68:20: error: ‘matrix_meta’ does not name a type
     meta_ptr = new matrix_meta;
                    ^~~~~~~~~~~
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:75:29: warning: ignoring attributes on template argument ‘cl_ulong {aka long unsigned int}’ [-Wignored-attributes]
         clMemRAII< cl_ulong > rRowBlocks( control->queue( ), meta_ptr->rowBlocks( ) );
                             ^
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp: In function ‘clsparseStatus clsparseCsrMetaDelete(clsparseCsrMatrix*)’:
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:95:5: error: ‘matrix_meta’ was not declared in this scope
     matrix_meta* meta_ptr = static_cast< matrix_meta* >( pCsrMatx->meta );
     ^~~~~~~~~~~
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:95:18: error: ‘meta_ptr’ was not declared in this scope
     matrix_meta* meta_ptr = static_cast< matrix_meta* >( pCsrMatx->meta );
                  ^~~~~~~~
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:95:42: error: ‘matrix_meta’ does not name a type
     matrix_meta* meta_ptr = static_cast< matrix_meta* >( pCsrMatx->meta );
                                          ^~~~~~~~~~~
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:95:53: error: expected ‘>’ before ‘*’ token
     matrix_meta* meta_ptr = static_cast< matrix_meta* >( pCsrMatx->meta );
                                                     ^
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:95:53: error: expected ‘(’ before ‘*’ token
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:95:55: error: expected primary-expression before ‘>’ token
     matrix_meta* meta_ptr = static_cast< matrix_meta* >( pCsrMatx->meta );
                                                       ^
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:95:74: error: expected ‘)’ before ‘;’ token
     matrix_meta* meta_ptr = static_cast< matrix_meta* >( pCsrMatx->meta );
                                                                          ^
/home/ghislain/debian/packages/clsparse/src/library/internal/data-types/csr-meta.cpp:96:12: error: type ‘<type error>’ argument given to ‘delete’, expected pointer
     delete meta_ptr;
            ^~~~~~~~

@pavanky
Copy link

pavanky commented Aug 10, 2016

You shouldn't have to change anything.. What is the error you are getting earlier ?

@pavanky
Copy link

pavanky commented Aug 10, 2016

My bad. OpenCL 1.2 builds fine, but OpenCL 2.0 still fails.

If you mean cl2.hpp works fine with OpenCL 1.2 I don't see a problem with it. I don't think clSparse has been patched to work in OpenCL 2.0 only.

Why do you need to force it to use OpenCL 2.0 APIs ?

@ghisvail
Copy link
Contributor Author

If you mean cl2.hpp works fine with OpenCL 1.2 I don't see a problem with it.

Indeed it works. Will it be sufficient for the next release of ArrayFire then?

I don't think clSparse has been patched to work in OpenCL 2.0 only.

That's what I figured from the results of the build above. Seems that the OpenCL 2.0 path of the codebase has not been adapted to recent changes in the API (such as e92f41b).

@pavanky
Copy link

pavanky commented Aug 11, 2016

Indeed it works. Will it be sufficient for the next release of ArrayFire then?

ArrayFire also targets 1.2. Considering that OpenCL libraries are backwards compatible, I think that is a fair.

That's what I figured from the results of the build above. Seems that the OpenCL 2.0 path of the codebase has not been adapted to recent changes in the API

I don't think clSparse ever had an OpenCL 2.0 path. @kknox correct me if I am wrong here.

@ghisvail
Copy link
Contributor Author

ArrayFire also targets 1.2. Considering that OpenCL libraries are backwards compatible.

Then I'll stick with 1.2 for all clMath libraries to remain consistent with what AF supports.

I don't think clSparse ever had an OpenCL 2.0 path.

The official documentation suggests otherwise:

"OpenCL 2.0 support is not yet fully implemented; only the interfaces have been designed"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants