5 Replies Latest reply on Aug 20, 2010 10:53 PM by notyou

    Problem with cl_amd_printf

    notyou

      Hello,

      Since moving to SDK 2.1, I've noticed that printf no longer works. From searching, it seems that plain old printf is no longer supported and that cl_amd_printf has been commissioned to replace it. The issue I'm having is that when I try to use it, the OpenCL program compiles but comes back with the warning, unrecognized extension and nothing prints.

      I've tried adding "#pragma OPENCL EXTENSION cl_amd_printf : enable" to both my .cl and main.cpp files and neither helps.

      Is there any documentation on this extension because I couldn't seem to find any? Are there any restrictions as to format (provided it is different than the standard printf)? I should also note that I've been running the code on an Intel CPU, if it makes a difference.

      Because of this, I've had to revert back to 2.01 for debugging, which is a lot of trouble for such a small change.

      -Matt

        • Problem with cl_amd_printf
          genaganna

           

          Originally posted by: notyou Hello,

           

          Since moving to SDK 2.1, I've noticed that printf no longer works. From searching, it seems that plain old printf is no longer supported and that cl_amd_printf has been commissioned to replace it. The issue I'm having is that when I try to use it, the OpenCL program compiles but comes back with the warning, unrecognized extension and nothing prints.

           

          I've tried adding "#pragma OPENCL EXTENSION cl_amd_printf : enable" to both my .cl and main.cpp files and neither helps.

           

          Is there any documentation on this extension because I couldn't seem to find any? Are there any restrictions as to format (provided it is different than the standard printf)? I should also note that I've been running the code on an Intel CPU, if it makes a difference.

           

          Because of this, I've had to revert back to 2.01 for debugging, which is a lot of trouble for such a small change.

           

          -Matt

           

          As we know printf should work without any issue. Please post your code here.

            • Problem with cl_amd_printf
              notyou

              Here's my code.

              Without the #pragma declared, I get the error: function "printf" declared implicitly. Which makes sense if 2.1 removed printf from the supported features, replacing it with cl_amd_printf.

              With the #pragma declared in the main file, I get the same error. Also, the compiler detects it as an unknown pragma.

              Now, with the #pragma inside the OpenCL file, I get the warning: ignore unrecognized OpenCL extension at which point it throws an access violation because of this.

              I think I realize what I didn't do. I didn't include any file containing this declaration. Do I need to include one or is this handled at a lower level? If so, do you know the location of it because I can't seem to find it?

              OpenCL: #pragma OPENCL EXTENSION cl_amd_printf : enable __kernel void knapsack(__global int *gpu_subset, __global int *weight, __global int *profit, int i, int NUM_COLS) { int local_id = get_local_id(0); printf("%i >= %i && (%i + %i) > %i\n", local_id, weight[i-1], gpu_subset[local_id - weight[i-1]], profit[i-1], gpu_subset[local_id]); if(local_id >= weight[i - 1] && (gpu_subset[local_id - weight[i - 1]] + profit[i - 1]) > gpu_subset[local_id]) { gpu_subset[NUM_COLS + local_id] = (gpu_subset[local_id - weight[i - 1]] + profit[i - 1]); printf("1%i NUM_COLS: %i + local_id: %i, gpu_subset[NUM_COLS + local_id]%i = \n", i, NUM_COLS, local_id, gpu_subset[NUM_COLS + local_id]); printf("gpu_subset[local_id - weight[i-1]]%i + profit[i-1]%i\n", gpu_subset[local_id - weight[i-1]], profit[i-1]); } else { gpu_subset[NUM_COLS + local_id] = gpu_subset[local_id]; printf("2%i NUM_COLS: %i + local_id: %i, gpu_subset[NUM_COLS + local_id]%i = \n", i, NUM_COLS, local_id, gpu_subset[NUM_COLS + local_id]); printf("gpu_subset[local_id]: %i\n", gpu_subset[local_id]); } }

                • Problem with cl_amd_printf
                  omkaranathan

                  notyou,

                  Please check the supported extensions with clGetDeviceInfo API call, CLInfo sample will also list the supported extensions. If the extension is listed, it should work.

                   

                    • Problem with cl_amd_printf
                      notyou

                      Sorry for the late reply, cl_amd_printf is returned in the list of extensions when I query clGetDeviceInfo(...), but printf still doesn't work.

                      This was tested on an Intel i7-720QM and before this, I was using a Celeron E3200 and a C2D E8400 (though I did not check to see if cl_amd_printf was supported on either of these last two, but I assume it is).

                      In case it was missed in my last post, is there any file I need to include from the SDK in order to use this extension, or is this handled at a lower level?