How to use "mkl_mic_free_memory"?

How to use "mkl_mic_free_memory"?

Dear all,

I would like to use AO and CAO. I could enable/disable AO and set max. memory, but mkl_mic_free_memory is not working.

Here is an example:

      dim = 1024*8

      allocate (A(dim*dim))
      allocate (B(dim*dim))
      allocate (C(dim*dim))

      write(*,*) mkl_mic_enable()
      write(*,*) mkl_mic_set_max_memory( MKL_TARGET_MIC, 0, 1024*1024*6 )
      CALL DGEMM('N','N',dim,dim,dim,1.0d0,
     &            A,dim,B,dim,1.0d0,C,dim)
      write(*,*) mkl_mic_free_memory(MKL_TARGET_MIC, 0)
      write(*,*) mkl_mic_disable()

     & IN(dim)
     & IN(A,B,C: LENGTH(dim*dim))


My card has 8GB memory. If AO reservs 6GB memory, there is not enough memory for offload transfer, and it generates offload error (9/13/16). All mkl_mic_... function return with 0 err code. When max. mem. only 4GB, it's working.

Is there any mistake?

(composer_xe_2013_sp1.2.144, composer_xe_2013_sp1.2.144, composer_xe_2015.0.024)


5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Please try set the env-variable OFFLOAD_ENABLE_ORSL=1. This tells automatic offload and compiler-assisted offload to synchronize their access to the coprocessor.

If this doesn't help then please submit a bug report.


Thanks for the quick answer.

I try, but it's not working. I also try "AO-after-CAO", and it's also not working. It goes into an infinite loop.




Downloadapplication/x-tar test.tar10 KB

Hello, I tried your test code. It actually worked fine. The problem is in the compile and link line. You didn't compile and link the code properly for CAO execution. See my modified script below.



touch test1.f
ifort -i8 test1.f -c -I$MKLROOT/include -offload-attribute-target=mic -offload-option,mic,compiler," -L$MKLROOT/lib/mic -lmkl_intel_ilp64 -lmkl_core -lmkl_sequential"
ifort test1.o -L$MKLROOT/lib/intel64 -lmkl_intel_ilp64 -lmkl_core -lmkl_sequential -lpthread -lm -o test1
chmod +x test1


What version of compiler did you use? Because your compiler line is incompatible with mine. "-extend_source" (long line) and "-I$MKLROOT/include/intel64/lp64/" ("use mkl_service") is necessary. And program goes into infinite loop at the AO stage AO is not working (CPU does the work) if I link "mkl_sequential". When I used  "mkl_intel_thread", so:

ifort -i8 -extend_source test1.f -c -I$MKLROOT/include -I$MKLROOT/include/intel64/lp64/ -offload-attribute-target=mic -offload-option,mic,compiler," -L$MKLROOT/lib/mic -lmkl_intel_ilp64 -lmkl_core -lmkl_intel_thread"
ifort test1.o -L$MKLROOT/lib/intel64 -lmkl_intel_ilp64 -lmkl_core -lmkl_intel_thread -lpthread -lm -o test1


I got the same error as previously with all three versions of compiler.

But, I use Debian, which is not supported OS, if I know it well. Maybe that's the problem, if you couldn't reproduce the error. I didn't mention it because I used AO and CAO separately without any problem.

Leave a Comment

Please sign in to add a comment. Not a member? Join today