I'm trying to learn the OpenCL language with C++, and I'm having a little trouble getting started. I've purchased a machine to start developing natively on, with an A10 5800K as the APU. I've downloaded the latest AMDAPP sdk, and have installed the drivers in Ubuntu's repos. (more on my software later down). I first had issues compiling the samples, but I sorted that out with another post, adding #include <unist.h> in the samples/opencl/SDKUtil/include/SDKCommon.hpp file. I'm now able to compile the samples, and I can run clinfo, as well as HelloCL. The output are below:
clinfo
kyle@lal:/opt/AMDAPP/samples/opencl/bin/x86_64$ clinfo
Number of platforms: 1
Platform Profile: FULL_PROFILE
Platform Version: OpenCL 1.2 AMD-APP (923.1)
Platform Name: AMD Accelerated Parallel Processing
Platform Vendor: Advanced Micro Devices, Inc.
Platform Extensions: cl_khr_icd cl_amd_event_callback cl_amd_offline_devices
Platform Name: AMD Accelerated Parallel Processing
Number of devices: 2
Device Type: CL_DEVICE_TYPE_GPU
Device ID: 4098
Board name: AMD Radeon HD 7660D
Device Topology: PCI[ B#0, D#1, F#0 ]
Max compute units: 6
Max work items dimensions: 3
Max work items[0]: 256
Max work items[1]: 256
Max work items[2]: 256
Max work group size: 256
Preferred vector width char: 16
Preferred vector width short: 8
Preferred vector width int: 4
Preferred vector width long: 2
Preferred vector width float: 4
Preferred vector width double: 0
Native vector width char: 16
Native vector width short: 8
Native vector width int: 4
Native vector width long: 2
Native vector width float: 4
Native vector width double: 0
Max clock frequency: 800Mhz
Address bits: 32
Max memory allocation: 134217728
Image support: Yes
Max number of images read arguments: 128
Max number of images write arguments: 8
Max image 2D width: 8192
Max image 2D height: 8192
Max image 3D width: 2048
Max image 3D height: 2048
Max image 3D depth: 2048
Max samplers within kernel: 16
Max size of kernel argument: 1024
Alignment (bits) of base address: 2048
Minimum alignment (bytes) for any datatype: 128
Single precision floating point capability
Denorms: No
Quiet NaNs: Yes
Round to nearest even: Yes
Round to zero: Yes
Round to +ve and infinity: Yes
IEEE754-2008 fused multiply-add: Yes
Cache type: None
Cache line size: 0
Cache size: 0
Global memory size: 134217728
Constant buffer size: 65536
Max number of constant args: 8
Local memory type: Scratchpad
Local memory size: 32768
Kernel Preferred work group size multiple: 64
Error correction support: 0
Unified memory for Host and Device: 1
Profiling timer resolution: 1
Device endianess: Little
Available: Yes
Compiler available: Yes
Execution capabilities:
Execute OpenCL kernels: Yes
Execute native function: No
Queue properties:
Out-of-Order: No
Profiling : Yes
Platform ID: 0x00007fab7abbc140
Name: Devastator
Vendor: Advanced Micro Devices, Inc.
Device OpenCL C version: OpenCL C 1.2
Driver version: CAL 1.4.1741
Profile: FULL_PROFILE
Version: OpenCL 1.2 AMD-APP (923.1)
Extensions: cl_amd_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_gl_sharing cl_ext_atomic_counters_32 cl_amd_device_attribute_query cl_amd_vec3 cl_amd_printf cl_amd_media_ops cl_amd_popcnt
Device Type: CL_DEVICE_TYPE_CPU
Device ID: 4098
Board name:
Max compute units: 4
Max work items dimensions: 3
Max work items[0]: 1024
Max work items[1]: 1024
Max work items[2]: 1024
Max work group size: 1024
Preferred vector width char: 16
Preferred vector width short: 8
Preferred vector width int: 4
Preferred vector width long: 2
Preferred vector width float: 4
Preferred vector width double: 0
Native vector width char: 16
Native vector width short: 8
Native vector width int: 4
Native vector width long: 2
Native vector width float: 4
Native vector width double: 0
Max clock frequency: 3800Mhz
Address bits: 64
Max memory allocation: 2147483648
Image support: Yes
Max number of images read arguments: 128
Max number of images write arguments: 8
Max image 2D width: 8192
Max image 2D height: 8192
Max image 3D width: 2048
Max image 3D height: 2048
Max image 3D depth: 2048
Max samplers within kernel: 16
Max size of kernel argument: 4096
Alignment (bits) of base address: 1024
Minimum alignment (bytes) for any datatype: 128
Single precision floating point capability
Denorms: Yes
Quiet NaNs: Yes
Round to nearest even: Yes
Round to zero: Yes
Round to +ve and infinity: Yes
IEEE754-2008 fused multiply-add: Yes
Cache type: Read/Write
Cache line size: 64
Cache size: 16384
Global memory size: 3834286080
Constant buffer size: 65536
Max number of constant args: 8
Local memory type: Global
Local memory size: 32768
Kernel Preferred work group size multiple: 1
Error correction support: 0
Unified memory for Host and Device: 1
Profiling timer resolution: 1
Device endianess: Little
Available: Yes
Compiler available: Yes
Execution capabilities:
Execute OpenCL kernels: Yes
Execute native function: Yes
Queue properties:
Out-of-Order: No
Profiling : Yes
Platform ID: 0x00007fab7abbc140
Name: AMD A10-5800K APU with Radeon(tm) HD Graphics
Vendor: AuthenticAMD
Device OpenCL C version: OpenCL C 1.2
Driver version: 2.0 (sse2,avx,fma4)
Profile: FULL_PROFILE
Version: OpenCL 1.2 AMD-APP (923.1)
Extensions: cl_khr_fp64 cl_amd_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_byte_addressable_store cl_khr_gl_sharing cl_ext_device_fission cl_amd_device_attribute_query cl_amd_vec3 cl_amd_printf cl_amd_media_ops cl_amd_popcnt
HelloCL
kyle@lal:/opt/AMDAPP/samples/opencl/bin/x86_64$ ./HelloCL
HelloCL!
Getting Platform Information
Creating a context AMD platform
Getting device info
Loading and compiling CL source
Running CL program
Done
Passed!
It appears that everything is installed correctly. However, when I try to run any other sample, I get an error; here is some output of two of the compiled examples:
kyle@lal:/opt/AMDAPP/samples/opencl/bin/x86_64$ ./MersenneTwister
Platform 0 : Advanced Micro Devices, Inc.
Platform found : Advanced Micro Devices, Inc.
Selected Platform Vendor : Advanced Micro Devices, Inc.
Device 0 : Devastator Device ID is 0xb8d460
Error: clCreateCommandQueue failed. Error code : CL_OUT_OF_HOST_MEMORY
kyle@lal:/opt/AMDAPP/samples/opencl/bin/x86_64$ ./SimpleGL
Platform 0 : Advanced Micro Devices, Inc.
Platform found : Advanced Micro Devices, Inc.
Selected Platform Vendor : Advanced Micro Devices, Inc.
Device 0 : Devastator Device ID is 0x1d92660
Number of displays 1
glXCreateContextAttribsARB 0x7f164889a000
Number of interoperable devices 1
Interop Device ID is 0x1d92660
libGL error: failed to load driver: swrast
libGL error: Try again with LIBGL_DEBUG=verbose for more details.
Error: clCreateCommandQueue failed. Error code : CL_OUT_OF_HOST_MEMORY
Location : SimpleGL.cpp:719
I'm guessing I'm running out of memory, or at least that is what the error code would lead me to believe. I'm sure that I have enough free memory in the system to run these programs, so there must be something else software related causing the error.
My hardware specs:
kyle@lal:/opt/AMDAPP/samples/opencl/bin/x86_64$ sudo lshw -sanitize -short
H/W path Device Class Description
================================================
system To Be Filled By O.E.M. (To Be Filled By O.E.M.)
/0 bus FM2A75M-DGS
/0/0 memory 64KiB BIOS
/0/8 memory 4GiB System Memory
/0/8/0 memory 2GiB DIMM DDR3 Synchronous 933 MHz (1.5 ns)
/0/8/1 memory 2GiB DIMM DDR3 Synchronous 933 MHz (1.5 ns)
/0/f memory 192KiB L1 cache
/0/10 memory 4MiB L2 cache
/0/16 processor AMD A10-5800K APU with Radeon(tm) HD Graphics
/0/100 bridge Family 15h (Models 10h-1fh) Processor Root Complex
/0/100/1 display Trinity [Radeon HD 7660D]
/0/100/1.1 multimedia Advanced Micro Devices [AMD] nee ATI
/0/100/5 bridge Family 15h (Models 10h-1fh) Processor Root Port
/0/100/5/0 eth0 network RTL8111/8168B PCI Express Gigabit Ethernet controller
/0/100/10 bus Hudson USB XHCI Controller
/0/100/10.1 bus Hudson USB XHCI Controller
/0/100/11 storage Hudson SATA Controller [AHCI mode]
/0/100/12 bus Hudson USB OHCI Controller
/0/100/12.2 bus Hudson USB EHCI Controller
/0/100/13 bus Hudson USB OHCI Controller
/0/100/13.2 bus Hudson USB EHCI Controller
/0/100/14 bus Hudson SMBus Controller
/0/100/14.1 storage Hudson IDE Controller
/0/100/14.2 multimedia Hudson Azalia Controller
/0/100/14.3 bridge Hudson LPC Bridge
/0/100/14.4 bridge Hudson PCI Bridge
/0/100/14.5 bus Hudson USB OHCI Controller
/0/101 bridge Family 15h (Models 10h-1fh) Processor Function 0
/0/102 bridge Family 15h (Models 10h-1fh) Processor Function 1
/0/103 bridge Family 15h (Models 10h-1fh) Processor Function 2
/0/104 bridge Family 15h (Models 10h-1fh) Processor Function 3
/0/105 bridge Family 15h (Models 10h-1fh) Processor Function 4
/0/106 bridge Family 15h (Models 10h-1fh) Processor Function 5
/0/1 scsi0 storage
/0/1/0.0.0 /dev/sda disk 64GB OCZ-VERTEX4
My Software:
Ubuntu 12.10 x86_64
gcc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2
GNU Make 3.81
AMD APP SDK 2.7
AMD Linux Catalyst
Driver Packaging 9.00.11-120920a-147436C-ATI
2D Driver Version 9.0.2
Catalyst Control Center Version 2.17
RandR Version 1.3
OpenGL Version 4.2.11903 Compatability Profile Context
I apologize for the lengthy post, but I wanted to include as much as info as possible up front. If more software info is needed I'll be happy to post back. Stated clearly, my question is why am I receiving the CL_OUT_OF_HOST_MEMORY errors on the compiled examples, and what action do I need to take to correct the errors?
Thanks in advance
Kyle Bentley
I think I may have found the solution to my problem. In the BIOS, the amount of shared video memory was set to auto, and I had assumed it could be allocated on demand. I'm still not sure if this is the case. I changed the amount of shared memory to 512 MB, the max setting, and I was able to run all of the sample programs successfully. That leads me to another question though; how much system ram can an APU allocate to the GPU? I was under the assumption it could let it have all the RAM it wanted, but perhaps my motherboard is limiting me to 512 MB?
EDIT: It turns out that I was running an early BIOS. There was an updated BIOS released by AsRock just a few days ago that sets the correct limit to 2 GB. Everything seems to be running fine now. Marking as solved.
Message was edited by: Kyle Bentley