diff options
Diffstat (limited to 'parallel-libs/streamexecutor/examples/Example.cpp')
-rw-r--r-- | parallel-libs/streamexecutor/examples/Example.cpp | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/parallel-libs/streamexecutor/examples/Example.cpp b/parallel-libs/streamexecutor/examples/Example.cpp index 5b0befc91be..af1994da415 100644 --- a/parallel-libs/streamexecutor/examples/Example.cpp +++ b/parallel-libs/streamexecutor/examples/Example.cpp @@ -23,27 +23,6 @@ #include "streamexecutor/StreamExecutor.h" -/// [Example saxpy host helper functions] -// Example handler for streamexecutor::Expected return values. -template <typename T> T getOrDie(streamexecutor::Expected<T> &&E) { - if (!E) { - std::fprintf(stderr, "Error extracting an expected value: %s.\n", - streamexecutor::consumeAndGetMessage(E.takeError()).c_str()); - std::exit(EXIT_FAILURE); - } - return std::move(*E); -} - -// Example handler for streamexecutor::Error return values. -void check(streamexecutor::Error &&E) { - if (E) { - std::fprintf(stderr, "Error encountered: %s.\n", - streamexecutor::consumeAndGetMessage(std::move(E)).c_str()); - std::exit(EXIT_FAILURE); - } -} -/// [Example saxpy host helper functions] - /// [Example saxpy compiler-generated] // Code in this namespace is generated by the compiler (e.g. clang). // @@ -148,7 +127,7 @@ int main() { .thenLaunch(ArraySize, 1, *Kernel, A, X, Y) .thenCopyD2H<float>(X, HostX); // Wait for the stream to complete. - check(Stream->blockHostUntilDone()); + se::dieIfError(Stream->blockHostUntilDone()); // Process output data in HostX. std::vector<float> ExpectedX = {4, 47, 90, 133}; @@ -157,7 +136,7 @@ int main() { } // Free device memory. - check(Device->freeDeviceMemory(X)); - check(Device->freeDeviceMemory(Y)); + se::dieIfError(Device->freeDeviceMemory(X)); + se::dieIfError(Device->freeDeviceMemory(Y)); /// [Example saxpy host main] } |