t-sakashita / rokko

Integrated Interface for libraries of eigenvalue decomposition
Boost Software License 1.0
10 stars 2 forks source link

Apple M3でELPAをビルド #618

Closed t-sakashita closed 1 month ago

t-sakashita commented 1 month ago

https://github.com/marekandreas/elpa/blob/master/documentation/INSTALL.md

t-sakashita commented 1 month ago

エラー

checking whether ELPA is allowed to limit the number of OpenMP threads at runtime... yes
configure: **************************************************************************************************************************
configure: * Please notice if the following step hangs or aborts abnormaly then you cannot run a short MPI-program during configure *
configure: * In this case please re-run configure with '--without-threading-support-check-during-build' _AND_ follow the hints in   *
configure: * the INSTALL and USER_GUIDE documents!                                                                                  *
configure: * In case you get some other warnings about threading support follow on of the steps detailed there                      *
configure: **************************************************************************************************************************
checking what threading level is supported by the MPI library... no
configure: WARNING: Your MPI implementation does not provide a sufficient threading level for OpenMP
configure: WARNING: You do have several options:
configure: WARNING:  * disable OpenMP (--disable-openmp): this will ensure correct results, but maybe some performance drop
configure: WARNING:  * use an MPI-library with the required threading support level (see the INSTALL and USER_GUIDE): this will 
configure: WARNING:    ensure correct results and best performance
configure: WARNING:  * allow ELPA at runtime to change the number of threads to 1 by setting "--enable-runtime-threading-support-checks
configure: WARNING:     --enable-allow-thread-limiting --without-threading-support-check-during-build": this will ensure correct results, but 
configure: WARNING:     maybe not the best performance (depends on the threading of your blas/lapack libraries), see the USER_GUIDE
configure: WARNING:  * switch of the checking of threading support "--disable-runtime-threading-support-checks 
configure: WARNING:    --without-threading-support-check-during-build: DO THIS AT YOUR OWN RISK! This will be fast, but might
configure: WARNING:    (depending on your MPI library sometimes) lead to wrong results
configure: error: You do have to take an action of the choices above!
Failed: ./configure LDFLAGS=-L/Users/sakashitatatsuya/rokko/scalapack/scalapack-2.2.0-2/Release/lib -L/opt/local/lib CXX=mpicxx CC=mpicc FC=mpif90 --disable-sse-assembly --disable-avx --disable-avx2 --disable-avx512 FCFLAGS=-O3 CFLAGS=-O3 --enable-openmp --prefix=/Users/sakashitatatsuya/rokko/elpa/elpa-2023.05.001-1/Release
t-sakashita commented 1 month ago

エラーメッセージで指示された--without-threading-support-check-during-buildを付ける。

エラー:

configure: error: Could not compile test program, try with --disable-sse, or adjust the C compiler or CFLAGS
Failed: ./configure LDFLAGS=-L/Users/sakashitatatsuya/rokko/scalapack/scalapack-2.2.0-2/Release/lib -L/opt/local/lib CXX=mpicxx CC=mpicc FC=mpif90 --without-threading-support-check-during-build --disable-sse-assembly --disable-avx --disable-avx2 --disable-avx512 FCFLAGS=-O3 CFLAGS=-O3 --disable-openmp --prefix=/Users/sakashitatatsuya/rokko/elpa/elpa-2024.05.001-1/Release
t-sakashita commented 1 month ago

--disable-sseを付けても、エラー:

  CC       src/helpers/check_thread_affinity.lo
src/helpers/check_thread_affinity.c:59:13: error: call to undeclared function 'sched_getcpu'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   59 |   *cpu_id = sched_getcpu();
      |             ^
src/helpers/check_thread_affinity.c:63:3: error: use of undeclared identifier 'cpu_set_t'
   63 |   cpu_set_t set;
      |   ^
src/helpers/check_thread_affinity.c:67:9: error: call to undeclared function 'sched_getaffinity'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   67 |   ret = sched_getaffinity(0, sizeof(cpu_set_t), &set);
      |         ^
src/helpers/check_thread_affinity.c:67:37: error: use of undeclared identifier 'cpu_set_t'
   67 |   ret = sched_getaffinity(0, sizeof(cpu_set_t), &set);
      |                                     ^
src/helpers/check_thread_affinity.c:67:50: error: use of undeclared identifier 'set'; did you mean 'ret'?
   67 |   ret = sched_getaffinity(0, sizeof(cpu_set_t), &set);
      |                                                  ^~~
      |                                                  ret
src/helpers/check_thread_affinity.c:64:7: note: 'ret' declared here
   64 |   int ret, i;
      |       ^
src/helpers/check_thread_affinity.c:68:17: error: use of undeclared identifier 'CPU_SETSIZE'
   68 |   for (i=0; i < CPU_SETSIZE; i++)
      |                 ^
src/helpers/check_thread_affinity.c:70:13: error: call to undeclared function 'CPU_ISSET'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   70 |       cpu = CPU_ISSET(i, &set);
      |             ^
src/helpers/check_thread_affinity.c:70:27: error: use of undeclared identifier 'set'; did you mean 'ret'?
   70 |       cpu = CPU_ISSET(i, &set);
      |                           ^~~
      |                           ret
src/helpers/check_thread_affinity.c:64:7: note: 'ret' declared here
   64 |   int ret, i;
      |       ^
