Fortran double precision matrix multiplication using MIC

Fortran double precision matrix multiplication using MIC

Can someone send us an example makefile which uses the Fortran compiler and mkl to multiple 2 double precision matrices and compiles for mic.

We want to run this program on mic only (for testing). 

We have no problems to compile and run on the main processor!

Thanks, Renate

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

Here you go, a very simple example.This is how you build it for native execution on Xeon Phi (assuming you have Intel Fotran Composer XE installed on your system):

 ifort -mmic -I$MKLROOT/include dgemm_example.f -L$MKLROOT/lib/mic -lmkl_intel_lp64 -lmkl_core -lmkl_intel_thread -L$MKLROOT/../compiler/lib/mic -liomp5 -lpthread -lm

C*******************************************************************************
C   Copyright(C) 2012 Intel Corporation. All Rights Reserved.
C
C   The source code, information  and  material ("Material") contained herein is
C   owned  by Intel Corporation or its suppliers or licensors, and title to such
C   Material remains  with Intel Corporation  or its suppliers or licensors. The
C   Material  contains proprietary information  of  Intel or  its  suppliers and
C   licensors. The  Material is protected by worldwide copyright laws and treaty
C   provisions. No  part  of  the  Material  may  be  used,  copied, reproduced,
C   modified, published, uploaded, posted, transmitted, distributed or disclosed
C   in any way  without Intel's  prior  express written  permission. No  license
C   under  any patent, copyright  or  other intellectual property rights  in the
C   Material  is  granted  to  or  conferred  upon  you,  either  expressly,  by
C   implication, inducement,  estoppel or  otherwise.  Any  license  under  such
C   intellectual  property  rights must  be express  and  approved  by  Intel in
C   writing.
C
C   *Third Party trademarks are the property of their respective owners.
C
C   Unless otherwise  agreed  by Intel  in writing, you may not remove  or alter
C   this  notice or  any other notice embedded  in Materials by Intel or Intel's
C   suppliers or licensors in any way.
C
C*******************************************************************************

*   In this simple example memory management, data alignment, I/O, etc.
*   that are necessary for a good programming style are omitted to
*   improve readability.

      PROGRAM   MAIN

      INCLUDE "mkl.fi"

      DOUBLE PRECISION ALPHA, BETA
      INTEGER          I, J, K, N
      PARAMETER        (N=200)
      DOUBLE PRECISION A(N,N), B(N,N), C(N,N)
*
*      Executable Statements
*
*      Set input data
      ALPHA = 1.0
      BETA = 0.0
      DO I = 1, N
        DO J = 1, N
          A(I,J) = (I-1) * N + J
          B(I,J) = -((I-1) * N + J)
          A(I,J) = 0.0
          B(I,J) = 0.0
          C(I,J) = 0.0
        END DO
      END DO

      PRINT *, "Start!"
*      Call DGEMM subroutine
      CALL DGEMM('N','N',N,N,N,ALPHA,A,N,B,N,BETA,C,N)
      PRINT *, "Finished!"

      END

Leave a Comment

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