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

Function ReadParameterFile

src/library/generator.stockham.cpp:189–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187 // LdsUse:
188
189 void ReadParameterFile(ParamRead &readParam)
190 {
191 const char *fileName = "parameters.txt";
192 std::ifstream file(fileName);
193
194 if(!file.is_open())
195 {
196 std::cout << "File: " << fileName << " could not be opened, exiting ...." << std::endl;
197 exit(-1);
198 }
199
200 std::string strWgs = "WorkGroupSize:";
201 std::string strNtw = "TransformsPerWorkGroup:";
202 std::string strRad = "Radices:";
203 std::string strLds = "LdsUse:";
204 std::string numbers = "0123456789";
205
206 std::string line;
207 while(std::getline(file, line))
208 {
209
210 size_t pos;
211
212 pos = line.find(strWgs);
213 if(pos != std::string::npos)
214 {
215 line.erase(pos, strWgs.length());
216 size_t numStart = line.find_first_of(numbers);
217 size_t numEnd = line.find_first_not_of(numbers, numStart);
218 std::string val = line.substr(numStart, numEnd-numStart);
219 readParam.workGroupSize = strtol(val.c_str(), NULL, 10);
220 continue;
221 }
222
223 pos = line.find(strNtw);
224 if(pos != std::string::npos)
225 {
226 line.erase(pos, strNtw.length());
227 size_t numStart = line.find_first_of(numbers);
228 size_t numEnd = line.find_first_not_of(numbers, numStart);
229 std::string val = line.substr(numStart, numEnd-numStart);
230 readParam.numTransformsPerWg = strtol(val.c_str(), NULL, 10);
231 continue;
232 }
233
234 pos = line.find(strRad);
235 if(pos != std::string::npos)
236 {
237 line.erase(pos, strRad.length());
238 while(std::string::npos != line.find_first_of(numbers))
239 {
240 size_t numStart = line.find_first_of(numbers);
241 size_t numEnd = line.find_first_not_of(numbers, numStart);
242 std::string val = line.substr(numStart, numEnd-numStart);
243 readParam.radices.push_back(strtol(val.c_str(), NULL, 10));
244 line.erase(0, numEnd);
245 }
246 continue;

Callers 2

KernelMethod · 0.85
initParamsMethod · 0.85

Calls 1

lengthMethod · 0.80

Tested by

no test coverage detected