Skip to content

Commit

Permalink
change eigen include
Browse files Browse the repository at this point in the history
  • Loading branch information
jinluchang committed Sep 8, 2024
1 parent d3610c3 commit 4074262
Show file tree
Hide file tree
Showing 13 changed files with 169 additions and 13 deletions.
3 changes: 2 additions & 1 deletion nixpkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ let
overlays = [];
};
qlat-pkgs = {
inherit cuba qlat_utils qlat c-lime grid-lehner gpt-lehner;
inherit cuba qlat_utils qlat qlat_grid c-lime grid-lehner gpt-lehner;
};
cuba = pkgs.callPackage ./cuba.nix {};
qlat_utils = pkgs.python3Packages.callPackage ./qlat_utils.nix { inherit cuba; };
qlat = pkgs.python3Packages.callPackage ./qlat.nix { inherit cuba qlat_utils; };
qlat_grid = pkgs.python3Packages.callPackage ./qlat_grid.nix { inherit cuba qlat_utils qlat c-lime grid-lehner; };
c-lime = pkgs.callPackage ./c-lime.nix {};
grid-lehner = pkgs.callPackage ./grid-lehner.nix { inherit c-lime; };
gpt-lehner = pkgs.python3Packages.callPackage ./gpt-lehner.nix { inherit c-lime grid-lehner; };
Expand Down
97 changes: 97 additions & 0 deletions nixpkgs/qlat_grid.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{ lib
, stdenv
, fetchPypi
, python
, buildPythonPackage
, setuptools
, setuptools-scm
, cython
, meson-python
, pkg-config
, numpy
, mpi4py
, sympy
, qlat_utils
, qlat
, grid-lehner
, hdf5
, openssl
, gmp
, mpfr
, c-lime
, psutil
, zlib
, eigen
, cuba
, mpi
, git
, fftw
, fftwFloat
, gsl
}:

buildPythonPackage rec {

pname = "qlat_grid";
version = "0.68";

pyproject = true;

src = fetchPypi {
inherit pname version;
extension = "tar.gz";
hash = "sha256-Gr1Ru0aMvzK5D38IHaIKpDVtl8qjFhGxAIEL+Kg8KLg=";
};

enableParallelBuilding = true;

build-system = [
meson-python
pkg-config
cython
numpy
qlat_utils
qlat
];

nativeBuildInputs = [
git
grid-lehner
];

buildInputs = [
mpi
grid-lehner
hdf5
openssl
gmp
mpfr
c-lime
zlib
eigen
cython
fftw
fftwFloat
gsl
cuba
];

dependencies = [
mpi
eigen
cuba
cython
numpy
psutil
qlat_utils
qlat
grid-lehner
mpi4py
sympy
];

postPatch = ''
sed -i "s/'-j4'/'-j$NIX_BUILD_CORES'/" pyproject.toml
'';

}
1 change: 1 addition & 0 deletions nixpkgs/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ in pkgs.mkShell {
wheel
local-pkgs.qlat_utils
local-pkgs.qlat
local-pkgs.qlat_grid
local-pkgs.gpt-lehner
]))
];
Expand Down
12 changes: 10 additions & 2 deletions qlat-cps/depend-qlat/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,19 @@ qlat_numpy = declare_dependency(
dependencies: [ qlat_py3.dependency(), ],
).as_system()

if qlat_cpp.check_header('Eigen/Eigen')
qlat_eigen_type = run_command(qlat_py3, '-c', 'import qlat as q ; print(q.get_eigen_type())',
env: environment({'q_verbose': '-1'}),
check: true).stdout().strip()
message('qlat_eigen_type', qlat_eigen_type)

if qlat_eigen_type == 'grid'
assert(qlat_cpp.check_header('Grid/Eigen/Eigen'))
qlat_eigen = dependency('', required: false)
elif qlat_cpp.check_header('Grid/Eigen/Eigen')
elif qlat_cpp.check_header('Eigen/Eigen')
assert(qlat_eigen_type == 'system')
qlat_eigen = dependency('', required: false)
else
assert(qlat_eigen_type == 'system')
qlat_eigen = dependency('eigen3').as_system()
endif

Expand Down
12 changes: 10 additions & 2 deletions qlat-grid/depend-qlat/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,19 @@ qlat_numpy = declare_dependency(
dependencies: [ qlat_py3.dependency(), ],
).as_system()

if qlat_cpp.check_header('Eigen/Eigen')
qlat_eigen_type = run_command(qlat_py3, '-c', 'import qlat as q ; print(q.get_eigen_type())',
env: environment({'q_verbose': '-1'}),
check: true).stdout().strip()
message('qlat_eigen_type', qlat_eigen_type)

if qlat_eigen_type == 'grid'
assert(qlat_cpp.check_header('Grid/Eigen/Eigen'))
qlat_eigen = dependency('', required: false)
elif qlat_cpp.check_header('Grid/Eigen/Eigen')
elif qlat_cpp.check_header('Eigen/Eigen')
assert(qlat_eigen_type == 'system')
qlat_eigen = dependency('', required: false)
else
assert(qlat_eigen_type == 'system')
qlat_eigen = dependency('eigen3').as_system()
endif

