ls_placereq() takes the form of:
On success, ls_placereq() returns an array of host names that best meet the resource requirements. Hosts listings may be duplicated for hosts that have sufficient resources to accept multiple tasks (for example, multiprocessors).
On failure, ls_placereq() returns NULL and sets lserrno to indicate the error.
The parameters for ls_placereq() are very similar to those of the ls_load() function described in the previous section.
LSLIB will append default resource requirement to resreq according to the rules described in “Handling Default Resource Requirements”.
Preference is given to fromhost over remote hosts that do not have a significantly lighter load or greater resources. This preference avoids unnecessary task transfer and reduces overhead. If fromhost is NULL, then the local host is assumed.
The following example takes a resource requirement string as an argument and displays the host in the LSF cluster that best satisfies the resource requirement.
#include <stdio.h>#include <lsf/lsf.h>main(argc, argv)int argc;char *argv[];{char *resreq = argv[1];char **best;int num = 1;int options = 0;char *fromhost = NULL;/* check the input format */if (argc != 2 ) {fprintf(stderr, "Usage: %s resreq\n", argv[0]);exit(‑2);}/* find the best host with the given condition (e.g. resource requirement) */best = ls_placereq(resreq, &num, options, fromhost);if (best == NULL) {ls_perror("ls_placereq()");exit(‑1);}printf("The best host is <%s>\n", best[0]);exit(0);}
The above program will produce output similar to the following:
LSLIB also provides a variant of ls_placereq(). ls_placeofhosts() lets you provide a list of candidate hosts. See the ls_policy(3) man page for details.