llvm-new-flang / workload-by-flang

The guide to build workloads using LLVM Flang
Apache License 2.0
0 stars 0 forks source link

Build workload DFTB+ using LLVM Flang #1

Open Wang-Zhewei opened 2 years ago

Wang-Zhewei commented 2 years ago

As described in installation documentation, LAPACK/BLAS is one of the requirements ( https://github.com/dftbplus/dftbplus/blob/main/INSTALL.rst#:~:text=LAPACK/BLAS%20libraries%20(or%20compatible%20equivalents) ).

  1. When I built lapack, I found that flang-new dose not support ETIME, so I modified the file "make.inc" to set "TIMER = INT_CPU_TIME" but not "TIMER = INT_ETIME". then I can build successfully. So will the ETIME feature be supported in the future?
  2. When I test blas and lapack with c code like this:
    
    #include <stdio.h>
    #include "cblas.h"

int main() { const int dim=2; double a[4]={1.0,1.0,1.0,1.0},b[4]={2.0,2.0,2.0,2.0},c[4]; int m=dim,n=dim,k=dim,lda=dim,ldb=dim,ldc=dim; double al=1.0,be=0.0; cblas_dgemm(101,111,111,m,n,k,al,a,lda,b,ldb,be,c,ldc); printf("the matrix c is:%f,%f\n%f,%f\n",c[0],c[1],c[2],c[3]); return 0; }

but I cannot found the correct command line to run this code. The command I used is the following:
`clang test_blas.c -o test -lcblas  -lrefblas  -lm -lflang-new`
The last option I have tried various but failed.
 3. After configuring cmake, I build dftb+ with the following command:
`cmake --build _build -- -j 4`
but it failed like this:

error: loc("/root/DFTBPLUS/dftbplus-22.1/external/xmlf90/charset.f90":15:52): /root/flang-install-f18/llvm-project/flang/lib/Lower/ConvertType.cpp:308: not yet implemented: derived type components with non default lower bounds [ 2%] Building Fortran object external/xmlf90/CMakeFiles/xmlf90_objlib.dir/dom_debug.f90.o external/xmlf90/CMakeFiles/xmlf90_objlib.dir/build.make:87: recipe for target 'external/xmlf90/CMakeFiles/xmlf90_objlib.dir/charset.f90.o' failed make[2]: [external/xmlf90/CMakeFiles/xmlf90_objlib.dir/charset.f90.o] Error 1 make[2]: Waiting for unfinished jobs.... error: Semantic errors in /root/DFTBPLUS/dftbplus-22.1/external/ddcosmo/ddcosmo_core.F90 /root/DFTBPLUS/dftbplus-22.1/external/ddcosmo/ddcosmo_core.F90:164:12: error: The DEFAULT(NONE) clause requires that 'ylmbas' must be listed in a data-sharing attribute clause call ylmbas(self, self%grid(:, i), self%basis(:, i), vplm, vcos, vsin) ^^^^^^ /root/DFTBPLUS/dftbplus-22.1/external/ddcosmo/ddcosmo_core.F90:306:16: error: The DEFAULT(NONE) clause requires that 'fsw' must be listed in a data-sharing attribute clause xt = fsw(t, se, self%eta) ^^^ /root/DFTBPLUS/dftbplus-22.1/external/ddcosmo/ddcosmo_core.F90:313:19: error: The DEFAULT(NONE) clause requires that 'dfsw' must be listed in a data-sharing attribute clause fac = dfsw(t, se, self%eta) / self%rvdw(jat) ^^^^ external/ddcosmo/CMakeFiles/ddcosmo_objlib.dir/build.make:74: recipe for target 'external/ddcosmo/CMakeFiles/ddcosmo_objlib.dir/ddcosmo_core.F90.o' failed make[2]: [external/ddcosmo/CMakeFiles/ddcosmo_objlib.dir/ddcosmo_core.F90.o] Error 1 CMakeFiles/Makefile2:857: recipe for target 'external/ddcosmo/CMakeFiles/ddcosmo_objlib.dir/all' failed make[1]: [external/ddcosmo/CMakeFiles/ddcosmo_objlib.dir/all] Error 2 make[1]: Waiting for unfinished jobs.... flang-new: warning: argument unused during compilation: '-flang-experimental-exec' CMakeFiles/Makefile2:831: recipe for target 'external/xmlf90/CMakeFiles/xmlf90_objlib.dir/all' failed make[1]: [external/xmlf90/CMakeFiles/xmlf90_objlib.dir/all] Error 2 Makefile:145: recipe for target 'all' failed make: *** [all] Error 2

error: Semantic errors in /home/wzw/dftb+/dftbplus-22.1/external/ddcosmo/ddcosmo_core.F90 /home/wzw/dftb+/dftbplus-22.1/external/ddcosmo/ddcosmo_core.F90:164:12: error: The DEFAULT(NONE) clause requires that 'ylmbas' must be listed in a data-sharing attribute clause call ylmbas(self, self%grid(:, i), self%basis(:, i), vplm, vcos, vsin) ^^^^^^ /home/wzw/dftb+/dftbplus-22.1/external/ddcosmo/ddcosmo_core.F90:306:16: error: The DEFAULT(NONE) clause requires that 'fsw' must be listed in a data-sharing attribute clause xt = fsw(t, se, self%eta) ^^^ /home/wzw/dftb+/dftbplus-22.1/external/ddcosmo/ddcosmo_core.F90:313:19: error: The DEFAULT(NONE) clause requires that 'dfsw' must be listed in a data-sharing attribute clause fac = dfsw(t, se, self%eta) / self%rvdw(jat) ^^^^ make[2]: [external/ddcosmo/CMakeFiles/ddcosmo_objlib.dir/build.make:75:external/ddcosmo/CMakeFiles/ddcosmo_objlib.dir/ddcosmo_core.F90.o] 错误 1 make[1]: [CMakeFiles/Makefile2:858:external/ddcosmo/CMakeFiles/ddcosmo_objlib.dir/all] 错误 2 make[1]: 正在等待未完成的任务.... make[1]: [CMakeFiles/Makefile2:832:external/xmlf90/CMakeFiles/xmlf90_objlib.dir/all] 错误 2 make: *** [Makefile:146:all] 错误 2


The first one is under the aarch64 architecture, the second under the x86 architecture. And I don't know if it's because lapack is not installed completely, or it's some other configuration problem.
PeixinQiao commented 2 years ago

If you are building DFTB+ on aarch64, you can try the following to avoid building BLAS and LAPACK.

sudo yum install openblas.aarch64 lapack.aarch64

There should be equivalent packages on X86_64.

but I cannot found the correct command line to run this code. The command I used is the following: clang test_blas.c -o test -lcblas -lrefblas -lm -lflang-new The last option I have tried various but failed.

You don't need the last option. -lcblas should give you the function definition of cblas_dgemm. But you should add the library path to LD_LIBRARY_PATH, and maybe you need to add the path of header file cblas.h as follows:

clang test_blas.c -o test -lcblas -lrefblas -lm -I/path-to-cblas-header-file