Expand Down
7 changes: 5 additions & 2 deletions qlat-utils/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ numpy = declare_dependency(
dependencies: [ py3.dependency(), ],
).as_system()

if cpp.check_header('Eigen/Eigen')
if cpp.check_header('Grid/Eigen/Eigen')
eigen_type = 'grid'
eigen = dependency('', required: false)
elif cpp.check_header('Grid/Eigen/Eigen')
elif cpp.check_header('Eigen/Eigen')
eigen_type = 'system'
eigen = dependency('', required: false)
else
eigen_type = 'system'
eigen = dependency('eigen3').as_system()
endif

Expand Down
2 changes: 2 additions & 0 deletions qlat-utils/qlat_utils/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@
'get_all_caches_info',
'clear_all_caches',
'clear_mem_cache',
#
'get_eigen_type',
]

__all__ += [
Expand Down
5 changes: 5 additions & 0 deletions qlat-utils/qlat_utils/cutils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,8 @@ def clear_all_caches():

def clear_mem_cache():
cc.clear_mem_cache()

### -------------------------------------------------------------------

def get_eigen_type():
return cc.get_eigen_type()
4 changes: 4 additions & 0 deletions qlat-utils/qlat_utils/everything.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ cdef extern from "qlat-utils/show.h" namespace "qlat":
void set_display_ptr(DisplayPtr f) except +
void display(const std_string& str) except +

cdef extern from "qlat-utils/eigen.h" namespace "qlat":

std_string get_eigen_type() except +

cdef extern from "qlat-utils/timer.h" namespace "qlat":

int get_id_node()
Expand Down
14 changes: 14 additions & 0 deletions qlat-utils/qlat_utils/include/qlat-utils/eigen.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,24 @@

#include <Grid/Eigen/Eigen>

namespace qlat
{

inline std::string get_eigen_type() { return "grid"; }

} // namespace qlat

#else

#include <Eigen/Eigen>

namespace qlat
{

inline std::string get_eigen_type() { return "system"; }

} // namespace qlat

#endif

// -------------------------------------------------------------------------------------
Expand Down
8 changes: 5 additions & 3 deletions qlat-utils/qlat_utils/include/qlat-utils/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ else
error('Cannot find endian.h header file.')
endif

if cpp.check_header('Eigen/Eigen', dependencies: deps)
conf_data.set('QLAT_USE_GRID_EIGEN', false)
elif cpp.check_header('Grid/Eigen/Eigen', dependencies: deps)
if eigen_type == 'grid'
conf_data.set('QLAT_USE_GRID_EIGEN', true)
elif eigen_type == 'plain' or eigen_type == 'system'
conf_data.set('QLAT_USE_GRID_EIGEN', false)
else
error('eigen_type not correct')
endif

if quadmath.found()
Expand Down
5 changes: 4 additions & 1 deletion qlat-utils/qlat_utils/scripts/qlat_utils_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

usage_message = """
Usage:
python3 -m qlat_utils qlat-utils-config [--cxxflags] [--ldflags] [--libs] [--LD_LIBRARY_PATH]
python3 -m qlat_utils qlat-utils-config [--cxxflags] [--ldflags] [--libs] [--LD_LIBRARY_PATH] [--eigen-type]
""".strip()

if len(sys.argv) < 2:
print(usage_message)
exit()

from ..get_include_dir import get_include_list, get_lib_list, get_new_ld_library_path
from ..c import get_eigen_type

output_args = []

Expand All @@ -22,6 +23,8 @@
output_args += [ "-lqlat-utils", ]
elif arg == "--LD_LIBRARY_PATH":
output_args = [ get_new_ld_library_path(), ]
elif arg == "--eigen-type":
output_args = [ get_eigen_type(), ]

print(" ".join(output_args))

Expand Down
12 changes: 10 additions & 2 deletions qlat/depend-qlat-utils/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ qlat_utils_numpy = declare_dependency(
dependencies: [ qlat_utils_py3.dependency(), ],
).as_system()

if qlat_utils_cpp.check_header('Eigen/Eigen')
qlat_utils_eigen_type = run_command(qlat_utils_py3, '-c', 'import qlat_utils as q ; print(q.get_eigen_type())',
env: environment({'q_verbose': '-1'}),
check: true).stdout().strip()
message('qlat_utils_eigen_type', qlat_utils_eigen_type)

if qlat_utils_eigen_type == 'grid'
assert(qlat_utils_cpp.check_header('Grid/Eigen/Eigen'))
qlat_utils_eigen = dependency('', required: false)
elif qlat_utils_cpp.check_header('Grid/Eigen/Eigen')
elif qlat_utils_cpp.check_header('Eigen/Eigen')
assert(qlat_utils_eigen_type == 'system')
qlat_utils_eigen = dependency('', required: false)
else
assert(qlat_utils_eigen_type == 'system')
qlat_utils_eigen = dependency('eigen3').as_system()
endif

Expand Down

0 comments on commit 4074262

Please sign in to comment.