MCPcopy Create free account
hub / github.com/clMathLibraries/clFFT / CopyKernel

Class CopyKernel

src/library/generator.copy.cpp:94–508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92 // Copy kernel
93 template <Precision PR>
94 class CopyKernel
95 {
96 size_t N;
97 size_t Nt;
98 const FFTGeneratedCopyAction::Signature & params;
99 bool h2c, c2h;
100 bool general;
101
102 inline std::string OffsetCalc(const std::string &off, bool input = true)
103 {
104 std::string str;
105
106 const size_t *pStride = input ? params.fft_inStride : params.fft_outStride;
107
108 str += "\t"; str += off; str += " = ";
109 std::string nextBatch = "batch";
110 for(size_t i=(params.fft_DataDim - 1); i>1; i--)
111 {
112 size_t currentLength = 1;
113 for(int j=1; j<i; j++) currentLength *= params.fft_N[j];
114
115 str += "("; str += nextBatch; str += "/"; str += SztToStr(currentLength);
116 str += ")*"; str += SztToStr(pStride[i]); str += " + ";
117
118 nextBatch = "(" + nextBatch + "%" + SztToStr(currentLength) + ")";
119 }
120
121 str += nextBatch; str += "*"; str += SztToStr(pStride[1]); str += ";\n";
122
123 return str;
124 }
125
126 public:
127 CopyKernel( const FFTGeneratedCopyAction::Signature &paramsVal) :
128 params(paramsVal)
129
130 {
131 N = params.fft_N[0];
132 Nt = 1 + N/2;
133
134 h2c = ( (params.fft_inputLayout == CLFFT_HERMITIAN_PLANAR) ||
135 (params.fft_inputLayout == CLFFT_HERMITIAN_INTERLEAVED) ) ? true : false;
136 c2h = ( (params.fft_outputLayout == CLFFT_HERMITIAN_PLANAR) ||
137 (params.fft_outputLayout == CLFFT_HERMITIAN_INTERLEAVED) ) ? true : false;
138
139 general = !(h2c || c2h);
140
141 // We only do out-of-place copies at this point
142 assert(params.fft_placeness == CLFFT_OUTOFPLACE);
143 }
144
145 void GenerateKernel(std::string &str)
146 {
147 std::string rType = RegBaseType<PR>(1);
148 std::string r2Type = RegBaseType<PR>(2);
149
150 bool inIlvd; // Input is interleaved format
151 bool outIlvd; // Output is interleaved format

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected