Trading Catechism

Last edited:
Intel also supports OpenCL (not the Altera OCL). It is also free and integrates nicely with MS Visual Studio. But this is for CPU.

AFAIK, gcc/g++ does not target FPGA, just CPU and maybe GPU. Otherwise if it cross compiled to FPGA, that would rule.

In the Altera SDK manual (it seems to be about FPGA I think) they write to use gcc on Linux (on p. 1-2):
https://www.altera.com/ja_JP/pdfs/literature/hb/opencl-sdk/aocl_getting_started.pdf
Ok, then maybe still the licence problem will happen since it is Altera... :-)
 
In Linux (Ubuntu/Debian) the following packages with "opencl" in their names/descriptions are available to install (but dunno if it supports FPGA, or whether cross-compiling is possible):
Code:
p   amd-libopencl1                  - AMD OpenCL ICD Loader library       
p   amd-libopencl1:i386             - AMD OpenCL ICD Loader library       
p   amd-opencl-dev                  - AMD OpenCL development files       
p   amd-opencl-dev:i386             - AMD OpenCL development files       
p   amd-opencl-icd                  - non-free AMD OpenCL ICD Loaders     
p   amd-opencl-icd:i386             - non-free AMD OpenCL ICD Loaders     
v   amd-opencl-icd-virtual          -                                     
v   amd-opencl-icd-virtual:i386     -                                     
p   boinc-amd-opencl                - metapackage for AMD/ATI OpenCL-savvy BOINC
p   boinc-amd-opencl:i386           - metapackage for AMD/ATI OpenCL-savvy BOINC
v   libopencl-1.1-1                 -                                     
v   libopencl-1.1-1:i386            -                                     
v   libopencl-1.2-1                 -                                     
v   libopencl-1.2-1:i386            -                                     
v   libopencl-2.0-1                 -                                     
v   libopencl-2.0-1:i386            -                                     
v   libopencl1                      -                                     
v   libopencl1:i386                 -                                     
v   manpages-opencl                 -                                     
p   mesa-opencl-icd                 - free implementation of the OpenCL API -- I
p   mesa-opencl-icd:i386            - free implementation of the OpenCL API -- I
p   mesa-opencl-icd-dbg             - free implementation of the OpenCL API -- d
p   mesa-opencl-icd-dbg:i386        - free implementation of the OpenCL API -- d
p   nvidia-libopencl1               - NVIDIA OpenCL ICD Loader library   
p   nvidia-libopencl1:i386          - NVIDIA OpenCL ICD Loader library   
p   nvidia-opencl-common            - NVIDIA OpenCL driver               
p   nvidia-opencl-common:i386       - NVIDIA OpenCL driver               
p   nvidia-opencl-dev               - NVIDIA OpenCL development files     
p   nvidia-opencl-dev:i386          - NVIDIA OpenCL development files     
p   nvidia-opencl-icd               - NVIDIA OpenCL installable client driver (I
p   nvidia-opencl-icd:i386          - NVIDIA OpenCL installable client driver (I
i A ocl-icd-libopencl1              - Generic OpenCL ICD Loader           
p   ocl-icd-libopencl1:i386         - Generic OpenCL ICD Loader           
p   ocl-icd-opencl-dev              - OpenCL development files           
p   ocl-icd-opencl-dev:i386         - OpenCL development files           
p   opencl-1.2-html-doc             - OpenCL 1.2 documentation - html pages
p   opencl-1.2-man-doc              - OpenCL 1.2 documentation - man pages (expe
v   opencl-dev                      -                                     
v   opencl-dev:i386                 -                                     
p   opencl-headers                  - OpenCL (Open Computing Language) header fi
v   opencl-headers:i386             -                                     
v   opencl-icd                      -                                     
v   opencl-icd:i386                 -                                     
v   opencl-icd-1.1-1                -                                     
v   opencl-icd-1.2-1                -                                     
p   pocl-opencl-icd                 - pocl ICD                           
p   pyrit-opencl                    - OpenCL extension module for Pyrit   
p   pyrit-opencl:i386               - OpenCL extension module for Pyrit   
p   python-pyopencl                 - Python module to access OpenCL parallel co
p   python-pyopencl:i386            - Python module to access OpenCL parallel co
p   python-pyopencl-dbg             - Python module to access OpenCL API (debug
p   python-pyopencl-dbg:i386        - Python module to access OpenCL API (debug
p   python-pyopencl-doc             - module to access OpenCL parallel computati
p   python3-pyopencl                - Python 3 module to access OpenCL parallel
p   python3-pyopencl:i386           - Python 3 module to access OpenCL parallel
p   python3-pyopencl-dbg            - Python 3 module to access OpenCL API (debu
p   python3-pyopencl-dbg:i386       - Python 3 module to access OpenCL API (debu
 
Last edited:
I'm interessted in OpenCL, but I'll start with CPU and GPU initially... Ie. the easy & lowcost variant to see whether it brings anything useful beyond standard multithreading in the kind of applications I'm usually doing...
I'll start with this HowTo:
https://wiki.tiker.net/OpenCLHowTo
 
Last edited:
That won't grow any hair on your chest. [Hope you are not a woman :wtf::wtf::wtf:]
I have to lookup what that means... :)

I've been able to get started with an OpenCL AMD environment, but haven't studied yet what the cl-demo is doing at all :) as it asks for 2 numeric args, have given 64 and 32 without knowing yet what it might represent :)
But I see it thinks "MAX_CLOCK_FREQUENCY: 1400", but this is incorrect; it's just the current setting done by the cpu governor, max is 2500 MHz for each of the 4 cores.

$ make
gcc -std=gnu99 -ocl-demo cl-demo.c cl-helper.c -lrt -lOpenCL
gcc -std=gnu99 -oprint-devices print-devices.c cl-helper.c -lrt -lOpenCL

$ ./print-devices
platform 0: vendor 'Advanced Micro Devices, Inc.'
device 0: 'AMD A10-5750M APU with Radeon(tm) HD Graphics'

$ ./cl-demo 64 32
Choose platform:
[0] Advanced Micro Devices, Inc.
Enter choice: 0
Choose device:
[0] AMD A10-5750M APU with Radeon(tm) HD Graphics
Enter choice: 0
---------------------------------------------------------------------
NAME: AMD A10-5750M APU with Radeon(tm) HD Graphics
VENDOR: AuthenticAMD
PROFILE: FULL_PROFILE
VERSION: OpenCL 1.2 AMD-APP (1800.11)
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_3d_image_writes 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_media_ops2 cl_amd_popcnt cl_khr_spir cl_khr_gl_event
DRIVER_VERSION: 1800.11 (sse2,avx,fma4)

Type: CPU
EXECUTION_CAPABILITIES: Kernel Native
GLOBAL_MEM_CACHE_TYPE: Read-Write (2)
CL_DEVICE_LOCAL_MEM_TYPE: Global (2)
SINGLE_FP_CONFIG: 0xbf
QUEUE_PROPERTIES: 0x2

VENDOR_ID: 4098
MAX_COMPUTE_UNITS: 4
MAX_WORK_ITEM_DIMENSIONS: 3
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: 8
PREFERRED_VECTOR_WIDTH_DOUBLE: 4
MAX_CLOCK_FREQUENCY: 1400
ADDRESS_BITS: 64
MAX_MEM_ALLOC_SIZE: 2147483648
IMAGE_SUPPORT: 1
MAX_READ_IMAGE_ARGS: 128
MAX_WRITE_IMAGE_ARGS: 64
IMAGE2D_MAX_WIDTH: 8192
IMAGE2D_MAX_HEIGHT: 8192
IMAGE3D_MAX_WIDTH: 2048
IMAGE3D_MAX_HEIGHT: 2048
IMAGE3D_MAX_DEPTH: 2048
MAX_SAMPLERS: 16
MAX_PARAMETER_SIZE: 4096
MEM_BASE_ADDR_ALIGN: 1024
MIN_DATA_TYPE_ALIGN_SIZE: 128
GLOBAL_MEM_CACHELINE_SIZE: 64
GLOBAL_MEM_CACHE_SIZE: 16384
GLOBAL_MEM_SIZE: 7475437568
MAX_CONSTANT_BUFFER_SIZE: 65536
MAX_CONSTANT_ARGS: 8
LOCAL_MEM_SIZE: 32768
ERROR_CORRECTION_SUPPORT: 0
PROFILING_TIMER_RESOLUTION: 1
ENDIAN_LITTLE: 1
AVAILABLE: 1
COMPILER_AVAILABLE: 1
MAX_WORK_GROUP_SIZES: 1024 1024 1024
---------------------------------------------------------------------
*** Kernel compilation resulted in non-empty log message.
*** Set environment variable CL_HELPER_PRINT_COMPILER_OUTPUT=1 to see more.
*** NOTE: this may include compiler warnings and other important messages
*** about your code.
*** Set CL_HELPER_NO_COMPILER_OUTPUT_NAG=1 to disable this message.
0.000022 s
0.034223 GB/s
GOOD


Update:

When setting the above said EnvVar then the following output comes:
$ CL_HELPER_PRINT_COMPILER_OUTPUT=1 ./cl-demo 64 32

*** build of 'sum' on 'AMD A10-5750M APU with Radeon(tm) HD Graphics' said:
"/tmp/OCLN5DvmR.cl", line 1: warning: OpenCL extension is now part of core
#pragma OPENCL EXTENSION cl_khr_fp64: enable
^

*** (end of message)
0.000033 s
0.023338 GB/s
GOOD

Update-2:

It executes this OpenCL kernel code:
$ cat vec-add-soln.cl
Code:
#pragma OPENCL EXTENSION cl_khr_fp64: enable

__kernel void sum(
    __global const float *a,
    __global const float *b,
    __global float *c,
    long n)
{
  int gid = get_global_id(0);
  if (gid < n)
    c[gid] = a[gid] + b[gid];
}

I'll study the source later what the cl-demo is calculating at all, it seems to be some vector calculation...
 
Last edited:
Back
Top