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

Feature/DD #1447

Open
wants to merge 120 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
efb27bf
Adding new macro for declaring enum classes with useful utils
sbacchio Mar 18, 2024
2514ca7
Adding DDParam structure used as property for any lattice_field
sbacchio Mar 18, 2024
1c89d4f
Adding method size to Coord
sbacchio Mar 18, 2024
82e3d6c
First implementation of DDaware dslash operator
sbacchio Mar 18, 2024
2ac39ad
Added dd options for tests
sbacchio Mar 19, 2024
3945185
Added set and reset functions
sbacchio Mar 19, 2024
c116ff8
Addind test routines for domain decomposition
sbacchio Mar 19, 2024
9ef4871
Enabling DD::in_use by default
sbacchio Mar 19, 2024
5435b96
Adding missing DD::mode
sbacchio Mar 19, 2024
66c7ae6
Example of usage of DD in SAP with MR solver
sbacchio Mar 19, 2024
2003212
implementing projection of ColorSpinorField to a domain determined by…
pittlerf Apr 4, 2024
f76859b
implementing tests for projection on domain determined by ddParam
pittlerf Apr 4, 2024
99fa643
Adding flags QUDA_DIRAC_DD and GPU_DD_DIRAC
sbacchio May 7, 2024
d4c448a
Adding instantiation over DDArg
sbacchio May 7, 2024
b21d9c9
Cleaning DDParam
sbacchio May 7, 2024
f13ca71
Adding DDArg
sbacchio May 7, 2024
aabb473
Resolving compilation errors
sbacchio May 7, 2024
328389b
Adding constexpr
sbacchio May 7, 2024
bfea442
Merge branch 'develop' of github.com:lattice/quda into HEAD
sbacchio May 7, 2024
fee22ac
Removing base struct DDArg
sbacchio May 7, 2024
e1e0dbb
Fixing wrong use of constexpr
sbacchio May 7, 2024
b1b3dd9
Adding DDArg in a number of places
sbacchio May 7, 2024
6fd40ea
Solving a few more compilation issues
sbacchio May 7, 2024
392ea76
Removing unnecessary copy constructor
sbacchio May 7, 2024
cf4705d
other missing fixes
sbacchio May 7, 2024
ae7f918
Enabling debug flag
sbacchio May 8, 2024
4327f70
cleaning
sbacchio May 8, 2024
57e5bc0
Bug fix
sbacchio May 20, 2024
ff6a219
Merge branch 'develop' of github.com:lattice/quda into feature/DD
sbacchio May 20, 2024
8e532d1
Applying clang-format
sbacchio May 20, 2024
c553724
Fixing typo in merging
sbacchio May 20, 2024
c55f733
Adding GPU implementation of projectDD
sbacchio May 21, 2024
57791d9
Changing block_hopping to no_block_hopping
sbacchio May 21, 2024
6ecce5b
Improving tests
sbacchio May 21, 2024
9926d80
Bug fix
sbacchio May 21, 2024
d318b51
Adding enum also to enum_quda_fortran.h
sbacchio May 21, 2024
c919c85
Renaming QUDA_DIRAC_DD to QUDA_DIRAC_DOMAIN_DECOMPOSITION
sbacchio May 21, 2024
3563a27
Changing DD to Domain Decomposition
sbacchio May 21, 2024
5410ea0
Removing most of constexpr
sbacchio May 21, 2024
cdebfe1
Removing another constexpr
sbacchio May 21, 2024
64d6256
Adding global coordinates
sbacchio May 21, 2024
e93707f
Adding check of DD parameters
sbacchio May 21, 2024
b8923e2
Using QUDA_MAX_DIM instead of 4
sbacchio May 21, 2024
0538afb
Restoring use of constexpr
sbacchio May 21, 2024
9dd6cc1
Adding check on no_block_hopping
sbacchio May 22, 2024
9fc016f
Disabling communication qhen possible
sbacchio May 22, 2024
d6c0162
Taking into account also dd of in during initialization
sbacchio May 22, 2024
7d7b320
Using full_dim
sbacchio May 22, 2024
6bc7b53
disabling global reduction is blocks are local
sbacchio May 22, 2024
b024d4c
Adding domain decomposition to ctest
sbacchio May 22, 2024
b0bd6a7
Adding option --dd-test-projection
sbacchio May 22, 2024
a549b63
Adding option to disable tests on domain decomposition
sbacchio May 22, 2024
822921e
Start making DD-aware more operators
sbacchio May 22, 2024
ee93d20
Merge branch 'develop' of github.com:lattice/quda into feature/DD
sbacchio Jun 17, 2024
2635a9d
Adding missing [src_idx]
sbacchio Jun 17, 2024
f0cf175
Adding DD method for accessing and editing domain decompositions
sbacchio Jun 17, 2024
34d0305
Restoring develop version of lib/dslash_policy.hpp
sbacchio Jun 17, 2024
83bb965
Restoring untouched files
sbacchio Jun 17, 2024
e4a1052
Adding const
sbacchio Jun 17, 2024
83d5b9d
Fixing compilation issues
sbacchio Jun 17, 2024
262d22a
supporting any value of dir in on_border
sbacchio Jun 17, 2024
ace5bf3
solving compilation issue
sbacchio Jun 17, 2024
6d0100e
Making all kernels DD-aware. Not tested!
sbacchio Jun 17, 2024
0d293cf
Fix warning in spin taste and minor cleanup
maddyscientist Jun 21, 2024
2dae537
Fix compilation issues
maddyscientist Jul 1, 2024
158c34d
Fix MR solver (avoid division by zero)
maddyscientist Jul 1, 2024
441be3c
Fix DD logic: issue was that global periodic boundary conditions were…
maddyscientist Jul 2, 2024
2893912
Renable DD tests in dslash_ctest, and apply various cleanup. Differe…
maddyscientist Jul 2, 2024
bfb4a3f
Replacing missed blockDim
sbacchio Jul 8, 2024
16c533b
Adding full_dim
sbacchio Jul 8, 2024
6c7bf63
Checking against the full lattice size
sbacchio Jul 8, 2024
14dea26
Adding dedicated tests for DD
sbacchio Jul 8, 2024
807b735
trying to fix compiler error in CI/CD
sbacchio Jul 8, 2024
2fdb22a
trying to fix compiler error in CI/CD
sbacchio Jul 8, 2024
d71dd75
Allowing for zero-valued block_dim, i.e. no DD in that direction
sbacchio Jul 8, 2024
6315e6f
Restoring original dim of tests and adding dedicated tests for DD
sbacchio Jul 8, 2024
bdc7d10
Cleanup and removing usage of Tmp2 and Tmp3 spinors
sbacchio Jul 8, 2024
1234bbb
Adding DD also to staggered_dslash_ctest
sbacchio Jul 8, 2024
dd012be
Merge branch 'develop' of github.com:lattice/quda into feature/DD
sbacchio Jul 8, 2024
9d31e48
Merge branch 'develop' of github.com:lattice/quda into feature/DD
maddyscientist Jul 9, 2024
90b4c5c
fixing benchmarking
sbacchio Jul 24, 2024
4cd5529
Merge branch 'feature/DD' of github.com:lattice/quda into feature/DD
sbacchio Jul 24, 2024
fe4c42b
Merge branch 'develop' of github.com:lattice/quda into feature/DD
sbacchio Sep 3, 2024
9fc2025
Changing QUDA_DIRAC_DOMAIN_DECOMPOSITION to bit value for multiple ki…
sbacchio Sep 3, 2024
b495ffe
Adding is_enabled for DD and precision_type_mapper
sbacchio Sep 3, 2024
029bdf7
Splitting compilation of dslash_wilson into multiple compilations units
sbacchio Sep 3, 2024
c2dd797
Fixing typo
sbacchio Sep 16, 2024
855f64e
extending single compilation units to distance preconditioning
sbacchio Sep 16, 2024
962554f
correcting travis-ci
pittlerf Oct 8, 2024
bce6914
correcting typo
pittlerf Oct 9, 2024
279c123
seprate compilation for twisted clover
pittlerf Oct 12, 2024
268ca0b
correcting error
pittlerf Oct 12, 2024
cc669f5
separate compilation units for several dslash
pittlerf Oct 14, 2024
514b492
separate compilation units for staggered dslash
pittlerf Oct 14, 2024
b1b8d4b
lower the string for the precision and including the 4d domain wall s…
pittlerf Oct 22, 2024
9dbd605
changing ncol to nc and correcting a bug
pittlerf Oct 22, 2024
a1ea3bd
typo corrected
pittlerf Oct 22, 2024
c288583
another typo corrected
pittlerf Oct 22, 2024
62fb53e
merging with current develop
pittlerf Oct 22, 2024
d4e8b17
finalizing merge
pittlerf Oct 26, 2024
ad74642
compiling with clang
Oct 26, 2024
fb6e206
Merge branch 'develop' of github.com:lattice/quda into feature/DD
sbacchio Nov 1, 2024
a7fe5bd
Fix non-improved staggered dslash tests - long link should not be cre…
maddyscientist Nov 6, 2024
23f889d
separate compilation units for domain wall 5f
pittlerf Nov 6, 2024
4041e67
separate compilation for wilson clover preconditioned
pittlerf Nov 6, 2024
f1b83a0
Merge branch 'feature/DD' into HEAD
pittlerf Nov 6, 2024
5c0b686
Fix redundant compilation with Wilson-clover using distain preconditi…
maddyscientist Nov 6, 2024
be72ab3
Fix issues with non-asqtad fermions
maddyscientist Nov 6, 2024
cb84d79
Renaming dir to dist
pittlerf Nov 7, 2024
a1fb649
separate compilation units for different domain wall
pittlerf Nov 7, 2024
65fec21
Merge remote-tracking branch 'origin' into HEAD
pittlerf Nov 7, 2024
7b88081
Merge branch 'feature/DD' into HEAD
pittlerf Nov 7, 2024
c73991f
including wilson clover hasenbusch twist
pittlerf Nov 7, 2024
21d81e6
remove in file no longer needed
pittlerf Nov 7, 2024
907ee8f
correcting preconditioning
pittlerf Nov 7, 2024
8539aa3
correcting typo
pittlerf Nov 7, 2024
a73e6a1
correcting typo
pittlerf Nov 7, 2024
a0123fc
correcting typo
pittlerf Nov 7, 2024
8ffb905
typo corrected
pittlerf Nov 7, 2024
9bac7f7
separate compilation for twisted mass preconditioned
pittlerf Nov 8, 2024
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ option(QUDA_DIRAC_CLOVER_HASENBUSCH "build clover Hasenbusch twist operators" ${
option(QUDA_DIRAC_NDEG_TWISTED_MASS "build non-degenerate twisted mass Dirac operators" ${QUDA_DIRAC_DEFAULT})
option(QUDA_DIRAC_NDEG_TWISTED_CLOVER "build non-degenerate twisted clover Dirac operators" ${QUDA_DIRAC_DEFAULT})
option(QUDA_DIRAC_LAPLACE "build laplace operator" ${QUDA_DIRAC_DEFAULT})

option(QUDA_DIRAC_DISTANCE_PRECONDITIONING "build code for distance preconditioned Wilson/clover Dirac operators" OFF)
set(QUDA_DOMAIN_DECOMPOSITION "0" CACHE STRING "which domain decomposition to instantiate in QUDA (1-bit number - RedBlack)")

option(QUDA_COVDEV "build code for covariant derivative" OFF)

Expand Down
1 change: 1 addition & 0 deletions ci/docker/Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ RUN QUDA_TEST_GRID_SIZE="1 1 1 2" cmake -S /quda/src \
-DQUDA_MULTIGRID_NVEC_LIST=6 \
-DQUDA_MDW_FUSED_LS_LIST=4 \
-DQUDA_MPI=ON \
-DQUDA_DSLASH_DISTANCE=1 \
-DQUDA_DIRAC_DEFAULT_OFF=ON \
-DQUDA_DIRAC_WILSON=ON \
-DQUDA_DIRAC_CLOVER=ON \
Expand Down
31 changes: 31 additions & 0 deletions include/color_spinor_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ namespace quda
int composite_dim = 0; // e.g., number of eigenvectors in the set
bool is_component = false;
int component_id = 0; // eigenvector index
DDParam dd {};

/**
If using CUDA native fields, this function will ensure that the
Expand Down Expand Up @@ -356,6 +357,9 @@ namespace quda
//
CompositeColorSpinorField components;

/** Domain decomposition options */
DDParam dd {};

/**
Compute the required extended ghost zone sizes and offsets
@param[in] nFace The depth of the halo
Expand Down Expand Up @@ -438,6 +442,31 @@ namespace quda
*/
void copy(const ColorSpinorField &src);

/**
@brief Project the field to a domain determined by DDParam
*/
void projectDD();

/**
@brief Returns DDParam (const version)
*/
const DDParam& DD() const { return dd; }

/**
@brief Returns DDParam (non const version)
*/
DDParam& DD() { return dd; }

/**
@brief Sets DDParam from a given DDParam
*/
void DD(const DDParam &in) { dd = in; }

/**
@brief Sets DDParam from a given list of options (DD flags)
*/
template <typename... Args> void DD(const quda::DD &flag, const Args &...args) { dd.set(flag, args...); }

/**
@brief Zero all elements of this field
*/
Expand Down Expand Up @@ -977,6 +1006,8 @@ namespace quda
void *Dst = nullptr, const void *Src = nullptr);

void genericSource(ColorSpinorField &a, QudaSourceType sourceType, int x, int s, int c);

void genericProjectDD(ColorSpinorField &a);
int genericCompare(const ColorSpinorField &a, const ColorSpinorField &b, int tol);

/**
Expand Down
60 changes: 60 additions & 0 deletions include/declare_enum.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* A macro that declares an `enum class` as well as a `to_string` function for the enums.
* The enum has also a default value `size` that measures the size of the enum.
*
* Credit: https://stackoverflow.com/a/71375077/12084612
* -------
* License: CC BY-SA 4.0
* --------
* Usage:
* ------
*
* DECLARE_ENUM(WeekEnum, Mon, Tue, Wed, Thu, Fri, Sat, Sun,);
*
* int main()
* {
* WeekEnum weekDay = WeekEnum::Wed;
* std::cout << to_string(weekDay) << std::endl; // prints Wed
* std::cout << to_string(WeekEnum::Sat) << std::endl; // prints Sat
* std::cout << to_string((int) WeekEnum::size) << std::endl; // prints 7
* return 0;
* }
*
*/

#pragma once
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>

// Add the definition of this method into a cpp file. (only the declaration in the header)
static inline const std::vector<std::string> get_enum_names(const std::string &en_key, const std::string &en_str)
{
static std::unordered_map<std::string, std::vector<std::string>> en_names_map;
const auto it = en_names_map.find(en_key);
if (it != en_names_map.end()) return it->second;

constexpr auto delim(',');
std::vector<std::string> en_names;
std::size_t start {};
auto end = en_str.find(delim);
while (end != std::string::npos) {
while (en_str[start] == ' ') ++start;
en_names.push_back(en_str.substr(start, end - start));
start = end + 1;
end = en_str.find(delim, start);
}
while (en_str[start] == ' ') ++start;
en_names.push_back(en_str.substr(start));
return en_names_map.emplace(en_key, std::move(en_names)).first->second;
}

#define DECLARE_ENUM(ENUM_NAME, ...) \
enum class ENUM_NAME : unsigned int { __VA_ARGS__ size }; \
inline std::string to_string(ENUM_NAME en) \
{ \
const auto names = get_enum_names(#ENUM_NAME, #__VA_ARGS__); \
return names[static_cast<std::size_t>(en)]; \
}
153 changes: 153 additions & 0 deletions include/domain_decomposition.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#pragma once

#include "declare_enum.h"

namespace quda
{

// using namespace quda;

DECLARE_ENUM(DD, // name of the enum class

reset, // No domain decomposition. It sets all flags to zero.

red_black_type, // Flags used by red_black
red_active, // if red blocks are active
black_active, // if black blocks are active
no_block_hopping, // if hopping between red and black is allowed
);

// Params for domain decompation
struct DDParam {

QudaDDType type = QUDA_DD_NO;
array<bool, static_cast<int>(DD::size)> flags = {}; // the default value of all flags is 0
array<int, QUDA_MAX_DIM> block_dim = {}; // the size of the block per direction

// Default constructor
DDParam() = default;

// returns false if in use
constexpr bool operator!() const { return type == QUDA_DD_NO; }

// returns value of given flag
constexpr bool is(const DD &flag) const { return flags[(int)flag]; }

// sets given flag to true
constexpr void set(const DD &flag)
{
flags[(int)flag] = true;

if ((int)flag == (int)DD::reset) {
#pragma unroll
for (auto i = 0u; i < (int)DD::size; i++) flags[i] = 0;
type = QUDA_DD_NO;
} else if ((int)flag >= (int)DD::red_black_type) {
type = QUDA_DD_RED_BLACK;
}
}

template <typename... Args> constexpr void set(const DD &flag, const Args &...args)
{
set(flag);
set(args...);
}

// Pretty print the args struct
void print() const
{
if (not *this) {
printfQuda("DD not in use\n");
return;
}
printfQuda("Printing DDParam\n");
for (int i = 0; i < (int)DD::size; i++)
printfQuda("flags[DD::%s] = %s\n", to_string((DD)i).c_str(), flags[i] ? "true" : "false");
for (int i = 0; i < QUDA_MAX_DIM; i++) printfQuda("block_dim[%d] = %d\n", i, static_cast<int>(block_dim[i]));
}

// Checks if this matches to given DDParam
template <typename F> inline bool check(const F &field, bool verbose = false) const
{
if (not *this) return true;

if (type == QUDA_DD_RED_BLACK) {
for (int i = 0; i < field.Ndim(); i++) {
if (block_dim[i] < 0) {
if (verbose) printfQuda("block_dim[%d] = %d is negative\n", i, block_dim[i]);
return false;
}
if (block_dim[i] > 0) {
int globalDim = comm_dim(i) * field.full_dim(i);
if (globalDim % block_dim[i] != 0) {
if (verbose) printfQuda("block_dim[%d] = %d does not divide %d \n", i, block_dim[i], globalDim);
return false;
}
if ((globalDim / block_dim[i]) % 2 != 0) {
if (verbose)
printfQuda("block_dim[%d] = %d does not divide %d **evenly** \n", i, block_dim[i], globalDim);
return false;
}
}
}
if (block_dim[0] % 2) {
if (verbose) printfQuda("block_dim[0] = %d must be even \n", block_dim[0]);
return false;
}
}

return true;
}

// Checks if this matches to given DDParam
inline bool match(const DDParam &dd, bool verbose = false) const
{
// if one of the two is not in use we return true, i.e. one of the two is a full field
if (not *this or not dd) return true;

// false if type does not match
if (type != dd.type) {
if (verbose) printfQuda("DD type do not match (%d != %d)\n", type, dd.type);
return false;
}

if (type == QUDA_DD_RED_BLACK) {
for (int i = 0; i < QUDA_MAX_DIM; i++)
if (block_dim[i] != dd.block_dim[i]) {
if (verbose) printfQuda("block_dim[%d] = %d != %d \n", i, block_dim[i], dd.block_dim[i]);
return false;
}
if (is(DD::no_block_hopping) != dd.is(DD::no_block_hopping)) {
if (verbose) printfQuda("no_block_hopping do not match.\n");
return false;
}
}

return true;
}

// Checks if this is equal to given DDParam
inline bool operator==(const DDParam &dd) const
{
// if both are not in use we return true
if (not *this and not dd) return true;

// false if type does not match
if (type != dd.type) return false;

// checking all flags matches (note this should be actually type-wise)
for (int i = 0; i < (int)DD::size; i++)
if (flags[i] != dd.flags[i]) return false;

// checking block_dim matches when needed
if (type == QUDA_DD_RED_BLACK)
for (int i = 0; i < QUDA_MAX_DIM; i++)
if (block_dim[i] != dd.block_dim[i]) return false;

return true;
}

inline bool operator!=(const DDParam &dd) const { return !(*this == dd); }
};

} // namespace quda
Loading
Loading