/*! \file main.c * * \author John Reppy * * \brief This program is used to determine properties of the host machine's * OpenCL support. * * Usage: * clinfo cmd [args] * * where cmd is one of * platforms -- prints a list of OpenCL platforms supported by the * host. * version platform -- prints version of OpenCL supported by the platform. The * format is "OpenCL major.minor ..." * devices platform -- prints a list of devices * extensions device -- prints a list of extensions that are * supported by the device */ /* * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu) * All rights reserved. */ #include "clinfo.h" #include #include #include #define MAX_PLATFORMS 16 static void usage (); static PlatformInfo_t *GetPlatformByName (const CLInfo_t *info, const char *name); int main (int argc, const char **argv) { if (argc < 2) { usage(); } // get CL info CLInfo_t *info = GetCLInfo (); // process command-line options if ((strcmp(argv[1], "platforms") == 0) && (argc == 2)) { for (int i = 0; i < info->numPlatforms; i++) { printf ("%s\n", info->platforms[i].name); } } else if ((strcmp(argv[1], "version") == 0) && (argc == 3)) { char buf[256]; cl_platform_id id = GetPlatformByName(info, argv[2]); clGetPlatformInfo (id, CL_PLATFORM_VERSION, sizeof(buf), buf, 0); printf ("%s\n", buf); } else if ((strcmp(argv[1], "devices") == 0) && (argc == 3)) { cl_platform_id id = GetPlatformByName(argv[2]); cl_device_id *devs; char buf[256]; int numDevs = GetDevices (id, CL_DEVICE_TYPE_ALL, &devs); for (int i = 0; i < numDevs; i++) { clGetDeviceInfo (devs[i], CL_DEVICE_NAME, sizeof(buf), buf, 0); printf ("%s\n", buf); } } else if ((strcmp(argv[1], "extensions") == 0) && (argc == 3)) { cl_platform_id id = GetPlatformByName(argv[2]); size_t bufSz; // get the size of the extensions buffer clGetPlatformInfo (id, CL_PLATFORM_EXTENSIONS, 0, 0, &bufSz); char *buf = (char *)malloc(bufSz); clGetPlatformInfo (id, CL_PLATFORM_EXTENSIONS, bufSz, buf, 0); char *p = buf; while (p != 0) { p = strchr(p, ' '); if (p != 0) *p = '\n'; } printf ("%s", buf); free (buf); } else usage(); } static void usage () { exit (1); } static PlatformInfo_t *GetPlatformByName (const CLInfo_t *info, const char *name) { for (cl_uint i = 0; i < info->numPlatforms; i++) { if (strcmp(info->platforms[i].name, name) == 0) return &(info->platforms[i]); } fprintf (stderr, "platform %s not found\n", name); exit (1); }
Click to toggle
does not end with </html> tag
does not end with </body> tag
The output has ended thus: (info->platforms[i]); } fprintf (stderr, "platform %s not found\n", name); exit (1); }