Share memory issue trying to set up inter-process communication

I tried to implement inter-process communication with Gaudi via Synapse. Standard pattern with file underneath has been implemented. We are not using mpi-run for reasons I do not want to go into, but we are doing our own inter-process communication using a shared buffer.

This is what we are doing:

int mem_fd = open(“/tmp”, O_TMPFILE | O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR);
if (mem_fd < 0) {
return FAIL;
}
if (ftruncate(mem_fd, data_size()) < 0) {
return FAIL;
}
void* mdata = mmap(nullptr, data_size(), PROT_READ | PROT_WRITE, MAP_SHARED, mem_fd, 0);
if (mdata == MAP_FAILED) {
return FAIL;
}
[…]
CHECK_SYNAPSE_STATUS(synHostMap(get_handle(), data_size(), (void*) mdata));

It turned, that mapping the data directly to Gaudi causes application to assert, and the kernel’s ioctl() responds with EFAULT (14) even with single process.
Is there any particular reason to fail requests with shared memory (e.g. particular pattern of addresses returned by mmap())?

The same code with malloc()works well in most cases, but some requests fails “randomly” (I haven’t found any pattern of address/data alignment).

The code was tested on a Gaudi-2 with Ubuntu 22.04 / linux kernel 6.5.0-1016 / Habana software version 1.15