[petsc-dev] Using multiple mallocs with PETSc

Jeff Hammond jeff.science at gmail.com
Fri Mar 10 20:55:59 CST 2017



> On Mar 10, 2017, at 12:42 PM, Jed Brown <jed at jedbrown.org> wrote:
> 
> Jeff Hammond <jeff.science at gmail.com> writes:
>> My intuition is that any HPC code that benefits from mapping the zero page
>> vs memset is doing something wrong.
> 
> The relevant issue is the interface, from
> 
>  a = malloc(size);
>  // need to fault the memory using first-touch
>  #pragma omp parallel
>  {
>    // memset my part
>  }
> 
>  // ...
>  #pragma omp parallel
>  {
>    // Use a[] knowing it starts zeroed
>  }
> 
> versus
> 
>  a = calloc(size,1);
> 
>  // ...
>  #pragma omp parallel
>  {
>    // Use a[] knowing it starts zeroed
>  }

I agree 100% that multithreaded codes that fault pages from the main thread in a NUMA environment are doing something wrong ;-)

Does calloc *guarantee* pages are not mapped? If I calloc(8), do I get the zero page or part of the arena that's already mapped that is zeroed by the heap manager?

Jeff


More information about the petsc-dev mailing list