DPLACE(3) DPLACE(3)
NAME
dplacefile, dplaceline, libdplace - a library interface to dplace
C SYNOPSIS
void dplacefile( char *filename);
void dplaceline( char *line);
FORTRAN SYNOPSIS
CHARACTER*n string
CALL dplacefile( string)
CALL dplaceline( string)
DESCRIPTION
These library routines provide high level access to a subset of the
memory management and control mechanisms of IRIX. Dynamic dplace(1)
functionality is provided from within a user's program. The first form
takes a filename as an argument and all commands within the file are
processed. The second form operates on a single command. Errors are
handled in the same way as dplace(1); the program exits and a diagnostic
message is printed to standard error. The library can be used with or
without using dplace(1).
EXAMPLE CODE
Here is a fragment of FORTRAN code
CHARACTER*128 s
np = mpnumthreads()
WRITE(s,*) 'memories ',np,' in cube'
CALL dplaceline(s)
WRITE(s,*) 'threads ',np
CALL dplaceline(s)
DO i=0, np-1
WRITE(s,*) 'run thread',i,' on memory',i
CALL dplaceline(s)
head = %loc( a( 1+i*(n/np) ) )
tail = %loc( a( (i+1)*(n/np) ) )
WRITE(s,*) 'place range',head,' to',tail,' on memory',i
CALL dplaceline(s)
END DO
DO i=0, np-1
WRITE(s,*) 'move thread',i,' to memory',np-1-i
CALL dplaceline(s)
END DO
Page 1
DPLACE(3) DPLACE(3)
DO i=0, np-1
head = %loc( a( 1+i*(n/np) ) )
tail = %loc( a( (i+1)*(n/np) ) )
WRITE(s,*) 'migrate range',head,' to',tail,' to memory',np-1-i
CALL dplaceline(s)
END DO
and here is a C language code fragment:
main(){ /* C example code */
...
dplacefile("initialplacementfile");
...
... data initialization,sprocs etc.
...
for(i=0;i<nthreads;i++){
sprintf(cmd,"run thread %d on memory %d\n",i,i/2);
dplaceline(cmd);
...
sprintf(cmd,"migrate range %d to %d to memory %d\n"
,&a[i*size],&a[(i+1)size-1],i/2);
dplaceline(cmd);
...
}
}
When linking C or FORTRAN programs, the flag -ldplace will automatically
invokes the correct libdplace library.
FILES
/usr/lib/libdplace.so
/usr/lib64/libdplace.so
/usr/lib32/libdplace.so
DEPENDENCIES
These procedures are only available on NUMA systems. In order to avoid
conflicts with Fortran's libmp, it is advisable to set the environment
variable _DSM_OFF to disable libmp's NUMA functionality before running
programs that are linked with libdplace.
BUGS
Operations on the default policy module, such as the setting of default
page sizes, should be done prior to an exec call to take effect. For
example, setting the data page size with dplaceline or dplacefile from
the program in question will not have the desired effect.
Page 2
DPLACE(3) DPLACE(3)
SEE ALSO
dplace(1), dplace(5)
Page 3