ls_resreq() gets the resource requirements associated with a task name. With ls_resreq(), LSF applications or utilities can automatically retrieve the resource requirements of a given task if the user does not explicitly specify it. For example, the LSF utility lsrun tries to find the resource requirements of the user-typed command automatically if ‘‑R’ option is not specified by the user on the command line.
If taskname does not appear in the remote task list, ls_resreq() returns NULL.
Typically the resource requirements of a task are then used for host selection purpose. The following program takes the input argument as a task name, get the associated resource requirements from the remote task list, and then supply the resource requirements to a ls_placereq() call to get the best host for running this task.
#include <stdio.h>#include <lsf/lsf.h>int main(int argc, char *argv[]){char *taskname = argv[1];char *resreq;char **best;/* check the input format */if (argc != 2 ) {fprintf(stderr, "Usage: %s taskname\n", argv[0]);exit(‑1);}resreq = ls_resreq(taskname);/* get the resource requirement for the given command */if (resreq)printf("Resource requirement for %s is \"%s\".\n",taskname, resreq);elseprintf("Resource requirement for %s is NULL.\n", taskname);/* select the best host with the given resource requirement to run the job */best = ls_placereq(resreq, NULL, 0, NULL);if (best == NULL) {ls_perror("ls_placereq");exit(‑1);}printf("Best host for %s is <%s>\n", taskname, best[0]);exit(0);}
The above program will produce output similar to the following: