Skip to content

Commit

Permalink
Merge branch 'develop' into update_stdface
Browse files Browse the repository at this point in the history
  • Loading branch information
k-ido committed Sep 15, 2024
2 parents cb049b3 + 89e25b6 commit efecacf
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 8 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: brew
if: ${{ runner.os == 'macOS' }}
run: |
brew install openmpi scalapack libomp
brew install openmpi scalapack libomp blis
- name: Setup Python
uses: actions/setup-python@v5
Expand All @@ -52,13 +52,10 @@ jobs:
run: |
if [ ${{ runner.os }} = "macOS" ] ; then
# CONFIG=apple requires gfortran but macOS runner has not, but gfortran-11, 12, ...
ln -s `which gfortran-11` gfortran
env PATH=`pwd`:$PATH cmake -DCONFIG=apple -DCMAKE_VERBOSE_MAKEFILE=ON $GITHUB_WORKSPACE
cmake -DCONFIG=apple -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_Fortran_COMPILER=gfortran-14 $GITHUB_WORKSPACE
else
cmake -DCMAKE_VERBOSE_MAKEFILE=ON $GITHUB_WORKSPACE
fi
env:
HOMEBREW_PREFIX: /opt/homebrew
- name: build
working-directory: ${{runner.workspace}}/build
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(mVMC NONE)

option(USE_SCALAPACK "Use Scalapack" OFF)
Expand Down
2 changes: 1 addition & 1 deletion config/apple.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# additional libomp and gfortran installation required
# mac computers are suggested to use this configuration for better performance

if(NOT $ENV{HOMEBREW_PREFIX})
if(NOT DEFINED ENV{HOMEBREW_PREFIX})
message(FATAL "Homebrew is not installed. Please install Homebrew first.")
endif()

Expand Down
1 change: 1 addition & 0 deletions config/gcc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ 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_CXX_FLAGS_RELEASE "-O3 -Wno-unknown-pragmas ")
set(CMAKE_Fortran_COMPILER "gfortran" CACHE STRING "" FORCE)
2 changes: 1 addition & 1 deletion src/ltl2inv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ endif()
include_directories(../common)

# TODO: Move blalink_gemmt.c to other subprojects?
add_library(ltl2inv STATIC ltl2inv.cc blalink_gemmt.c ilaenv_lauum.cc)
add_library(ltl2inv STATIC ltl2inv.cc blalink_gemmt.c ilaenv_lauum.cc ilaenv_wrap.f90)
target_compile_definitions(ltl2inv PRIVATE -D_CC_IMPL)

3 changes: 3 additions & 0 deletions src/ltl2inv/ilaenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
extern "C" {
#endif

/*
int ilaenv_(const int *ispec, const char *name, const char *opts, const int *n1, const int *n2, const int *n3, const int *n4);
*/
int ilaenv_wrap(int ispec, const char *name, const char *opts, int n1, int n2, int n3, int n4);

#ifdef __cplusplus
}
Expand Down
29 changes: 29 additions & 0 deletions src/ltl2inv/ilaenv_lauum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
#include "ilaenv.h"
#include "ilaenv_lauum.hh"

/*
* sloppy version exploits that
* ILAENV(ispec=1, xLAUUM, "", dummy, dummy, dummy, dummy)
* returns 64 for x=S,D,C,Z .
*/

#undef SLOPPY_ILAENV
// #define SLOPPY_ILAENV

/*
#define EXPANDMAC(cctype, name) \
template <> int ilaenv_lauum<cctype>(uplo_t uplo, int n) \
{ \
Expand All @@ -15,6 +25,25 @@ template <> int ilaenv_lauum<cctype>(uplo_t uplo, int n) \
int dummy = 0; \
return ilaenv_(&ispec, #name, &uplo_, &n, &dummy, &dummy, &dummy); \
}
*/

#ifndef SLOPPY_ILAENV
#define EXPANDMAC(cctype, name) \
template <> int ilaenv_lauum<cctype>(uplo_t uplo, int n) \
{ \
char uplo_ = uplo2char(uplo); \
int ispec = 1; \
int dummy = -1; \
return ilaenv_wrap(ispec, #name, &uplo_, n, dummy, dummy, dummy); \
}
#else
#define EXPANDMAC(cctype, name) \
template <> int ilaenv_lauum<cctype>(uplo_t uplo, int n) \
{ \
return 64; \
}
#endif

EXPANDMAC( float, SLAUUM )
EXPANDMAC( double, DLAUUM )
EXPANDMAC( ccscmplx, CLAUUM )
Expand Down
37 changes: 37 additions & 0 deletions src/ltl2inv/ilaenv_wrap.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module wrapper
use, intrinsic :: iso_c_binding
implicit none
contains
function c_charptr_to_f_charptr(ccp) result(result)
type(c_ptr),intent(in),value :: ccp
character(:,c_char),pointer :: result
interface
function strlen(p) bind(c)
import c_ptr, c_size_t
type(c_ptr),value :: p
integer(c_size_t) strlen
end function strlen
end interface
result => convert_cptr(ccp,strlen(ccp))
contains
function convert_cptr(p, len)
type(c_ptr),intent(in) :: p
integer(c_size_t),intent(in) :: len
character(len, c_char),pointer :: convert_cptr
call c_f_pointer(p, convert_cptr)
end function convert_cptr
end function c_charptr_to_f_charptr

integer function ilaenv_wrap(ispec, name, opts, n1, n2, n3, n4) bind(c, name="ilaenv_wrap")
implicit none
integer,intent(in),value :: ispec, n1, n2, n3, n4
type(c_ptr),intent(in),value :: name, opts
character(:,c_char),pointer :: namef, optsf
integer ilaenv

namef => c_charptr_to_f_charptr(name)
optsf => c_charptr_to_f_charptr(opts)

ilaenv_wrap = ILAENV(ispec, namef, optsf, n1, n2, n3, n4)
end function ilaenv_wrap
end module wrapper

0 comments on commit efecacf

Please sign in to comment.