如果不能正常显示,请查看原文 , 或返回

Submitting your first Condor job

Submitting your first Condor job

First you need a job

Before you can submit a job to Condor, you need a job. We will quickly write a small program in C. If you aren't an expert C program, fear not. We will hold your hand throughout this process.

First, create a file called simple.c using your favorite editor. In that file, put the following text. Copy and paste is a good choice:

#include 

main(int argc, char **argv)
{
    int sleep_time;
    int input;
    int failure;

    if (argc != 3) {
        printf("Usage: simple  \n");
        failure = 1;
    } else {
        sleep_time = atoi(argv[1]);
        input      = atoi(argv[2]);

        printf("Thinking really hard for %d seconds...\n", sleep_time);
        sleep(sleep_time);
        printf("We calculated: %d\n", input * 2);
        failure = 0;
    }
    return failure;
}

Now compile that program:

% gcc -o simple simple.c

% ls -lh simple
-rwxrwxr-x  1 roy roy 5.1K Jan 25 12:24 simple*

Finally, run the program and tell it to sleep for four seconds and calculate 10 * 2:

% ./simple 4 10
Thinking really hard for 4 seconds...
We calculated: 20

Great! You have a job you can tell Condor to run! Although it clearly isn't an interesting job, it models some of the aspects of a real scientific program. It takes a while to run and it does a calculation.

Submitting your job

Now that you have a job, you just have to tell Condor to run it. Put the following text into a file called submit:

Universe   = vanilla
Executable = simple
Arguments  = 4 10
Log        = simple.log
Output     = simple.out
Error      = simple.error
Queue

Let's examine each of these lines:

  • Universe: The vanilla universe means a plain old job. Later on, we'll encounter some special universes.
  • Executable: The name of your program
  • Arguments: These are the arguments you want. They will be the same arguments we typed above.
  • Log: This is the name of a file where Condor will record information about your job's execution. While it's not required, it is a really good idea to have a log.
  • Output: Where Condor should put the standard output from your job.
  • Error: Where Condor should put the standard error from your job. Our job isn't likely to have any, but we'll put it there to be safe.

Next, tell Condor to run your job:

% condor_submit submit
Submitting job(s)con.
Logging submit event(s).
1 job(s) submitted to cluster 6075.

Now, watch your job run:

% condor_q

-- Submitter: hal.fnal.gov :  : hal.fnal.gov
 ID      OWNER            SUBMITTED     RUN_TIME ST PRI SIZE CMD               
4589.0   doronn          3/30 18:07  19+09:26:01 I  0   0.0  go1               
...
6073.3   zomerosn       12/17 17:46   0+07:30:15 R  0   1.3  q1 Arabidopsis_tha
6075.0   alainroy       12/18 01:16   0+00:00:00 I  0   0.0  simple 4 10   

% condor_q -sub alainroy

-- Submitter: alainroy@cs.tau.ac.il :  : hal.fnal.gov
 ID      OWNER            SUBMITTED     RUN_TIME ST PRI SIZE CMD               
6075.0   alainroy       12/18 01:16   0+00:00:04 R  0   0.0  simple 4
 10  

% condor_q -sub alainroy

-- Submitter: alainroy@cs.tau.ac.il :  : hal.fnal.gov
 ID      OWNER            SUBMITTED     RUN_TIME ST PRI SIZE CMD               
6075.0   alainroy       12/18 01:16   0+00:00:29 R  0   0.0  simple 4
 10     

% condor_q -sub alainroy
-- Submitter: alainroy@cs.tau.ac.il :  : hal.fnal.gov
 ID      OWNER            SUBMITTED     RUN_TIME ST PRI SIZE CMD               

0 jobs; 0 idle, 0 running, 0 held

Notice a few things here. First, when I did condor_q, I got a long list of everyone's jobs. (I trimmed the output above.) So I told condor_q to just list my jobs with the -sub option, which is short for submitter. You will want to substitute your user name for alainroy. When my job was done, it was no longer listed. Because I told Condor to log information about my job, I can see what happened:

