AnsweredAssumed Answered

confirm bugs in cl_amd_printf

Question asked by mkohler on Jun 20, 2014
Latest reply on Sep 29, 2016 by dipak

Hello OpenCLers,


I'm seeing two problems with cl_amd_printf. These problems only occur when running on the GPU.


  1. If the input string doesn't include a % format specifier, the input string doesn't get printed.
  2. If the built kernel is retrieved from cache, a Segmentation fault occurs.


The details of my system are:

- Ubuntu 14.04 LTS, x86_64

- processor: AMD A10 7850K

- Catalyst 4.4.12874

- clinfo version: OpenCL 1.2 AMD-APP (1445.5)

- running on the GPU

 

I've pasted code to demonstrate these problems below. On my system, the first time the code is run it will print the "lucky number" line. The second time the code is run, I see the message that "Built kernel retrieved from cache" and a segmentation fault.

 

Mark

---------------------------------------------------------------------

import sys

import pyopencl as cl

 

KERNEL_STR = r'''

#pragma OPENCL EXTENSION cl_amd_printf : enable

 

__kernel void cl_kernel() {

    // The line below does not get printed.

    printf("Hello, world\n");

 

    // This line will get printed.

    printf("My lucky number is %d\n", 7);

 

    // The line below does not get printed.

    printf("Hello again.\n");

}

'''

 

 

def main():

    platform = cl.get_platforms()[0]

    devices = platform.get_devices(cl.device_type.GPU)

    ctx = cl.Context(devices)

    device = devices[0]

    cmd_q = cl.CommandQueue(ctx, device)

 

    program = cl.Program(ctx, KERNEL_STR)

    program.build(devices=[device])

 

    program.cl_kernel(cmd_q, (4,), None)

 

 

if __name__ == '__main__':

    sys.exit(main())

Outcomes