ddemidov / amgcl

C++ library for solving large sparse linear systems with algebraic multigrid method
http://amgcl.readthedocs.org/
MIT License
728 stars 112 forks source link

Error when trying to compile with VexCL #67

Closed loumalouomega closed 5 years ago

loumalouomega commented 6 years ago

Greetings,

I am trying to compile AMGCL with support to VexCl and I am getting the following error:

/home/vicente/src/vexcl/vexcl/function.hpp:338:1: error: macro "isgreater" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, isgreater )
 ^
/home/vicente/src/vexcl/vexcl/function.hpp:339:1: error: macro "isgreaterequal" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, isgreaterequal )
 ^
/home/vicente/src/vexcl/vexcl/function.hpp:341:1: error: macro "isless" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, isless )
 ^
/home/vicente/src/vexcl/vexcl/function.hpp:342:1: error: macro "islessequal" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, islessequal )
 ^
/home/vicente/src/vexcl/vexcl/function.hpp:343:1: error: macro "islessgreater" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, islessgreater )
 ^
/home/vicente/src/vexcl/vexcl/function.hpp:348:1: error: macro "isunordered" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, isunordered )
 ^
In file included from /home/vicente/src/vexcl/vexcl/sparse/ell.hpp:52:0,
                 from /home/vicente/src/vexcl/vexcl/sparse/matrix.hpp:4,
                 from /home/vicente/src/vexcl/vexcl/vexcl.hpp:50,
                 from /home/vicente/src/amgcl/amgcl/backend/vexcl.hpp:40,
                 from /home/vicente/src/amgcl/examples/vexcl.cpp:5:
/home/vicente/src/vexcl/vexcl/function.hpp:338:1: error: macro "isgreater" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, isgreater )
 ^
/home/vicente/src/vexcl/vexcl/function.hpp:339:1: error: macro "isgreaterequal" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, isgreaterequal )
 ^
/home/vicente/src/vexcl/vexcl/function.hpp:341:1: error: macro "isless" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, isless )
 ^
/home/vicente/src/vexcl/vexcl/function.hpp:342:1: error: macro "islessequal" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, islessequal )
 ^
/home/vicente/src/vexcl/vexcl/function.hpp:343:1: error: macro "islessgreater" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, islessgreater )
 ^
/home/vicente/src/vexcl/vexcl/function.hpp:348:1: error: macro "isunordered" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, isunordered )
 ^
In file included from /home/vicente/src/vexcl/vexcl/sparse/ell.hpp:52:0,
                 from /home/vicente/src/vexcl/vexcl/sparse/matrix.hpp:4,
                 from /home/vicente/src/vexcl/vexcl/vexcl.hpp:50,
                 from /home/vicente/src/amgcl/amgcl/backend/vexcl.hpp:40,
                 from /home/vicente/src/amgcl/examples/solver.cpp:15:
/home/vicente/src/vexcl/vexcl/function.hpp:338:1: error: macro "isgreater" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, isgreater )
 ^
/home/vicente/src/vexcl/vexcl/function.hpp:339:1: error: macro "isgreaterequal" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, isgreaterequal )
 ^
/home/vicente/src/vexcl/vexcl/function.hpp:341:1: error: macro "isless" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, isless )
 ^
/home/vicente/src/vexcl/vexcl/function.hpp:342:1: error: macro "islessequal" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, islessequal )
 ^
/home/vicente/src/vexcl/vexcl/function.hpp:343:1: error: macro "islessgreater" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, islessgreater )
 ^
/home/vicente/src/vexcl/vexcl/function.hpp:348:1: error: macro "isunordered" requires 2 arguments, but only 1 given
 VEX_BUILTIN_FUNCTION( 2, isunordered )

It continues, but is more of the same error.

I am using boost 1.66 and compiling with c++11 support.

Best regards and thanks in advance

ddemidov commented 6 years ago

Could you please elaborate on how exactly you are compiling this (compiler, compile options)? For example, the following example:

#include <boost/range/iterator_range.hpp>

#include <vexcl/vexcl.hpp>

#include <amgcl/backend/vexcl.hpp>
#include <amgcl/adapter/crs_tuple.hpp>
#include <amgcl/make_solver.hpp>
#include <amgcl/amg.hpp>
#include <amgcl/relaxation/spai0.hpp>
#include <amgcl/coarsening/smoothed_aggregation.hpp>
#include <amgcl/solver/bicgstab.hpp>

