From 809bf2e3fb8619d5eeb4a8174880a1effd56d0f2 Mon Sep 17 00:00:00 2001 From: Ben Ashbaugh Date: Mon, 21 Aug 2023 15:10:55 -0700 Subject: [PATCH] add more queries after ICD loader shutdown --- samples/00_loadershutdown/main.cpp | 56 ++++++++++++++++++------------ 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/samples/00_loadershutdown/main.cpp b/samples/00_loadershutdown/main.cpp index c2d8be3..323533c 100644 --- a/samples/00_loadershutdown/main.cpp +++ b/samples/00_loadershutdown/main.cpp @@ -13,12 +13,28 @@ typedef cl_int (*pfn_clShutdownOCLICD)(void); pfn_clShutdownOCLICD clShutdownOCLICD = NULL; +static void PrintPlatformList(const std::vector& platforms) +{ + for (const auto& platform: platforms) { + cl_int errorCode = CL_SUCCESS; + auto name = platform.getInfo(&errorCode); + if (errorCode == CL_SUCCESS) { + printf("\tPlatform: %s\n", name.c_str()); + } else { + printf("\tQuery returned %d\n", errorCode); + } + } +} + int main( int argc, char** argv ) { + bool skipShutdown = false; + { popl::OptionParser op("Supported Options"); + op.add("s", "skipshutdown", "Skip ICD Loader Shutdown", &skipShutdown); bool printUsage = false; try { @@ -47,32 +63,28 @@ int main( return 0; } - std::vector platforms; - cl::Platform::get(&platforms); + std::vector before; + cl::Platform::get(&before); - printf("Before shutting down: queried %zu platforms.\n", platforms.size()); - for (const auto& platform: platforms) { - cl_int errorCode = CL_SUCCESS; - auto name = platform.getInfo(&errorCode); - if (errorCode == CL_SUCCESS) { - printf("\tPlatform: %s\n", name.c_str()); - } else { - printf("\tQuery returned %d\n", errorCode); - } + printf("Before shutting down: queried %zu platform(s).\n", before.size()); + PrintPlatformList(before); + + if (!skipShutdown) { + printf("\nCalling clShutdownOCLICD()!\n"); + clShutdownOCLICD(); } - clShutdownOCLICD(); + std::vector after; + cl::Platform::get(&after); - printf("\nAfter shutting down:\n"); - for (const auto& platform: platforms) { - cl_int errorCode = CL_SUCCESS; - auto name = platform.getInfo(&errorCode); - if (errorCode == CL_SUCCESS) { - printf("\tPlatform: %s\n", name.c_str()); - } else { - printf("\tQuery returned %d\n", errorCode); - } - } + printf("\nAfter shutting down: queried %zu platform(s).\n", after.size()); + + printf("\nPlatform information from old platform list:\n"); + PrintPlatformList(before); + + printf("\nPlatform information from new platform list:\n"); + PrintPlatformList(after); + printf("\nAll done.\n"); return 0; }