简体   繁体   中英

best way to allocate memory in C for parallel programming openmp and mpi

If one were to write C code, not C++, and were to use openmp directives to make a parallel program then what is the best way to allocate memory? I am used to the traditional malloc() and calloc() but i have also come across

#include <sys/sem.h>

for doing semaphores. Is one better or worse than the other?

The program i am considering writing would be using large amounts of RAM, on the order of 256GB or more. And it would also be reading/writing scratch files greater than 4GB. Therefore i would not be using the 32-bit version of the lseek() command but would use lseek64() . With all that in mind, can someone offer advice for the best way to write such a program? I had learned openmp a long time ago, and that generally will suffice for running on a single system having enough memory, but I mentioned MPI because i would be ok learning and using that instead if it makes everything more robust and portable. Or some other method of parallel programming in C.

考虑使用mmap和mremap来更快地重新映射内存,因为mremap()使用Linux页表方案。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM