title: Is it possible to call cublas functions from a device function?
body: <p>In <a href="https://stackoverflow.com/questions/12219997/is-it-possible-to-call-a-cuda-cublas-function-from-a-global-or-device-function">here</a> Robert Crovella said that cublas routines can be called from device code.  Although I am  using dynamic parallelism and compiling with compute capability 3.5, I cannot manage to call Cublas routines from a device function. I always get the error "<em>calling a host function from a <strong>device</strong>/<strong>global</strong> function is not allowed</em>" My code contains device functions which call CUBLAS routines like <code>cublsAlloc</code>, <code>cublasGetVector</code>, <code>cublasSetVector</code> and <code>cublasDgemm</code></p>
  
  <p>My compilation and linking commands:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>  
  nvcc -arch=sm_35 -I. -I/usr/local/cuda/include -c -O3 -dc GPUutil.cu -o ./build/GPUutil.o   
  nvcc -arch=sm_35 -I. -I/usr/local/cuda/include -c -O3 -dc DivideParalelo.cu -o ./build/DivideParalelo.o
  nvcc -arch=sm_35 -I. -I/usr/local/cuda/include -dlink ./build/io.o ./build/GPUutil.o ./build/DivideParalelo.o -lcudadevrt -o ./build/link.o
  icc -Wwrite-strings ./build/GPUutil.o ./build/DivideParalelo.o ./build/link.o -lcudadevrt -L/usr/local/cuda/lib64  -L~/Intel/composer_xe_2015.0.090/mkl/lib/intel64  -L~/Intel/composer_xe_2015.0.090/mkl/../compiler/lib/intel64  -Wl,--start-group ~/Intel/composer_xe_2015.0.090/mkl/lib/intel64/libmkl_intel_lp64.a ~/Intel/composer_xe_2015.0.090/mkl/lib/intel64/libmkl_sequential.a ~/Intel/composer_xe_2015.0.090/mkl/lib/intel64/libmkl_core.a ~/Intel/composer_xe_2015.0.090/mkl/../compiler/lib/intel64/libiomp5.a -Wl,--end-group -lpthread  -lm  -lcublas -lcudart   -o DivideParalelo   
   </code></pre>
  </div>
  </div>
  </p>