Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake Support for Blocked Pfaffian #26

Merged
merged 8 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)
project(mVMC NONE)

option(USE_SCALAPACK "Use Scalapack" OFF)
option(PFAFFIAN_BLOCKED "Use blocked-update Pfaffian to speed up." OFF)

add_definitions(-D_mVMC)
if(CONFIG)
Expand All @@ -15,6 +16,10 @@ message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})

option(BUILD_SHARED_LIBS "Build shared libraries" ON)
enable_language(C Fortran)
if(PFAFFIAN_BLOCKED)
enable_language(CXX)
set(CMAKE_CXX_STANDARD 11)
endif(PFAFFIAN_BLOCKED)

set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_SKIP_BUILD_RPATH FALSE)
Expand Down Expand Up @@ -57,6 +62,14 @@ if(USE_SCALAPACK MATCHES OFF)
endif(LAPACK_FOUND)
endif()

if(PFAFFIAN_BLOCKED)
add_definitions(-D_pf_block_update)
include("download_blis_artifact.cmake")
# Must set BLIS artifact BEFORE adding pfupdates target.
add_subdirectory(src/pfupdates)
add_dependencies(pfupdates blis_include)
endif(PFAFFIAN_BLOCKED)

add_subdirectory(src/ComplexUHF)
add_subdirectory(src/pfapack/fortran)
add_subdirectory(src/mVMC)
Expand Down
16 changes: 16 additions & 0 deletions config/aocc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# for AOCC

set(CMAKE_C_COMPILER "clang" CACHE STRING "" FORCE)
set(CMAKE_CXX_COMPILER "clang++" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_DEBUG "-g -O0 -Wall -Wformat -Werror=format-security")
set(CMAKE_C_FLAGS_RELEASE "-Wno-unknown-pragmas -O3 -DNDEBUG -DHAVE_SSE2" CACHE STRING "" FORCE)

