Getting the Specifications of CPU and GPU cards, OpenCL + OSX

Code: openclTest.cpp    Makefile

 

 

 

For several reasons I chose to have a go with OpenCL. Being mainly a High Performance Engineer, and even though I prefer NVIDIA CUDA, OpenCL is very interesting, and a very nice treat in what parallelism, portabiliy, and General computation is concerned. Therefore I grabbed my 27" IMac, and started Jumping around this Quick General Guide from IVEC. 

 

For other systems like Linux and Windows, you need to install OpenCL explicitly, however in OS X it already comes embedded, so you only need to learn how to Link your program to it. If you're in OSX as me, and if you love things uncomplicated and wrapped in a pleasant-to-the-eye layer, all you need to do is use Xcode, create your project, and add the framework in this place:

Xcode Adding OpenCL Framework

 

If you're like me, then you prefer Linux style, everything raw but uncomplicated. For me, programming is all about the program in text files plus a Makefile. It is clean, with absolutely no extra garbage, and easier to port into other platforms. So, you can grab a C/C++ compliler and add the flag "-framework OpenCL", and that's it. It is different from Linux, but at least I am telling you the secret here, there is no secret extra hours of searching on the Web on why you're getting this or that compiling error, after adding OpenCL ports and adding tons of extra lines, specifying include paths and Library paths. 

 

To compile under the Console: g++ -Wall  -g  -o  openclTest  openclTest.cpp  -framework  OpenCL

To execute: ./openclTest

 

The result is, for my IMac, the following:

OpenCL Specifications OSX

 

 

 

 

There is also a sample code that usually comes in the AMD APP SDK, called CLInfo. A snippet of the output is:

 

$ ./CLInfo

 

Number of platforms: 

Platform Profile: 

Platform Version: 

Platform Name: 

Platform Vendor:  

 

Number of devices: 

 

Device Type:

Board name:

Device Topology: 

Max compute units:

Max work items dimensions: 

Max work group size: 

Preferred vector width char: 

Local memory type: 

Local memory size:

Name:

Vendor:

Device OpenCL C version: 

Driver version: 

Max Constant Args: 

Global Mem Cache Size:

  

 

Device Type:

Device ID:

Max compute units:

Max work group size: 

Name:

Vendor:

Device OpenCL C version: 

Global Mem Cache Size:

 

 

1

FULL_PROFILE

OpenCL 1.2 AMD–APP (938.1)

AMD Accelerated Parallel Processing 

Advanced Micro Devices, Inc. 

 

2

 

CL_DEVICE_TYPE_GPU

AMD Radeon HD 7900 Series

PCI[ B#1, D#0, F#0 ]

32

3

512

16

Scratchpad

32768

Tahiti 

Advanced Micro Devices, Inc.

OpenCL C 1.2

CAL 1.4.1741 (VM) 

8

536870912

  

 

CL_DEVICE_TYPE_CPU

4098

4

1024

Intel(R) Core(TM) i5 CPU 680 @ 3.60 GHz 

GenuineIntel

OpenCL C 1.2 

64

 

The code CLInfo gets the majority of the specifications of all the OpenCL Capable devices of your system. I am posting here the full code, so it is just compile and run. With this being said, I personaly find the code a bit bitter for the beginner's eyes, and therefore I recommend to use it only to get all the specs you need (or just to try things out). Other than that, I recommend using the other code examples I've put here, as they're friendlier and easier to understand, and faster for you to copy and reuse it for your needs.

 

Code: clInfo.cpp

Published by fxsf às 13:18