int main() {
    vex::Context ctx(vex::Filter::Env);
    std::cout << ctx << std::endl;

    typedef amgcl::backend::vexcl<double> Backend;
    typedef amgcl::make_solver<
        amgcl::amg<Backend, amgcl::coarsening::smoothed_aggregation, amgcl::relaxation::spai0>,
        amgcl::solver::bicgstab<Backend>
        > Solver;

    // Fake CRS matrix:
    int n = 0;
    int *ptr = 0;
    int *col = 0;
    int *val = 0;

    // This is enough to compile, but should fail at runtime.
    Solver solver(boost::make_tuple(
                n,
                boost::make_iterator_range(ptr, ptr),
                boost::make_iterator_range(col, col),
                boost::make_iterator_range(val, val)
                ));
}

compiles for me with this cmake file:

cmake_minimum_required(VERSION 3.1)
project(hello)

find_package(amgcl)
find_package(VexCL)

add_executable(hello hello.cpp)
target_link_libraries(hello VexCL::OpenCL amgcl::amgcl)

It is enough to clone and configure both amgcl and vexcl for find_package above to work. Configure means running cmake like this:

cd amgcl
mkdir build
cd build
cmake ..

If this does not help, could you provide a minimal example?

loumalouomega commented 6 years ago

For the VexCL compilation I use the following script:

cmake .. \
-DCMAKE_BUILD_TYPE=Release                                               \
-DBoost_NO_BOOST_CMAKE:BOOL=TRUE                                         \
-DBoost_NO_SYSTEM_PATHS:BOOL=TRUE                                        \
-DBOOST_ROOT="~/src/boost_1_66_0"                                        \
-DUSE_LIBCPP:BOOL=TRUE                                                   \
-DCMAKE_C_COMPILER=/usr/bin/gcc-5                                        \
-DCMAKE_CXX_COMPILER=/usr/bin/g++-5                                      \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -msse3 -std=c++11 -O3 -g"          \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -msse3 -O3 -g"                         \
-DCUDA_NVCC_FLAGS="${CUDA_NVCC_FLAGS} -Xcompiler -std=c++11"             \
-DCUDA_TOOLKIT_ROOT_DIR="/usr/lib/nvidia-cuda-toolkit/"                  \
# -DCUDA_TOOLKIT_ROOT_DIR="/usr/local/cuda-9.1/"                           \

#decomment this to have it verbose
# make VERBOSE=1 -j4
make -j4
# sudo make install

Besides USE_LIBCPP does not work or it is recognized apparently.

And for the AMGL I use the following script:

cmake .. \
-DCMAKE_BUILD_TYPE=Release                                               \
-DBOOST_ROOT="~/src/boost_1_66_0"                                        \
-DCMAKE_C_COMPILER=/usr/bin/gcc-5                                        \
-DCMAKE_CXX_COMPILER=/usr/bin/g++-5                                      \
-DAMGCL_BUILD_EXAMPLES=ON                                                \
-DAMGCL_BUILD_TESTS=ON                                                   \
-DPASTIX_INCLUDES="~/src/pastix_5.2.3/install/lib"                       \
-DPASTIX_LIBRARIES="~/src/pastix_5.2.3/install/include"                  \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -msse3 -std=c++11 -O3 -g"          \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -msse3 -O3 -g"                         \
-DCUDA_NVCC_FLAGS="${CUDA_NVCC_FLAGS} -Xcompiler -std=c++11"             \
-DEIGEN_INCLUDE="~/src/eigen"                                            \
-DVIENNACL_INCLUDE="~/src/viennacl-dev"                                  \
-DCUDA_TOOLKIT_ROOT_DIR="/usr/lib/nvidia-cuda-toolkit/"                  \
# -DVexCL_DIR="~/src/vexcl"                                                \
# -DCUDA_TOOLKIT_ROOT_DIR="/usr/local/cuda-9.1/"                           \

#decomment this to have it verbose
# make VERBOSE=1 -j4
make -j4
# sudo make install

Thanks in advance, have a nice day

loumalouomega commented 6 years ago

Additionally, boost has been compiled with:

./b2 stage --with-python --with-serialization --with-chrono  --with-date_time --with-system --with-thread --with-test --with-atomic --with-program_options --with-filesystem cxxflags="-std=c++11" variant=release link=shared,static
ddemidov commented 6 years ago

@loumalouomega , sorry for the late reply, did you manage to solve this? If not, we could have a chat in telegram.

loumalouomega commented 6 years ago

Sorry I haven't tried since then, I downgraded the drivers of the graphic card because of compatibility reasons, and CUDA wasn't working. I reinstalled the correct ones last Sunday, I will try again today and I will tell yiu

ddemidov commented 6 years ago

Try to not use the old configuration scripts; I would just try a clean configuration of vexcl and amgcl instead.