Last active
January 6, 2021 05:50
-
-
Save Foadsf/3ca81a9b6f4b5c51e93dcee34b434342 to your computer and use it in GitHub Desktop.
Revisions
-
Foadsf revised this gist
Jun 9, 2020 . No changes.There are no files selected for viewing
-
Foadsf revised this gist
Jun 9, 2020 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ cmake_minimum_required(VERSION 3.1) project(OpenCL_Example) find_package(OpenCL REQUIRED) include_directories(${OpenCL_INCLUDE_DIRS}) link_directories(${OpenCL_LIBRARY}) add_executable(main main.c) target_include_directories(main PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(main ${OpenCL_LIBRARY}) -
Foadsf revised this gist
Jun 3, 2018 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,6 @@ #include <stdio.h> //printf #ifdef __APPLE__ #include <OpenCL/cl.h> #else #include <CL/cl.h> @@ -21,7 +20,7 @@ int main(int argc, char const* argv[]) { platforms= (cl_platform_id*) malloc(sizeof(cl_platform_id) * numPlatforms); err = clGetPlatformIDs(numPlatforms, platforms, NULL); if(err != CL_SUCCESS) { printf("Couldn't get platforms"); return EXIT_FAILURE; } -
Foadsf created this gist
Jun 3, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ OS := $(shell uname) OPTIONS:= ifeq ($(OS),Darwin) OPTIONS += -framework OpenCL else OPTIONS += -l OpenCL endif all: main.c gcc -Wall -g main.c -o main $(OPTIONS) clean: rm -rf main This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ #include <stdio.h> //printf #ifdef __APPLE__ //or? MAC or? APPLE //or? #if defined(MAC) || defined(__APPLE__) #include <OpenCL/cl.h> #else #include <CL/cl.h> #endif int main(int argc, char const* argv[]) { cl_int err; cl_uint numPlatforms; cl_platform_id* platforms; err = clGetPlatformIDs(0, NULL, &numPlatforms); if(err != CL_SUCCESS || numPlatforms == 0) { printf("Couldn't identify a platform"); return EXIT_FAILURE; } printf("Number of platfroms: %d\n", numPlatforms); platforms= (cl_platform_id*) malloc(sizeof(cl_platform_id) * numPlatforms); err = clGetPlatformIDs(numPlatforms, platforms, NULL); if(err != CL_SUCCESS) {// clGetPlatformIDs returns CL_INVALID_VALUE or CL_SUCCESS printf("Couldn't get platforms"); return EXIT_FAILURE; } cl_platform_info Param_Name[5]={CL_PLATFORM_PROFILE, CL_PLATFORM_VERSION, CL_PLATFORM_NAME, CL_PLATFORM_VENDOR,CL_PLATFORM_EXTENSIONS}; cl_platform_info param_name; size_t param_value_size; for(int i=0;i<numPlatforms;i++){ for(int j=0;j<5;j++){ param_name=Param_Name[j]; err = clGetPlatformInfo( platforms[i], param_name, 0, NULL, ¶m_value_size); char* param_value = (char*)malloc( sizeof(char) * param_value_size); err = clGetPlatformInfo( platforms[i], param_name, param_value_size, param_value, NULL ); printf("%s\n", param_value); free(param_value); } } free(platforms); return 0; }