% cat simple.log
000 (001.000.000) 01/25 12:25:43 Job submitted from host: 
...
001 (001.000.000) 01/25 12:25:45 Job executing on host: 
...
005 (001.000.000) 01/25 12:25:49 Job terminated.
        (1) Normal termination (return value 0)
                Usr 0 00:00:00, Sys 0 00:00:00  -  Run Remote Usage
                Usr 0 00:00:00, Sys 0 00:00:00  -  Run Local Usage
                Usr 0 00:00:00, Sys 0 00:00:00  -  Total Remote Usage
                Usr 0 00:00:00, Sys 0 00:00:00  -  Total Local Usage
        0  -  Run Bytes Sent By Job
        0  -  Run Bytes Received By Job
        0  -  Total Bytes Sent By Job
        0  -  Total Bytes Received By Job
...

That looks good: It took a few seconds for the job to start up, though you will often see slightly slower startups. (Particularly today on this poor old laptop that simulates a complete Condor pool.) Condor doesn't optimize for fast job startup, but for high throughput, The job ran for about four seconds. But did our job execute correctly? If this had been a real Condor pool, the execution computer would have been different than the submit computer, but otherwise it would have looked the same.

% cat simple.out
Thinking really hard for 4 seconds...
We calculated: 20

Excellent! We ran our sophisticated scientific job on a Condor pool!

Doing a parameter sweep

If you only ever had to run a single job, you probably wouldn't need Condor. But we would like to have our program calculate a whole set of values for different inputs. How can we do that? Let's change our submit file to look like this:

Universe   = vanilla
Executable = simple
Arguments  = 4 10
Log        = simple.log
Output     = simple.$(Process).out
Error      = simple.$(Process).error
Queue

Arguments = 4 11
Queue

Arguments = 4 12
Queue

There are two important differences to notice here. First, the Output and Error lines have the $(Process) macro in them. This means that the output and error files will be named according to the process number of the job. You'll see what this looks like in a moment. Second, we told Condor to run the same job an extra two times by adding extra Arguments and Queue statements. We are doing a parameter sweep on the values 10, 11, and 12. Let's see what happens:

%  condor_submit submit
Submitting job(s)...
Logging submit event(s)...
3 job(s) submitted to cluster 2.

% condor_q -sub roy

-- Submitter: roy@fnal.gov :  : hal.fnal.gov
 ID      OWNER            SUBMITTED     RUN_TIME ST PRI SIZE CMD               
   2.0   roy             1/25 12:28   0+00:00:00 R  0   0.0  simple 4 10       
   2.1   roy             1/25 12:28   0+00:00:00 R  0   0.0  simple 4 11       
   2.2   roy             1/25 12:28   0+00:00:00 R  0   0.0  simple 4 12       

3 jobs; 0 idle, 3 running, 0 held

% condor_q -sub roy


-- Submitter: roy@fnal.gov :  : hal.fnal.gov
 ID      OWNER            SUBMITTED     RUN_TIME ST PRI SIZE CMD               

0 jobs; 0 idle, 0 running, 0 held

% ls simple*out
simple.0.out  simple.1.out  simple.2.out  simple.out

% cat simple.0.out
Thinking really hard for 4 seconds...
We calculated: 20

% cat simple.1.out
Thinking really hard for 4 seconds...
We calculated: 22

% cat simple.2.out
Thinking really hard for 4 seconds...
We calculated: 24
Notice that we had three jobs with the same cluster number, but different process numbers. They have the same cluster number because they were all submitted from the same submit file. When the jobs ran, they created three different output files, each with the desired output.

You are now ready to submit lots of jobs! Although this example was simple, Condor has many, many options so you can get a wide variety of behaviors. You can find many of these if you look at the documentation for condor_submit.

Extra credit

  • What if you want the cluster number to be part of the output filename?
  • Condor sends you email when a job finishes. How can you control this?
  • Bonus points: You know that your job should never run for more than four hours. If it does, then the job should be killed because there is a problem. How can you tell Condor to do this for you?

Next: Submitting a standard universe job

返回