Debugging the shared memory size issue 

What happens if we exceed the size of the shared memory device if we have forgotten to increase the size as described earlier? Let's say we need to allocate 20 GiB but there is only 16 GiB:

There is no error even though we have exceeded the limit! Are we getting a free ride? The answer is no. It turns out that Julia does not know the limit has been breached. We can even work with the array up close and personal to the 16 GiB mark:

The preceding code simply sets the first 15 GiB of memory to 0x01. No error is shown so far. Going back to the shell, we can check the size of /dev/shm again. Clearly, 15 GiB is in use:

Now, if we continue to assign values to the later part of the array, we get an ugly Bus error and a long stack trace:

You may wonder why Julia cannot be smarter and tell you up front that you do not have enough shared memory space. As it turns out, it's the same behavior if you had used the underlying operating system's mmap function. Honestly, Julia just does not have any more information about the system constraint.

Sometimes, a C function's manual page can be useful and provide some hints. For example, the documentation about the mmap call indicates that a SIGBUS signal will be thrown when the program attempts to access an unreachable portion of the memory buffer. The manual page can be found at https://linux.die.net/man/2/mmap.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.39.23