-
Notifications
You must be signed in to change notification settings - Fork 1
Using Additional Data In Kernel
Hüseyin Tuğrul BÜYÜKIŞIK edited this page Jul 4, 2023
·
1 revision
Some problems require more than just the parameter-space as input. Extra data can be fed to kernel by a method call:
std::vector<unsigned char> digitsOfPI={'3','1','4','1','5',...};
UFSACL::UltraFastSimulatedAnnealing<5, 100000> sim(
R"(
parallelFor(256,{
// do something with digits of pi
unsigned char digit = pi[loopId];
});
)"
);
sim.addUserInput("pi", digitsOfPI);
sim.build();
The call to build()
has to be after the first call to the addUserInput
. This creates OpenCL kernel with necessary parameter design within compilation unit. Additional calls to sim.addUserInput("pi", digitsOfPI);
only updates the internal data with new data from user-vector. This is useful when problem has dynamically changing optimizations or needs a different input dataset for every new energy level:
// on every new energy level achieved, user data is automatically updated from ```digitsOfPI``` vector.
sim.run(..., [](float * newParameters){ sim.addUserInput("pi", digitsOfPI); });