title: What's the equivalent system API implementation to cudaMallocHost
body: <p>Hi I want to allocate pinned memory but not using cudaMallocHost, I've read <a href="https://stackoverflow.com/questions/26888890/cuda-and-pinned-page-locked-memory-not-page-locked-at-all">this post</a> and tried to use fixed mmap to emulate 'cudaMallocHost' :</p>
  
  <pre><code>data_mapped_ = (void *)mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd_, 0);
  if(munmap(data_mapped_, sb.st_size) == -1) {
      cerr &lt;&lt; "munmap failed" &lt;&lt; endl;
      exit(-1);
  }
  
  data_mapped_ = (void *)mmap(data_mapped_, sb.st_size, PROT_READ, MAP_SHARED|MAP_FIXED, fd_, 0);
  </code></pre>
  
  <p>But this is still not as fast as cudaMallocHost. So what's the correct c implementation of pinned memory?</p>