set(CMAKE_Fortran_COMPILER "flang" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -DNDEBUG -DHAVE_SSE2" CACHE STRING "" FORCE)

# for AOCL
set(BLA_VENDOR "FLAME" CACHE STRING "" FORCE)

# for BLIS & block pfaffian
set(BLIS_ARTIFACT_CONFIG "amd64")
set(PFAFFIAN_BLOCKED ON)
1 change: 1 addition & 0 deletions config/apple.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# additional libomp and gfortran installation required
# mac computers are suggested to use this configuration for better performance
set(CMAKE_C_COMPILER "clang" CACHE STRING "" FORCE)
set(CMAKE_CXX_COMPILER "clang++" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_DEBUG "-g -O0 -Wall -Wformat -Werror=format-security")
set(CMAKE_C_FLAGS_RELEASE "-O3 -Wno-unknown-pragmas -Wno-logical-not-parentheses")
set(CMAKE_Fortran_COMPILER "gfortran" CACHE STRING "" FORCE)
Expand Down
20 changes: 20 additions & 0 deletions config/fugaku.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# for Fujitsu Compiler in Clang-mode
set(CMAKE_C_COMPILER "mpifccpx" CACHE STRING "" FORCE)
set(CMAKE_CXX_COMPILER "mpiFCCpx" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELEASE "-Nclang -Ofast -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "-Nclang -Ofast -DNDEBUG" CACHE STRING "" FORCE)

set(CMAKE_Fortran_COMPILER "mpifrtpx" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_RELEASE "-Kfast,parallel -DNDEBUG -DFUJITSU" CACHE STRING "" FORCE)

set(OpenMP_C_FLAGS "-fopenmp" CACHE STRING "" FORCE)
set(OpenMP_Fortran_FLAGS "-Kopenmp" CACHE STRING "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS "-fopenmp" CACHE STRING "" FORCE)

# for SSL2
set(BLAS_LIBRARIES "-SSL2" CACHE STRING "" FORCE)
set(LAPACK_LIBRARIES ${BLAS_LIBRARIES} CACHE STRING "" FORCE)

# for BLIS & block pfaffian
set(BLIS_ARTIFACT_CONFIG "a64fx")
set(PFAFFIAN_BLOCKED ON)
2 changes: 2 additions & 0 deletions config/fujitsu.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# for Fujitsu Compiler
set(CMAKE_C_COMPILER "mpifccpx" CACHE STRING "" FORCE)
set(CMAKE_CXX_COMPILER "mpiFCCpx" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -Kfast,parallel -Kmemalias,alias_const" CACHE STRING "" FORCE)
set(OpenMP_C_FLAGS "-Kopenmp" CACHE STRING "" FORCE)
set(CMAKE_Fortran_COMPILER "mpifrtpx" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_RELEASE "-DNDEBUG -DFUJITSU -Kfast,parallel" CACHE STRING "" FORCE)
set(OpenMP_Fortran_FLAGS "-Kopenmp" CACHE STRING "" FORCE)
set(MPI_EXTRA_LIBRARY "-lmpi_f90 -lmpi_f77" CACHE STRING "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS "-Kopenmp" CACHE STRING "" FORCE)

# for SSL2
set(BLAS_LIBRARIES "-SSL2" CACHE STRING "" FORCE)
Expand Down
3 changes: 2 additions & 1 deletion config/gcc.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# for GCC Compiler
set(CMAKE_C_COMPILER "gcc" CACHE STRING "" FORCE)
set(CMAKE_CXX_COMPILER "g++" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_DEBUG "-g -O0 -Wall -Wformat -Werror=format-security")
set(CMAKE_C_FLAGS_RELEASE "-O3 -Wno-unknown-pragmas ")
Set(CMAKE_Fortran_COMPILER "gfortran" CACHE STRING "" FORCE)
set(CMAKE_Fortran_COMPILER "gfortran" CACHE STRING "" FORCE)
5 changes: 5 additions & 0 deletions config/intel.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# for Intel Compiler

set(CMAKE_C_COMPILER "icc" CACHE STRING "" FORCE)
set(CMAKE_CXX_COMPILER "icpc" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -Wall -Wformat -Werror=format-security")
set(CMAKE_C_FLAGS_RELEASE "-Wno-unknown-pragmas -O3 -DNDEBUG -DHAVE_SSE2" CACHE STRING "" FORCE)

Expand All @@ -9,3 +10,7 @@ set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -DNDEBUG -DHAVE_SSE2" CACHE STRING "" FORCE

# for Intel MKL
set(BLA_VENDOR "Intel10_64lp" CACHE STRING "" FORCE)

# for BLIS & block pfaffian
set(BLIS_ARTIFACT_CONFIG "intel64")
set(PFAFFIAN_BLOCKED ON)
17 changes: 0 additions & 17 deletions config/sekirei.cmake

This file was deleted.

62 changes: 62 additions & 0 deletions download_blis_artifact.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
if(NOT DEFINED BLIS_ARTIFACT_CONFIG)
execute_process(
COMMAND uname -m
COMMAND tr -d '\n'
OUTPUT_VARIABLE ARCHITECTURE)
if(${ARCHITECTURE} STREQUAL "x86_64")
execute_process(
COMMAND cat /proc/cpuinfo
COMMAND grep Intel
COMMAND head -1
COMMAND tr -d '\n'
OUTPUT_VARIABLE UARCH_INTEL)
if(NOT "${UARCH_INTEL} " STREQUAL " ")
set(BLIS_ARTIFACT_CONFIG "intel64")
else()
set(BLIS_ARTIFACT_CONFIG "amd64")
endif()
elseif(${ARCHITECTURE} STREQUAL "aarch64" OR
${ARCHITECTURE} STREQUAL "arm64")
# Currently SVE requires being set manually.
set(BLIS_ARTIFACT_CONFIG "arm64")
else()
message(FATAL_ERROR "Failed to recognize architecture ${ARCHITECTURE}.")
endif()
endif(NOT DEFINED BLIS_ARTIFACT_CONFIG)

message(STATUS "Downloading BLIS artifact...")

set(BLIS_ARCHIVE ${CMAKE_CURRENT_BINARY_DIR}/libblis_artifact.tar.gz)
if(${BLIS_ARTIFACT_CONFIG} STREQUAL "intel64")
set(BLIS_ARTIFACT_URL https://github.com/xrq-phys/blis/releases/download/sv0.8.1+arm/libblis_intel64_gcc.tar.gz)
elseif(${BLIS_ARTIFACT_CONFIG} STREQUAL "amd64")
set(BLIS_ARTIFACT_URL https://github.com/xrq-phys/blis/releases/download/sv0.8.1+arm/libblis_amd64_gcc.tar.gz)
elseif(${BLIS_ARTIFACT_CONFIG} STREQUAL "arm64")
set(BLIS_ARTIFACT_URL https://github.com/xrq-phys/blis/releases/download/sv0.8.1+arm/libblis_cortexa57_aarch64-linux-gnu-gcc.tar.gz)
elseif(${BLIS_ARTIFACT_CONFIG} STREQUAL "armsve")
set(BLIS_ARTIFACT_URL https://github.com/xrq-phys/blis/releases/download/sv0.8.1+arm/libblis_armsve_aarch64-linux-gnu-gcc-10.tar.gz)
elseif(${BLIS_ARTIFACT_CONFIG} STREQUAL "a64fx")
set(BLIS_ARTIFACT_URL https://github.com/xrq-phys/blis/releases/download/sv0.8.1+arm/libblis_a64fx_aarch64-linux-gnu-gcc-10.tar.gz)
else()
message(FATAL_ERROR "Not BLIS artifact available.")
endif()

message("${BLIS_ARTIFACT_URL} ${BLIS_ARCHIVE}")
file(DOWNLOAD "${BLIS_ARTIFACT_URL}" "${BLIS_ARCHIVE}")

add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lib/libblis.a
${CMAKE_CURRENT_BINARY_DIR}/include/blis/blis.h
COMMAND ${CMAKE_COMMAND} -E tar -zxf ${BLIS_ARCHIVE}
DEPENDS ${BLIS_ARCHIVE})
add_custom_target(blis_target
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lib/libblis.a)
add_custom_target(blis_include
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/include/blis/blis.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/blis)

add_library(blis STATIC IMPORTED GLOBAL)
set_target_properties(blis PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/lib/libblis.a)
add_dependencies(blis blis_target)

6 changes: 5 additions & 1 deletion src/mVMC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ add_executable(vmcdry.out vmcdry.c)
target_link_libraries(vmcdry.out StdFace m)
add_executable(vmc.out ${SOURCES_vmcmain} ${SOURCES_sfmt})
target_link_libraries(vmc.out StdFace)
target_link_libraries(vmc.out pfapack StdFace ${LAPACK_LIBRARIES} m)
target_link_libraries(vmc.out pfapack)
if(PFAFFIAN_BLOCKED)
target_link_libraries(vmc.out pfupdates blis pthread)
endif(PFAFFIAN_BLOCKED)
target_link_libraries(vmc.out ${LAPACK_LIBRARIES} m)

if(USE_SCALAPACK)
string(REGEX REPLACE "-L[ ]+" "-L" sc_libs ${SCALAPACK_LIBRARIES})
Expand Down
15 changes: 10 additions & 5 deletions src/mVMC/vmcmake.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,16 @@ void VMCMakeSample(MPI_Comm comm) {
// TODO: Compute from qpStart to qpEnd to support loop splitting.
void *pfOrbital[NQPFull];
void *pfUpdator[NQPFull];
// TODO: Make it input parameter.
if (NExUpdatePath == 0)
NBlockUpdateSize = 4;
else
NBlockUpdateSize = 20;
// Read block size from input.
const char *optBlockSize = getenv("VMC_BLOCK_UPDATE_SIZE");
if (optBlockSize)
NBlockUpdateSize = atoi(optBlockSize);
// Fall back to default if input is invalid.
if (NBlockUpdateSize < 1 || NBlockUpdateSize > 100)
if (NExUpdatePath == 0)
NBlockUpdateSize = 4;
else
NBlockUpdateSize = 20;

// Set one universal EleSpn.
for (mi=0; mi<Ne; mi++) EleSpn[mi] = 0;
Expand Down
15 changes: 10 additions & 5 deletions src/mVMC/vmcmake_fsz.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,16 @@ void VMCMakeSample_fsz(MPI_Comm comm) {
// TODO: Compute from qpStart to qpEnd to support loop splitting.
void *pfOrbital[NQPFull];
void *pfUpdator[NQPFull];
// TODO: Make it input parameter.
if (NExUpdatePath == 0)
NBlockUpdateSize = 4;
else
NBlockUpdateSize = 20;
// Read block size from input.
const char *optBlockSize = getenv("VMC_BLOCK_UPDATE_SIZE");
if (optBlockSize)
NBlockUpdateSize = atoi(optBlockSize);
// Fall back to default if input is invalid.
if (NBlockUpdateSize < 1 || NBlockUpdateSize > 100)
if (NExUpdatePath == 0)
NBlockUpdateSize = 4;
else
NBlockUpdateSize = 20;

// Initialize with free spin configuration.
updated_tdi_v_init_z(NQPFull, Nsite, Nsite2, Nsize,
Expand Down
15 changes: 10 additions & 5 deletions src/mVMC/vmcmake_real.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,16 @@ void VMCMakeSample_real(MPI_Comm comm) {
// TODO: Compute from qpStart to qpEnd to support loop splitting.
void *pfOrbital[NQPFull];
void *pfUpdator[NQPFull];
// TODO: Make it input parameter.
if (NExUpdatePath == 0)
NBlockUpdateSize = 2;
else
NBlockUpdateSize = 20;
// Read block size from input.
const char *optBlockSize = getenv("VMC_BLOCK_UPDATE_SIZE");
if (optBlockSize)
NBlockUpdateSize = atoi(optBlockSize);
// Fall back to default if input is invalid.
if (NBlockUpdateSize < 1 || NBlockUpdateSize > 100)
if (NExUpdatePath == 0)
NBlockUpdateSize = 2;
else
NBlockUpdateSize = 20;

// Set one universal EleSpn.
for (mi=0; mi<Ne; mi++) EleSpn[mi] = 0;
Expand Down
18 changes: 18 additions & 0 deletions src/pfupdates/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# include guard
cmake_minimum_required(VERSION 2.8.0 )

if(${CMAKE_PROJECT_NAME} STREQUAL "Project")
message(FATAL_ERROR "cmake should be executed not for 'src' subdirectory, but for the top directory of mVMC.")
endif(${CMAKE_PROJECT_NAME} STREQUAL "Project")

add_definitions(-DBLAS_EXTERNAL)
add_definitions(-DF77_COMPLEX_RET_INTEL)
include_directories(../pfaffine/src)

add_library(pfupdates STATIC
pf_interface.cc
../pfaffine/src/skpfa.cc
../pfaffine/src/sktdf.cc
../pfaffine/src/sktdi.cc)
target_compile_definitions(pfupdates PRIVATE -D_CC_IMPL)