Add ET support for Lattice spin- and colour-traces #488
+18
−0
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.
Currently, the functions
TraceColourandTraceSpin, as well as the more genericTraceIndex(Grid/lattice/Lattice_trace.h) are available for tracing over internal indices of lattice objects. However, these functions cannot take an expression template as an argument, requiring them to be called as e.g.TraceIndex<ColourIndex>(closure(a*b))or for the expression to be assigned to a temporary first, forcing the full expression evaluation before the trace is performed.This pull request adds expression-template-compatible
traceColourandtraceSpinoverloads in the same spirit astrace, removing the need for aclosure()and reducing the cost of a trace over individual indices. This is currently being used to obtain performance gains in a contraction-heavy in-development workflow.This is a minimally-intrusive implementation that may not be ideal, in large part due to replicating the macros from
Grid/lattice/Lattice_ET.h. To avoid this the macro#undefs at the bottom ofGrid/lattice/Lattice_ET.hcould be removed.These operators can't live inside
Grid/lattice/Lattice_ET.hbecauseSpinIndexandColourIndexare defined inGrid/qcd/QCD.h, and implementing atraceIndexop would require additional macro definitions to account for theIndextemplate parameter -- which might be the better way to achieve this.I will update the pull request with production GPU benchmarks in the next few days.