Bilinear Contractions - lattice/quda GitHub Wiki
Notes on Bi-linear contraction functionality
There are several additions included in the contract code. I'll enumerate them, trying to explain how they work, but if you have further questions, please, ask.
- There is the gamma5Cuda kernel, that just multiplies a spinor by gamma5. I don't really know whether this was necessary, because in QUDA was a function applying the operator (b + ia gamma5) to a spinor, but I think this was only compiled for twisted mass. In any case, this function is straightforward to use:
gamma5Cuda(*outSpinor, *inSpinor);
where the spinor fields are of the cudaColorSpinorField type.
I'm thinking on removing the pointers, but this is stuff we shouldn't care about now.
- The main addition is a very simple one: contraction kernels for product of spinors. The function is called contractCuda, and performs the contraction of two spinors per volume point, that is, it calculates the scalar product of the two spinors, but only in color space, and the dirac indices are left open, so the output is an array of size 16xVOLUME (the 16 comes from the 4x4 submatrix, due to the open dirac indices). This is useful for disconnected diagrams, 2 and 3 point functions, and any other computation that requires contractions.
The way to use the function is the following:
contractQUDA(Spinor1, Spinor2, output, contraction-type, [optional: time-slice], parity);
where the two spinors are cudaColorSpinorField, the output is a void array , whose size must be 16xVOLUME, the parity is the parity of the spinors (this function works only for parity spinors at this moment), and the contraction-type can be any of the following:
QUDA_CONTRACT: Just contracts the fields Spinor1 and Spinor2, and writes the result in output.
QUDA_CONTRACT_GAMMA5: It contracts the fields Spinor1 and gamma5*Spinor2, and writes the result in output.
QUDA_CONTRACT_TSLICE: Contracts the fields Spinor1 and Spinor2, but only the spatial volume corresponding to one time-slice. The time-slice is chosen with the input parameter "time-slice". The result is written in output, but since we are contracting only one time-slice, the size of output must be 16xSPATIAL VOLUME (LXLYLZ).
The _PLUS and _MINUS variants perform the same operations, but instead of overwritting the results of the output array, they add/substract what is computed to the output array. This can be useful when accumulating contractions.
After the contraction, usually a FFT is needed to go to the momentum space. The output data is in such a format that the FFT is straightforward with the cuFFT library.
- The final addition is the covariant derivative. The name might be a bit confusing: the function doesn't calculate the covariant derivative, it applies a color matrix to a spinor, but it can be used to calculate the covariant derivative.
The parameters are:
covDev(*spinorOut, gaugeField, *spinorIn, parity, mu, profiler);
The spinorIn and spinorOut are pointers to cudaColorSpinorField, the gaugeField is the gauge field being used, usually gaugePrecise. Again, the function works only with parity spinors, so we need to indicate the parity. The int "mu" indicates the direction of the color (gauge) fields, and goes from 0 (X) to 3(T). Higher values indicate backwards application of the gauge fields (that is, one applies the dagger version of the color matrices. Finally, one needs a profiler.
I have some interfaces demonstrating everything, but I should polish them before integration. In any case, I can privately send some exaplme code to you, but only for disconnected diagrams, which is the reason I developed this.