5 Replies Latest reply on Jun 16, 2014 5:13 AM by pinform

    printf from kernel misbehaves again

    Raistmer



      for (int j = 1; j < ndivs ; j++)



      {




      //perdiv *=2;




      tmp0 = di & 1;




      di >>= 1;




      tmp0 += di;




      dis_thresh = t_funct(di, num_adds, j,PulseMax,t_funct_cache_fp) * avg;




      {





      tmp_max = sumtop2(tmp_pot, tmp_pot, di, fft_len4, tmp0);




      }

      #if 1


      if(ul_PoT == 1 && y == 3 && z == 7 && p == 4454){


      printf("tmp_max=(%f,%f,%f,%f) dis_thresh=(%f,%f,%f,%f) j=%d\n",



      tmp_max.x,tmp_max.y,tmp_max.z,tmp_max.w,



      dis_thresh.x,dis_thresh.y,dis_thresh.z,dis_thresh.w,



      j);

      }

      #endif





      if (tmp_max.x>dis_thresh.x || tmp_max.y>dis_thresh.y ||





      tmp_max.z>dis_thresh.z || tmp_max.w>dis_thresh.w) {





      // unscale for reporting





      tmp_max /= (float4)num_adds_2;





      cur_thresh = (dis_thresh / (float4)num_adds_2 - avg) * rcfg_dis_thresh + avg;

       

       






      float4 _snr = (tmp_max-avg)/(cur_thresh-avg);

      #if 1


      if(ul_PoT == 1 && y == 3 && z == 7 && p == 4454){


      printf("_snr=(%f,%f,%f,%f) best_pulse_score=(%f)\n",



      _snr.x,_snr.y,_snr.z,_snr.w,best_pulse_score);

      }

      #endif






      if (_snr.x  > best_pulse_score ||






      _snr.y  > best_pulse_score ||






      _snr.z  > best_pulse_score ||






      _snr.w  > best_pulse_score) {






      result_flag[0].x = 1;printf("location 3 hit: ul_PoT=%d,y=%d,z=%d,p=%d\n",ul_PoT,y,z,p);return;





      }

      When it was %d instead %f for float values it worked OK.

      tmp_max=(1016206848,1016042150,1014254674,1015103447) dis_thresh=(1017574742,1017521425,1017343526,1017306023) j=1

      tmp_max=(1019540776,1019234484,1019323582,1019736860) dis_thresh=(1022113170,1022037738,1021786049,1021732991) j=2

      tmp_max=(1025885083,1025687250,1025025298,1024181522) dis_thresh=(1026938408,1026880340,1026686587,1026645743) j=3

      tmp_max=(1032427341,1033697660,1031554466,1031172886) dis_thresh=(1033265612,1033217589,1033057352,1033023573) j=4

      _snr=(1052921234,1058128081,1050160947,1049360638) best_pulse_score=(1063430413)

      tmp_max=(1039569588,1041180477,1038290570,1038685748) dis_thresh=(1040415552,1040373564,1040233466,1040203932) j=5

      _snr=(1052941357,1060001794,1049353865,1051071391) best_pulse_score=(1063430413)

      tmp_max=(1046772721,1049205382,1045513371,1045367322) dis_thresh=(1047492886,1047416412,1047161246,1047107455) j=6

      _snr=(1052854581,1063899244,1046138112,1044991040) best_pulse_score=(1063430413)

      location 3 hit: ul_PoT=1,y=3,z=7,p=4454

       

      Now I changed %d to %f where needed but output broken to signle line with ridiculous j value.

       

      What is wrong ????

        • Re: printf from kernel misbehaves again
          Raistmer

          btw, forum formatting just CRAZY. Why it used table for copy/paste from plain text editor???

            • Re: printf from kernel misbehaves again
              Raistmer

              Just trying to make code more easy to read:

               

               

               

                                            //          int j = 1;

                                            //float4 tmp_max2=(float4)0.f;

                                            for (int j = 1; j < ndivs ; j++)

                                            {

                                                      //perdiv *=2;

                                                      tmp0 = di & 1;

                                                      di >>= 1;

                                                      tmp0 += di;

                                                      dis_thresh = t_funct(di, num_adds, j,PulseMax,t_funct_cache_fp) * avg;

                                                      {

                                                                tmp_max = sumtop2(tmp_pot, tmp_pot, di, fft_len4, tmp0);

                                                      }

              #if 1

                        if(ul_PoT == 1 && y == 3 && z == 7 && p == 4454){

                                  printf("tmp_max=(%d,%d,%d,%d) dis_thresh=(%d,%d,%d,%d) j=%d\n",

                                            tmp_max.x,tmp_max.y,tmp_max.z,tmp_max.w,dis_thresh.x,dis_thresh.y,dis_thresh.z,dis_thresh.w,j);

                        }

              #endif

                                                      if (tmp_max.x>dis_thresh.x || tmp_max.y>dis_thresh.y ||

                                                                tmp_max.z>dis_thresh.z || tmp_max.w>dis_thresh.w) {

                                                                // unscale for reporting

                                                                tmp_max /= (float4)num_adds_2;

                                                                cur_thresh = (dis_thresh / (float4)num_adds_2 - avg) * rcfg_dis_thresh + avg;

               

               

                                                                float4 _snr = (tmp_max-avg)/(cur_thresh-avg);

              #if 1

                        if(ul_PoT == 1 && y == 3 && z == 7 && p == 4454){

                                  printf("_snr=(%d,%d,%d,%d) best_pulse_score=(%d)\n",

                                            _snr.x,_snr.y,_snr.z,_snr.w,best_pulse_score);

                        }

              #endif

                                                                if (_snr.x  > best_pulse_score ||

                                                                          _snr.y  > best_pulse_score ||

                                                                          _snr.z  > best_pulse_score ||

                                                                          _snr.w  > best_pulse_score) {

                                                                          result_flag[0].x = 1;printf("location 3 hit: ul_PoT=%d,y=%d,z=%d,p=%d\n",ul_PoT,y,z,p);return;

                                                                }

               

              when %d changed (only for floating point values of course) to %.4g or %f printf fails to print anything useful.

                • Re: printf from kernel misbehaves again
                  himanshu.gautam

                  Hi Raistmer,

                  Thanks for reporting the issue. Will it be possible for you attach a small testcase, which I can directly run and check if the issue is still present in our internal drivers.

                  One small suggestion, use %vn format strings when printing vectors. They are quite handy.

                    • Re: printf from kernel misbehaves again
                      Raistmer

                      Well, you could try attached pack.

                      But when I tried to reproduce issue on HD6950-based PC I got compilation failure:

                       

                      INFO: can't open binary kernel file: .\\MultiBeam_Kernels_r1812.clHD5_Cayman.bin_V7, continue with recompile...

                      Error : Building Program (source, clBuildProgram):main kernels: not OK code -11

                      C:\Users\R\AppData\Local\Temp\OCL7BF4.tmp.cl(2200): error: function "printf"

                                declared implicitly

                                  if(ul_PoT == 0 && y == 0 && z == 0) printf("Entering PulseFind\n");

                                                                      ^

                       

                       

                      C:\Users\R\AppData\Local\Temp\OCL7BF4.tmp.cl(2262): error: function "printf"

                                declared implicitly

                                                                printf("label 1\n");

                       

                       

                      Catalyst 12.1

                       

                      And it was compiled w/o issues on my dev netbook with some another Cat version.

                      [Another version is:

                        Name:




                      Loveland
                        Vendor:



                      Advanced Micro Devices, Inc.
                        Driver version:


                      CAL 1.4.1646 (VM)
                        Version:



                      OpenCL 1.2 AMD-APP (938.2)
                        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_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 cl_khr_d3d10_sharing

                      ]

                      This return us to previously reported issue: should printf extension be manually enabled or not. Looks like for this particular host with this partcular Catalyst version it should be...

                       

                      EDIT: same error on Catalyst 12.8 on Trinity APU.

                       

                        Name:




                      Devastator
                        Vendor:



                      Advanced Micro Devices, Inc.
                        Driver version:


                      CAL 1.4.1741 (VM)
                        Version:



                      OpenCL 1.1 AMD-APP (851.4)
                        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_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 cl_khr_d3d10_sharing