but I did use -DENABLE_OPENCL=ON with cmake
   also can you tell where exactly i should put this line
viennacl::ocl::set_context_device_type (0, CL_DEVICE_TYPE_GPU | CL_DEVICE_TYPE_ACCELERATOR); in vector.cpp code
how do we know if MIC is infact being used i,e  the code is running on MIC..  IM trying to run this on stampede cluster node of tacc

also should we add any other flags..  or change code some where... as it is suggested in the viennaCL manual..
 to use custom-context.cpp to create context and modify vector.cpp..   if that is the case how should i modify...
thanks for your time and reply

with regards..

M. Sai Rajeswar
M-tech  Computer Technology
IIT Delhi
----------------------------------Cogito Ergo Sum---------

On Thu, Jun 26, 2014 at 6:40 PM, Karl Rupp <> wrote:

>    Im trying to run viennaCL demo codes on mic.. but got stuck in doing so..
if i want to rin say /examples/bencmarks/vector.cpp on MIC how should i
use 'make' command

The following should build it:

$ ViennaCL-1.5.2> mkdir build && cd build
$ build> cmake ..
$ build> make vectorbench-opencl

# run it:
$ build> examples/benchmarks/vectorbench-opencl

in one of the mailing list people have suggested to use the following
statement in the main part of the code

viennacl::ocl::set_context_device_type (0, CL_DEVICE_TYPE_GPU |

Yes, you have to include this, as the Intel SDK by default uses the CPU. If you have other OpenCL SDKs installed on your machine, you should also set the platform index accordingly.

how ever when i used that line in main part of vector.cpp and ran 'make'
command i got following error
---------------------------------------------------[ 95%] Building CXX
object examples/benchmarks/CMakeFiles/vectorbench-cpu.dir/vector.cpp.o
In function ‘int main()’:
error: ‘set_context_device_type’ is not a member of ‘viennacl::ocl’
error: ‘CL_DEVICE_TYPE_GPU’ was not declared in this scope
error: ‘CL_DEVICE_TYPE_ACCELERATOR’ was not declared in this scope
make[2]: ***
[examples/benchmarks/CMakeFiles/vectorbench-cpu.dir/vector.cpp.o] Error 1
make[1]: *** [examples/benchmarks/CMakeFiles/vectorbench-cpu.dir/all]
Error 2
make: *** [all] Error 2

This stems from a missing "VIENNACL_WITH_OPENCL" define. This is set automatically by the included CMake build system if "ENABLE_OPENCL" is activated. If you use your own Makefile, make sure you add "-DVIENNACL_WITH_OPENCL".

As an alternative path, you can also build directly without using CMake or Makefiles:

$ build> g++ ../examples/benchmarks/vector.cpp -o vectorbench-opencl -I .. -DVIENNACL_WITH_OPENCL -lOpenCL

$ build> ./vectorbench-opencl

Best regards,