Quantcast
Channel: Intel® Software - Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 3005

complex-valued scalar products

$
0
0

Is there any problem calling BLAS functions zdotc, zdotu in recent version of MKL?

When calling these functions from a C-code using recent version of the MKL, the code crashes or returns fault values. It works properly when using soft-coded FORTRAN BLAS. I am using LINUX, I tried three different versions of the MKL (2018.5.274, 2019.1.144 und 2019.3.199).

 

Here is how I call the MKL

cc -O -fPIC -fopenmp -m64 -mcmodel=medium -I $MKLROOT/include test.c -L $MKLROOT/lib -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lm

 

Here is a sample C-code

#include <stdio.h>
#include <stdlib.h>

typedef struct { double r, i; } doublecomplex;

doublecomplex zdotc_(int *,doublecomplex *,int *, doublecomplex *,int *),
                         zdotu_(int *,doublecomplex *,int *, doublecomplex *,int *);

#define N 4

int main(int argc, char **argv)
{
  doublecomplex *v, *w, val;
  int i=N,j=1,k=2,l,m;
  v=(doublecomplex *)malloc((size_t)N  *sizeof(doublecomplex));
  w=(doublecomplex *)malloc((size_t)2*N*sizeof(doublecomplex));

  for (l=0; l<N; l++) {
      v[l].r  = 1.0; v[l].i  =(double)l;

      w[l].r  =-1.0; w[l].i  = 1.0;
      w[N+l].r= 1.0; w[N+l].i= 0.0;
  }

  val=zdotc_(&i, v,&j, w,&k);
  printf("val=(%8.1le,%8.1le)\n",val.r,val.i);

  val=zdotu_(&i, v,&j, w,&k);
  printf("val=(%8.1le,%8.1le)\n",val.r,val.i);

  free(v);
  free(w);
 
  return 0;
}

 


Viewing all articles
Browse latest Browse all 3005

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>