cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

___
Adept I

Strange printf behaviour on Vega

Tested on latest 19.10.1 drivers. Windows 10 x64 1903

I attached cl file and cpp program which would launch this simple addVec kernel.

Opencl code:

#pragma OPENCL EXTENSION cl_amd_printf : enable

__attribute__((reqd_work_group_size(WORKSIZE, 1, 1)))
__kernel void addVec(__global uint *a, __global uint *b, __global uint *c)
{
const uint gid = get_global_id(0);

uint aLocal = a[gid];
uint bLocal = b[gid];

// Good
printf("a[%u] = %u; b[%u] = %u;\n", gid, aLocal, gid, bLocal);

// Bad
/*printf("a[%u] = %u;\n", gid, aLocal);
printf("b[%u] = %u;\n", gid, bLocal);*/


c[gid] = aLocal + bLocal;
}

If you use printf from "Good" section output is fine as expected.

But if you comment first printf and uncomment 2 printfs from "Bad" section it would look like this on vega64:

a[0] = 128;
a[0] = 1024;
b[%u] = %u;

And like this on 5700XT:

a[0] = 128;
b[0] = 1024;

So it works correctly in case of navi and wrong in case of vega. It was broken on vega for a while, at least few months, maybe even before July. I don't remember when i first time noticed that more than 1 printf leads to strange output on vega.

14 Replies
dipak
Big Boss

Thank you for reporting the above "printf" issue and providing the reproducible test-case. We'll check and get back to you soon.

Thanks.

0 Likes

I've reported the issue to the OpenCL team and created a bug ticket against it. Once I get any feedback from them, I'll get back to you.

Thanks.

0 Likes

Update:

The printf issue has been fixed in the internal build. 

Thanks.

0 Likes
dipak
Big Boss

Could you please try the latest Adrenalin 19.12.3  and share your observation?

Thanks.

0 Likes

Sadly I'm still able to reproduce it.

clinfo log attached.

I have AMD and Nvidia platforms. AMD platform id is 0. I pick the correct one

If it is really needed - I can remove nvidia and reinstall drivers with cleanup, but this would take some time.

Number of platforms:                             2
  Platform Profile:                              FULL_PROFILE
  Platform Version:                              OpenCL 2.1 AMD-APP (3004.7)
  Platform Name:                                 AMD Accelerated Parallel Processing
  Platform Vendor:                               Advanced Micro Devices, Inc.
  Platform Extensions:                           cl_khr_icd cl_khr_d3d10_sharing cl_khr_d3d11_sharing cl_khr_dx9_media_sharing cl_amd_event_callback cl_amd_offline_devices
  Platform Profile:                              FULL_PROFILE
  Platform Version:                              OpenCL 1.2 CUDA 10.2.108
  Platform Name:                                 NVIDIA CUDA
  Platform Vendor:                               NVIDIA Corporation
  Platform Extensions:                           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_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_d3d10_sharing cl_khr_d3d10_sharing cl_nv_d3d11_sharing cl_nv_copy_opts cl_nv_create_buffer cl_khr_int64_base_atomics cl_khr_int64_extended_atomics


  Platform Name:                                 AMD Accelerated Parallel Processing
