Converted AtomicString to constexpr char[]

This commit is contained in:
Seth Troisi 2022-03-11 14:08:42 -08:00
parent 94c3e6bed3
commit 5605faeed7
2 changed files with 23 additions and 27 deletions

View File

@ -249,30 +249,26 @@ static constexpr char CarToRasFunctionString[] =
"}\n" "}\n"
"\n"; "\n";
static string AtomicString() static constexpr char AtomicString[] =
{ "void AtomicAdd(volatile __global real_bucket_t* source, const real_bucket_t operand)\n"
ostringstream os; "{\n"
os << " union\n"
"void AtomicAdd(volatile __global real_bucket_t* source, const real_bucket_t operand)\n" " {\n"
"{\n" " atomi intVal;\n"
" union\n" " real_bucket_t realVal;\n"
" {\n" " } newVal;\n"
" atomi intVal;\n" "\n"
" real_bucket_t realVal;\n" " union\n"
" } newVal;\n" " {\n"
"\n" " atomi intVal;\n"
" union\n" " real_bucket_t realVal;\n"
" {\n" " } prevVal;\n"
" atomi intVal;\n" "\n"
" real_bucket_t realVal;\n" " do\n"
" } prevVal;\n" " {\n"
"\n" " prevVal.realVal = *source;\n"
" do\n" " newVal.realVal = prevVal.realVal + operand;\n"
" {\n" " } while (atomic_cmpxchg((volatile __global atomi*)source, prevVal.intVal, newVal.intVal) != prevVal.intVal);\n"
" prevVal.realVal = *source;\n" "}\n";
" newVal.realVal = prevVal.realVal + operand;\n"
" } while (atomic_cmpxchg((volatile __global atomi*)source, prevVal.intVal, newVal.intVal) != prevVal.intVal);\n"
"}\n";
return os.str();
}
} }

View File

@ -334,7 +334,7 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(const Ember<T>& ember,
CarToRasFunctionString; CarToRasFunctionString;
if (lockAccum) if (lockAccum)
os << AtomicString(); os << AtomicString;
os << os <<
xformFuncs.str() << xformFuncs.str() <<