cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

kos
Journeyman III

What is the difference between this two samples ?

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);
  }
  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);
  }
  printf("\n");
  }
 }

Will second work fine in any case ?

0 Likes
1 Reply
rick_weber
Adept II

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.

0 Likes