Number of devices:                               1
  Device Type:                                   CL_DEVICE_TYPE_GPU
  Vendor ID:                                     1002h
  Board name:                                    Radeon RX Vega
  Device Topology:                               PCI[ B#4, D#0, F#0 ]
  Max compute units:                             64
  Max work items dimensions:                     3
    Max work items[0]:                           1024
    Max work items[1]:                           1024
    Max work items[2]:                           1024
  Max work group size:                           256
  Preferred vector width char:                   4
  Preferred vector width short:                  2
  Preferred vector width int:                    1
  Preferred vector width long:                   1
  Preferred vector width float:                  1
  Preferred vector width double:                 1
  Native vector width char:                      4
  Native vector width short:                     2
  Native vector width int:                       1
  Native vector width long:                      1
  Native vector width float:                     1
  Native vector width double:                    1
  Max clock frequency:                           1750Mhz
  Address bits:                                  64
  Max memory allocation:                         4244635648
  Image support:                                 Yes
  Max number of images read arguments:           128
  Max number of images write arguments:          64
  Max image 2D width:                            16384
  Max image 2D height:                           16384
  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:                                    Read/Write
  Cache line size:                               64
  Cache size:                                    16384
  Global memory size:                            8573157376
  Constant buffer size:                          4244635648
  Max number of constant args:                   8
  Local memory type:                             Scratchpad
  Local memory size:                             32768
  Max pipe arguments:                            16
  Max pipe active reservations:                  16
  Max pipe packet size:                          4244635648
  Max global variable size:                      3820172032
  Max global variable preferred total size:      8573157376
  Max read/write image args:                     64
  Max on device events:                          1024
  Queue on device max size:                      8388608
  Max on device queues:                          1
  Queue on device preferred size:                262144
  SVM capabilities:
    Coarse grain buffer:                         Yes
    Fine grain buffer:                           Yes
    Fine grain system:                           No
    Atomics:                                     No
  Preferred platform atomic alignment:           0
  Preferred global atomic alignment:             0
  Preferred local atomic alignment:              0
  Kernel Preferred work group size multiple:     64
  Error correction support:                      0
  Unified memory for Host and Device:            0
  Profiling timer resolution:                    1
  Device endianess:                              Little
  Available:                                     Yes
  Compiler available:                            Yes
  Execution capabilities:
    Execute OpenCL kernels:                      Yes
    Execute native function:                     No
  Queue on Host properties:
    Out-of-Order:                                No
    Profiling :                                  Yes
  Queue on Device properties:
    Out-of-Order:                                Yes
    Profiling :                                  Yes
  Platform ID:                                   00007FFF181CBFD0
  Name:                                          gfx900
  Vendor:                                        Advanced Micro Devices, Inc.
  Device OpenCL C version:                       OpenCL C 2.0
  Driver version:                                3004.7 (PAL,HSAIL)
  Profile:                                       FULL_PROFILE
  Version:                                       OpenCL 2.0 AMD-APP (3004.7)
  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_fp16 cl_khr_gl_sharing cl_khr_gl_depth_images cl_amd_device_attribute_query cl_amd_vec3 cl_amd_printf cl_amd_media_ops cl_amd_media_ops2 cl_amd_popcnt cl_khr_d3d10_sharing cl_khr_d3d11_sharing cl_khr_dx9_media_sharing cl_khr_image2d_from_buffer cl_khr_subgroups cl_khr_gl_event cl_khr_depth_images cl_khr_mipmap_image cl_khr_mipmap_image_writes cl_amd_liquid_flash cl_amd_copy_buffer_p2p cl_amd_planar_yuv


  Platform Name:                                 NVIDIA CUDA
Number of devices:                               1
  Device Type:                                   CL_DEVICE_TYPE_GPU
  Vendor ID:                                     10deh
  Max compute units:                             15
  Max work items dimensions:                     3
    Max work items[0]:                           1024
    Max work items[1]:                           1024
    Max work items[2]:                           64
  Max work group size:                           1024
  Preferred vector width char:                   1
  Preferred vector width short:                  1
  Preferred vector width int:                    1
  Preferred vector width long:                   1
  Preferred vector width float:                  1
  Preferred vector width double:                 1
  Native vector width char:                      1
  Native vector width short:                     1
  Native vector width int:                       1
  Native vector width long:                      1
  Native vector width float:                     1
  Native vector width double:                    1
  Max clock frequency:                           1683Mhz
  Address bits:                                  64
  Max memory allocation:                         2147483648
  Image support:                                 Yes
  Max number of images read arguments:           256
  Max number of images write arguments:          16
  Max image 2D width:                            16384
  Max image 2D height:                           32768
  Max image 3D width:                            16384
  Max image 3D height:                           16384
  Max image 3D depth:                            16384
  Max samplers within kernel:                    32
  Max size of kernel argument:                   4352
  Alignment (bits) of base address:              4096
  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:                               128
  Cache size:                                    737280
  Global memory size:                            8589934592
  Constant buffer size:                          65536
  Max number of constant args:                   9
  Local memory type:                             Scratchpad
  Local memory size:                             49152
  Kernel Preferred work group size multiple:     32
  Error correction support:                      0
  Unified memory for Host and Device:            0
  Profiling timer resolution:                    1000
  Device endianess:                              Little
  Available:                                     Yes
  Compiler available:                            Yes
  Execution capabilities:
    Execute OpenCL kernels:                      Yes
    Execute native function:                     No
  Queue on Host properties:
    Out-of-Order:                                Yes
    Profiling :                                  Yes
  Platform ID:                                   000002877738D330
  Name:                                          GeForce GTX 1070
  Vendor:                                        NVIDIA Corporation
  Device OpenCL C version:                       OpenCL C 1.2
  Driver version:                                441.66
  Profile:                                       FULL_PROFILE
  Version:                                       OpenCL 1.2 CUDA
  Extensions:                                    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_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_d3d10_sharing cl_khr_d3d10_sharing cl_nv_d3d11_sharing cl_nv_copy_opts cl_nv_create_buffer cl_khr_int64_base_atomics cl_khr_int64_extended_atomics

0 Likes

Thank you for sharing the above observation.

I thought the fix was already part of this public driver. That's why I asked you to verify it. Let me check with the concerned team whether this Adrenalin driver has the fix or not. I'll get back to you shortly. 

Thanks.

0 Likes

Sorry for this delayed reply and thank you for your patience.

As I've been informed, this Adrenalin driver doesn't have the fix. By the way, I just verified the above code with an internal driver which has the fix and the issue is no longer reproducible there. 

Thanks.

0 Likes

As I checked, it looks like the issue is no longer reproducible with the latest Adrenalin 20.5.1. Could you please verify and confirm?

Thanks.

lolliedieb
Adept II

Wanted to add here that this is not only within same kernel, but also withing same program. What I mean: if multiple printf exist within the same OpenCL program a Vega (and also a Polaris) always print the format of the first occuring printf but with the data of the 2nd, sometimes. This even happens across kernel calls. After the wrong format one also gets the right one printed afterwards, but then with data missing.

Thank you for sharing the valuable inputs.

As I tested with a simple test-case, the fix seems working fine for the above scenario also.

Thanks.

0 Likes
fresto
Journeyman III

Dear support, I have a similar problem already as a year on AMD Vega 64. Now I installed the latest patch 20.4.2. There is the same problem with printf. Before that, I had already used OpenCL and several printf in one kernel worked fine. Can you still solve this problem?

0 Likes

Hi fresto

As I mentioned above, it looks like the issue is no longer reproducible with the latest Adrenalin 20.5.1. Could you please try this driver and share your observation?

Thanks.

Hi.

Tested original test case with Adrenalin 20.5.1. It works. Thank you!

___ wrote:

Hi.

Tested original test case with Adrenalin 20.5.1. It works. Thank you!

20.5.1 seems to be very stable so far

0 Likes