Updated sample example to show async simple

This commit is contained in:
Alejandro Saucedo 2020-10-17 19:27:07 +01:00
parent 258629af59
commit 21c65c4b11
2 changed files with 10 additions and 2 deletions

View file

@ -89,7 +89,11 @@ int main() {
std::vector<char>(shader.begin(), shader.end()));
// Sync the GPU memory back to the local tensor
mgr.evalOpDefault<kp::OpTensorSyncLocal>({ tensorA, tensorB });
// You can run the job asynchronously with the Async function
mgr.evalOpAsyncDefault<kp::OpTensorSyncLocal>({ tensorA, tensorB });
// Await for the asynchonous default sequence to finish
mgr.evalOpAwaitDefault();
// Prints the output which is A: { 0, 1, 2 } B: { 3, 4, 5 }
std::cout << fmt::format("A: {}, B: {}",

View file

@ -69,7 +69,11 @@ Pass compute shader data in glsl/hlsl text or compiled SPIR-V format (or as path
std::vector<char>(shader.begin(), shader.end()));
// Sync the GPU memory back to the local tensor
mgr.evalOpDefault<kp::OpTensorSyncLocal>({ tensorA, tensorB });
// You can run the job asynchronously with the Async function
mgr.evalOpAsyncDefault<kp::OpTensorSyncLocal>({ tensorA, tensorB });
// Await for the asynchonous default sequence to finish
mgr.evalOpAwaitDefault();
// Prints the output which is A: { 0, 1, 2 } B: { 3, 4, 5 }
std::cout << fmt::format("A: {}, B: {}",