Esempio n. 1
0
/**
 * Show platform information.
 *
 * @param[in] p Platform wrapper object.
 * @param[in] idx Platform index.
 * */
void ccl_devinfo_show_platform_info(CCLPlatform* p, guint idx) {

	/* Platform info variables. */
	gchar *profile, *version, *name, *vendor;

	/* Error location. */
	CCLErr* err = NULL;

	/* Get platform profile. */
	profile = ccl_platform_get_info_string(p, CL_PLATFORM_PROFILE, &err);
	if (err != NULL) {
		g_clear_error(&err);
		profile = "Unknown profile";
	}

	/* Get platform version. */
	version = ccl_platform_get_info_string(p, CL_PLATFORM_VERSION, &err);
	if (err != NULL) {
		g_clear_error(&err);
		version = "Unknown version";
	}

	/* Get platform name. */
	name = ccl_platform_get_info_string(p, CL_PLATFORM_NAME, &err);
	if (err != NULL) {
		g_clear_error(&err);
		name = "Unknown name";
	}

	/* Get platform vendor. */
	vendor = ccl_platform_get_info_string(p, CL_PLATFORM_VENDOR, &err);
	if (err != NULL) {
		g_clear_error(&err);
		vendor = "Unknown vendor";
	}

	/*  Send info to defined stream. */
	g_fprintf(CCL_DEVINFO_OUT,
		"\n* Platform #%d: %s (%s)\n               %s, %s\n",
		idx, name, vendor, version, profile);

	/* Bye. */
	return;
}
Esempio n. 2
0
/**
 * Get the OpenCL version of this platform. The version is returned as
 * an integer, in the following format:
 *
 * * 100 for OpenCL 1.0
 * * 110 for OpenCL 1.1
 * * 120 for OpenCL 1.2
 * * 200 for OpenCL 2.0
 * * 210 for OpenCL 2.1
 * * etc.
 *
 * @public @memberof ccl_platform
 *
 * @param[in] platf The platform wrapper object.
 * @param[out] err Return location for a ::CCLErr object, or `NULL` if error
 * reporting is to be ignored.
 * @return OpenCL version of platform as an integer. If an error occurs,
 * 0 is returned.
 * */
CCL_EXPORT
cl_uint ccl_platform_get_opencl_version(CCLPlatform * platf, CCLErr ** err) {

    /* Make sure platf is not NULL. */
    g_return_val_if_fail(platf != NULL, 0);
    /* Make sure err is NULL or it is not set. */
    g_return_val_if_fail(err == NULL || *err == NULL, 0);

    char * ver_str;
    cl_uint ver = 0;

    /* Get version string which has the format "OpenCL x.x ..." */
    ver_str = ccl_platform_get_info_string(
        platf, CL_PLATFORM_VERSION, err);

    if (ver_str != NULL) {
        ver = /* strlen("OpenCL ") == 7 */
            atoi(ver_str + 7) * 100 + /* Major version. */
            atoi(ver_str + 9) * 10; /* Minor version. */
    }
    return ver;
}