8 errors generated.
make[1]: *** [src/helpers/check_thread_affinity.lo] Error 1
make: *** [all] Error 2
Failed: make
t-sakashita commented 1 month ago

--disable-affinity-checkingを指定しても、エラー:

Undefined symbols for architecture arm64:
  "___thread_affinity_MOD_check_thread_affinity", referenced from:
      import-atom in libelpa.dylib
  "___thread_affinity_MOD_cleanup_thread_affinity", referenced from:
      import-atom in libelpa.dylib
  "___thread_affinity_MOD_init_thread_affinity", referenced from:
      import-atom in libelpa.dylib
  "___thread_affinity_MOD_print_thread_affinity", referenced from:
      import-atom in libelpa.dylib
ld: symbol(s) not found for architecture arm64
t-sakashita commented 1 month ago

--enable-generic-kernelsを指定しても、同様のエラー

t-sakashita commented 1 month ago

Macでは、sched_getcpu関数が存在しない。 代替の関数を作る方法: https://www.hybridkernel.com/2015/01/18/binding_threads_to_cores_osx.html https://stackoverflow.com/questions/45227009/alternative-to-shed-getaffinity-cpu-set-t-etc

呼び出しているソースファイル:src/helpers/check_thread_affinity.c 該当箇所を全てコメントアウトしてみた。

void get_thread_affinity(int *cpu_id) {
  //*cpu_id = sched_getcpu();
}

void get_process_affinity(int cpu_id) {
  /*
  cpu_set_t set;
  int ret, i;
  int cpu;
  cpu_id = 9999999 ;
  ret = sched_getaffinity(0, sizeof(cpu_set_t), &set);
  for (i=0; i < CPU_SETSIZE; i++)
    {
      cpu = CPU_ISSET(i, &set);
      if (cpu == 1) { cpu_id = i; }
    }
  */
}

void get_process_id(int *process_id, int *pprocess_id) {
  /*
  int id;
  *process_id = 0;
  *pprocess_id = 0;
  id = getpid();
  *process_id = id ;
  id = getppid();
  *pprocess_id = id ; 
  //printf("My pid %d \n",*process_id);
  //printf("My ppid %d \n",*pprocess_id);
  */
}
t-sakashita commented 1 month ago
./configure 'LDFLAGS=-Wl,-ld_classic -L/Users/sakashitatatsuya/rokko/scalapack/scalapack-2.2.0-2/Debug/lib' CXX=mpicxx CC=mpicc FC=mpif90 --enable-c-tests=no --disable-sse --disable-runtime-threading-support-checks --with-fixed-real-kernel=generic_simple --disable-sse-assembly --disable-avx --disable-avx2 --disable-avx512 FCFLAGS=-O3 CFLAGS=-O3 --disable-openmp
t-sakashita commented 1 month ago

サンプルプログラムを実行と、以下のエラー:

./validate_real_single_solve_tridiagonal_1stage_toeplitz
dyld[72761]: Library not loaded: @rpath/libscalapack.dylib
  Referenced from: <B82CBCBE-FE4D-33DE-82D2-FA744970BCD0> /Users/sakashitatatsuya/Downloads/elpa-2024.05.001/.libs/validate_real_single_solve_tridiagonal_1stage_toeplitz
  Reason: tried: '/Users/sakashitatatsuya/Downloads/elpa-2024.05.001/.libs/libscalapack.dylib' (no such file), '/opt/local/lib/libgcc/libscalapack.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/local/lib/libgcc/libscalapack.dylib' (no such file), '/Users/sakashitatatsuya/Downloads/elpa-2024.05.001/.libs/libscalapack.dylib' (no such file), '/opt/local/lib/gcc14/gcc/aarch64-apple-darwin23/14.2.0/libscalapack.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/local/lib/gcc14/gcc/aarch64-apple-darwin23/14.2.0/libscalapack.dylib' (no such file), '/opt/local/lib/gcc14/libscalapack.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/local/lib/gcc14/libscalapack.dylib' (no such file), '/opt/local/lib/libgcc/libscalapack.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/local/lib/libgcc/libscalapack.dylib' (no such file), '/Users/sakashitatatsuya/Downloads/elpa-2024.05.001/.libs/libscalapack.dylib' (no such file), '/opt/local/lib/gcc14/gcc/aarch64-apple-darwin23/14.2.0/libscalapack.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/local/lib/gcc14/gcc/aarch64-apple-darwin23/14.2.0/libscalapack.dylib' (no such file), '/opt/local/lib/gcc14/libscalapack.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/local/lib/gcc14/libscalapack.dylib' (no such file), '/usr/local/lib/libscalapack.dylib' (no such file), '/usr/lib/libscalapack.dylib' (no such file, not in dyld cache)
t-sakashita commented 1 month ago

とりあえず、libscalapack.dylibをコピーしてみる。

cp /Users/sakashitatatsuya/rokko/scalapack/scalapack-2.2.0-2/Debug/lib/libscalapack.dylib .libs

./validate_real_single_solve_tridiagonal_1stage_toeplitzが実行できた。

t-sakashita commented 1 month ago

以下

export DYLD_LIBRARY_PATH=/Users/sakashitatatsuya/rokko/scalapack/scalapack-2.2.0-2/Debug/lib:$DYLD_LIBRARY_PATH

を実行しても、

dyld[72761]: Library not loaded: @rpath/libscalapack.dylib

となってしまう。