I have written the following simple program for syrk using armadillo (arma.sourceforge.net).
Environment : Rhea from OLCF. https://www.olcf.ornl.gov/computing-resources/rhea/
MKL : Tried with version 16 and 17. Problem occurs in both.
#define ARMA_DONT_USE_WRAPPER #define ARMA_USE_BLAS #include <iostream> #include <armadillo> using namespace std; using namespace arma; int main() { int m = 10000; int n = 50; fmat A; A.load("H_init.csv"); cout << "A::"<< A.n_rows << "x"<< A.n_cols << endl; fmat AtA = arma::zeros<fmat>(n, n); AtA = A.t() * A; cout << "AtA "<< endl; cout << max(max(AtA)) << ""<< min(min(AtA)) << ""<< norm(AtA, "fro") << endl; return 0; }
I have also attached the H_init.csv along with this email. I compile using the following three procedure.
Compilation 1 (gcc with mkl): Based on the article https://software.intel.com/en-us/articles/a-new-linking-model-single-dyn.... I compile as "g++ hth.cpp -o hth -O2 -I ~/armadillo-7.800.1/include/ -fopenmp -lmkl_rt"
Compilation 2 (with icc and mkl): icc hth.cpp -o hth -O2 -I ~/armadillo-7.800.1/include/ -fopenmp -mkl
Compilation 3 (gcc with intel linker recommendation): g++ hth.cpp -o hth -O2 -I ~/armadillo-7.800.1/include/ -fopenmp -lmkl_rt -L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_ilp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl
Compilation based on method compilation 1 is producing wrong output on HtH. Compilation 2 and 3 works fine. Infact in the case of compilation 3, even the ordering of the libraries appears important. If the ordering is change a bit, it is producing wrong output.
Output of compile 1: (Wrong)
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo}
span.s1 {font-variant-ligatures: no-common-ligatures}
A::10000x50
AtA
24044.6 3697.91 350951
Output out of compile 2: (Right)
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo}
span.s1 {font-variant-ligatures: no-common-ligatures}
A::10000x50
AtA
3436.05 2437.46 126222
Output out of compile 3: (Right)
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo}
span.s1 {font-variant-ligatures: no-common-ligatures}
A::10000x50
AtA
3436.05 2437.46 126222
Am I making any mistake on this? Can't I link w/ gcc using -lmkl_rt?
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #5330e1}
span.s1 {font-variant-ligatures: no-common-ligatures}