Skip to content

Commit

Permalink
use popl for command line arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbaug committed Sep 9, 2024
1 parent 31c14fb commit b04ceff
Showing 1 changed file with 24 additions and 39 deletions.
63 changes: 24 additions & 39 deletions samples/usm/999_bigusm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
// SOFTWARE.
*/

#include <CL/opencl.hpp>
#include <popl/popl.hpp>

constexpr size_t BIG_ALLOC = 5ULL * 1024 * 1024 * 1024; // 5GB
#include <CL/opencl.hpp>

#define CL_MEM_FLAGS_INTEL 0x10001
#define CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL (1 << 23)
Expand All @@ -36,49 +36,34 @@ int main(
int argc,
char** argv )
{
bool printUsage = false;
int platformIndex = 0;
int deviceIndex = 0;
float numGB = 5.0f;

if( argc < 1 )
{
printUsage = true;
}
else
{
for( size_t i = 1; i < argc; i++ )
{
if( !strcmp( argv[i], "-d" ) )
{
if( ++i < argc )
{
deviceIndex = strtol(argv[i], NULL, 10);
}
}
else if( !strcmp( argv[i], "-p" ) )
{
if( ++i < argc )
{
platformIndex = strtol(argv[i], NULL, 10);
}
}
else
{
printUsage = true;
}
popl::OptionParser op("Supported Options");
op.add<popl::Value<int>>("p", "platform", "Platform Index", platformIndex, &platformIndex);
op.add<popl::Value<int>>("d", "device", "Device Index", deviceIndex, &deviceIndex);
op.add<popl::Value<float>>("s", "size", "Size to Allocate (GB)", numGB, &numGB);
bool printUsage = false;
try {
op.parse(argc, argv);
} catch (std::exception& e) {
fprintf(stderr, "Error: %s\n\n", e.what());
printUsage = true;
}

if (printUsage || !op.unknown_options().empty() || !op.non_option_args().empty()) {
fprintf(stderr,
"Usage: bigusm [options]\n"
"%s", op.help().c_str());
return -1;
}
}
if( printUsage )
{
fprintf(stderr,
"Usage: bigusm [options]\n"
"Options:\n"
" -d: Device Index (default = 0)\n"
" -p: Platform Index (default = 0)\n"
);

return -1;
}

printf("numGB = %f\n", numGB);

size_t BIG_ALLOC = numGB * 1024 * 1024 * 1024;

std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
Expand Down

0 comments on commit b04ceff

Please sign in to comment.