Next: Synchronization
Up: Application Programming Interface
Previous: Process Creation
void *SMP_Getshmem(size_t size);
- C: gets a piece of shared memory with ``size'' bytes.
A pointer to the allocated memory segment is returned.
Restriction: The function is usually called before
SMP_Fork.
But the function may also be used after SMP_Fork,
in which case it must be called by all the processes with
the same requested size.
The same restriction applies to other shared-memory-allocation
routines (including Fortran routines).
- error code:
SMP_ERR_MALLOC
SUBROUTINE SMP_GETSHMEM(REFP, KIND, SIZE, IOFF)
<type> REFP(1)
INTEGER KIND, SIZE
<pointer> IOFF
- Fortran: gets a piece of shared memory for ``kind''
with ``size'' elements.
<type> is the reference type, such as REAL, INTEGER,...
KIND is one of (1,2,4,8,16) as the size of the reference type
SIZE is the number of elements to be allocated
<pointer> is a type large enough to hold an address:
for 32-bit, this is INTEGER*4;
for 64-bit, this is INTEGER*8.
Reference to the allocated shared memory is done by REFP(IOFF)
as the first element.
The function may be used after SMP_FORK, but should be
called by all the processes with the same requested size.
- error code:
SMP_ERR_MALLOC, SMP_ERR_KIND
SUBROUTINE SMP_GETSHMEMP(KIND, SIZE, IPTR)
INTEGER KIND, SIZE
POINTER IPTR
- Fortran: gets a piece of shared memory for ``kind" with
``size" elements.
KIND is a positive scaling factor for the size of the data type
SIZE is the number of elements to be allocated
IPTR is the returned pointer that points to the allocated memory.
This function can be used on platform that supports the Cray pointer.
Typically a variable is declared as
<type> VAR(100)
POINTER (IPTR,VAR)
Reference to the allocated shared memory is done by VAR(1) as
the first element.
The approach works for both 32-bit and 64-bit platforms.
Combining with a large value of "kind" this function
can be used to allocate memory larger than 2 GB.
See SMP_Getshmem() for usage restriction.
- error code:
SMP_ERR_MALLOC, SMP_ERR_KIND
void *SMP_Resetshmem(void *ptr, size_t size);
- C: resets the size of a shared memory buffer that was
previously allocated. ``ptr'' points to the old memory buffer
and ``size'' is the new size. The function returns a pointer to
the newly re-allocated memory buffer. If size=0, the function
frees the previously allocated shared memory buffer. The same restriction
to
SMP_Getshmem applies to this function as well.
See SMP_Getshmem() for usage restriction.
- error code:
SMP_ERR_MALLOC, SMP_ERR_MEMPTR
SUBROUTINE SMP_RESETSHMEM(REFP, KIND, SIZE, IOFF)
<type> REFP(1)
INTEGER KIND, SIZE
<pointer> IOFF
- Fortran: resets the size of a shared memory buffer that was
previously allocated. See
SMP_GETSHMEM for a description on
the argument list
and SMP_Getshmem() for usage restriction.
- error code:
SMP_ERR_MALLOC, SMP_ERR_MEMPTR,
SMP_ERR_KIND
SUBROUTINE SMP_RESETSHMEMP(KIND, SIZE, IPTR)
INTEGER KIND, SIZE
POINTER IPTR
- Fortran: resets the size of a shared memory buffer that was
previously allocated. See
SMP_GETSHMEMP for a description on
the argument list
and SMP_Getshmem() for usage restriction.
- error code:
SMP_ERR_MALLOC, SMP_ERR_MEMPTR,
SMP_ERR_KIND
int SMP_Pagesize(void);
INTEGER FUNCTION SMP_PAGESIZE()
- returns the memory page size in bytes.
Next: Synchronization
Up: Application Programming Interface
Previous: Process Creation
Haoqiang Jin
2005-08-10