-
Notifications
You must be signed in to change notification settings - Fork 102
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
Adding gauge shift #1348
Open
sbacchio
wants to merge
10
commits into
develop
Choose a base branch
from
feature/gauge_shift
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Adding gauge shift #1348
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
24eca06
Adding gauge shift
sbacchio 3b7b8ef
Adding mock implementation of shift
sbacchio 05f8b7b
Using geometry to fix kernel size
sbacchio 6d929b1
Running clang-format
sbacchio 7a0bff9
Merge branch 'feature/gauge_shift' of github.com:lattice/quda into fe…
sbacchio a304a3a
Changing type for dx from int* to array
sbacchio 4e10343
Merge branch 'develop' of github.com:lattice/quda into feature/gauge_…
sbacchio 666a38e
Removing template over dir
sbacchio fcf8d86
Merge branch 'develop' of github.com:lattice/quda into feature/gauge_…
sbacchio 9a3dbf1
Merge branch 'develop' of github.com:lattice/quda into feature/gauge_…
sbacchio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#pragma once | ||
|
||
#include <gauge_field_order.h> | ||
#include <quda_matrix.h> | ||
#include <index_helper.cuh> | ||
#include <kernel.h> | ||
|
||
namespace quda | ||
{ | ||
|
||
template <typename Float_, int nColor_, QudaReconstructType recon_u> struct GaugeShiftArg : kernel_param<> { | ||
using Float = Float_; | ||
static constexpr int nColor = nColor_; | ||
static_assert(nColor == 3, "Only nColor=3 enabled at this time"); | ||
typedef typename gauge_mapper<Float, recon_u>::type Gauge; | ||
|
||
Gauge out; | ||
const Gauge in; | ||
|
||
int S[4]; // the regular volume parameters | ||
int X[4]; // the regular volume parameters | ||
int E[4]; // the extended volume parameters | ||
int border[4]; // radius of border | ||
int P; // change of parity | ||
|
||
GaugeShiftArg(GaugeField &out, const GaugeField &in, const array<int, 4> &dx) : | ||
kernel_param(dim3(in.VolumeCB(), 2, in.Geometry())), out(out), in(in) | ||
{ | ||
P = 0; | ||
for (int i = 0; i < 4; i++) { | ||
S[i] = dx[i]; | ||
X[i] = out.X()[i]; | ||
E[i] = in.X()[i]; | ||
border[i] = (E[i] - X[i]) / 2; | ||
P += dx[i]; | ||
} | ||
P = std::abs(P) % 2; | ||
} | ||
}; | ||
|
||
template <typename Arg> struct GaugeShift { | ||
const Arg &arg; | ||
constexpr GaugeShift(const Arg &arg) : arg(arg) { } | ||
static constexpr const char *filename() { return KERNEL_FILE; } | ||
|
||
__device__ __host__ void operator()(int x_cb, int parity, int dir) | ||
{ | ||
using real = typename Arg::Float; | ||
typedef Matrix<complex<real>, Arg::nColor> Link; | ||
|
||
int x[4] = {0, 0, 0, 0}; | ||
getCoords(x, x_cb, arg.X, parity); | ||
for (int dr = 0; dr < 4; ++dr) x[dr] += arg.border[dr]; // extended grid coordinates | ||
int nbr_oddbit = arg.P == 1 ? (parity ^ 1) : parity; | ||
|
||
Link link = arg.in(dir, linkIndexShift(x, arg.S, arg.E), nbr_oddbit); | ||
arg.out(dir, x_cb, parity) = link; | ||
} | ||
}; | ||
|
||
} // namespace quda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include <tunable_nd.h> | ||
#include <instantiate.h> | ||
#include <gauge_field.h> | ||
#include <kernels/gauge_shift.cuh> | ||
|
||
namespace quda | ||
{ | ||
|
||
template <typename Float, int nColor, QudaReconstructType recon_u> class ShiftGauge : public TunableKernel3D | ||
{ | ||
GaugeField &out; | ||
const GaugeField ∈ | ||
const array<int, 4> &dx; | ||
unsigned int minThreads() const { return in.VolumeCB(); } | ||
|
||
public: | ||
ShiftGauge(GaugeField &out, const GaugeField &in, const array<int, 4> &dx) : | ||
TunableKernel3D(in, 2, in.Geometry()), out(out), in(in), dx(dx) | ||
{ | ||
strcat(aux, ",shift="); | ||
for (int i = 0; i < in.Ndim(); i++) { strcat(aux, std::to_string(dx[i]).c_str()); } | ||
strcat(aux, comm_dim_partitioned_string()); | ||
apply(device::get_default_stream()); | ||
} | ||
|
||
void apply(const qudaStream_t &stream) | ||
{ | ||
TuneParam tp = tuneLaunch(*this, getTuning(), getVerbosity()); | ||
launch<GaugeShift>(tp, stream, GaugeShiftArg<Float, nColor, recon_u>(out, in, dx)); | ||
} | ||
|
||
void preTune() { } | ||
void postTune() { } | ||
|
||
long long flops() const { return in.Volume() * 4; } | ||
long long bytes() const { return in.Bytes(); } | ||
}; | ||
|
||
void gaugeShift(GaugeField &out, const GaugeField &in, const array<int, 4> &dx) | ||
{ | ||
checkPrecision(in, out); | ||
checkLocation(in, out); | ||
checkReconstruct(in, out); | ||
|
||
if (out.Geometry() != in.Geometry()) { | ||
errorQuda("Field geometries %d %d do not match", out.Geometry(), in.Geometry()); | ||
} | ||
|
||
// gauge field must be passed as first argument so we peel off its reconstruct type | ||
instantiate<ShiftGauge>(out, in, dx); | ||
} | ||
|
||
} // namespace quda |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be moved to e.g.
gauge_tools.h
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that seems like a consistent place for it.