Menu

an error about "amg.cpp"

Tan.Q
2016-10-19
2016-10-19
  • Tan.Q

    Tan.Q - 2016-10-19

    Hi, I study the Viennacl library. and when I bulid the example " amg.cpp " with opencl, it occured error .
    at the begining of the code I write:

    #define VIENNACL_WITH_OPENCL 1
    #include "viennacl/ocl/platform.hpp"
    #include "viennacl/ocl/backend.hpp"
    #include "viennacl/context.hpp"
    #include "viennacl/ocl/context.hpp"
    #include "viennacl/forwards.h"
    

    and the error occured in the sentence

    viennacl::context ctx(viennacl::ocl::get_context(0));
    

    the error description is
    " Error 4 error C2664: 'viennacl::context::context(const viennacl::context &)' : cannot convert argument 1 from 'viennacl::ocl::context' to 'viennacl::memory_types' "
    I wonder why about this.

    AND I have another question: If I want compute on GPU , I must use " #define VIENNACL_WITH_OPENCL 1" ?
    or this code has already compute with GPU defaultly. without write " #define VIENNACL_WITH_OPENCL 1 ".

    Thank you very much !!!!!

     
  • Karl Rupp

    Karl Rupp - 2016-10-19

    Hi,
    do you define VIENNACL_WITH_OPENCL before all of your ViennaCL-related includes? It looks like viennacl/context.hpp gets included indirectly at an earlier point. Generally I recommend to put the define as the first line in your source file.

    As for your second question:
    If you define VIENNACL_WITH_OPENCL, the code will run per default on the first device available on your system. To get an overview of the OpenCL devices on your system, build and run viennacl-info. The first device listed there is the default device (usually a GPU).

    Best regards,
    Karli

     

Log in to post a comment.