1 Reply Latest reply on Jan 24, 2009 9:47 PM by rick.weber

    What is the difference between this two samples ?

    kos

      first :

        calResMap((CALvoid**)&fdata, &pitch, outputRes, 0);
        if(!Info.Quiet)
       {
        for (CALint i = 0; i < 8; ++i)
        {
        CALfloat* tmp = &fdata[i * pitch];
        for(CALint j = 0; j < 8; ++j)
        {
        printf("%8.2f ", tmp[j]);
        }
        printf("\n");
        }
       }
        calResUnmap(outputRes);

      second :

      calResMap((CALvoid**)&fdata, &pitch, outputRes, 0);
      calResUnmap(outputRes);
       if(!Info.Quiet)
       {
        for (CALint i = 0; i < 8; ++i)
        {
        CALfloat* tmp = &fdata[i * pitch];
        for(CALint j = 0; j < 8; ++j)
        {
        printf("%8.2f ", tmp[j]);
        }
        printf("\n");
        }
       }

      Will second work fine in any case ?

        • What is the difference between this two samples ?
          rick.weber

          I believe that the first example will exhibit the behavior you're looking for. calResMap takes a resource on the GPU and maps it to a PCIe buffer so you can write data. When you call calResUnmap, all the data you put into that buffer is sent to the GPU and the memory address range becomes meaningless once again. In the second case, you may get a segmentation fault or the addresses may be remapped to another page etc. As such, always use the first paradigm when reading/copying a result from the GPU.