BlueGene Homepage BlueGene Homepage BlueGene Homepage BlueGene Homepage

Examples: NY Blue/L Compile, Link and Run

IBM and GNU Cross Compilers

These are interactive job submission examples.

You should use the Bash shell for interactive job submission.

IBM Cross Compiler Example Using BASH Shell

GNU Cross Compiler Example Using BASH Shell

Back to User Guide


IBM Cross Compiler Example Using BASH Shell

Example Description

  1. Copy the source code for a C language "Hello World" MPI program to any test subdirectory of your home directory:
    cp /bgl/samplecodes/c/hello.c /home/johndoe/tests/c/

  2. cd /home/johndoe/tests/c

    Next, compile and link using either step 3 or step 4:

  3. mpixlc -qsource -o helloc.exe hello.c

  4. export CFLAGS="-qsource"
    export LDFLAGS="-o helloc.exe"
    mpixlc hello.c

    Now, run:

  5. mpirun -np 128 -exe /home/johndoe/helloc.exe

  6. The output is very similar to that for the example on the User Guide page except that your output will be bigger because you used more processors.

Example Description: This example uses the BASH shell and compiles and links using the mpich wrapper mpixlc for the IBM C cross compiler, then runs the resulting executable on 128 NY Blue compute nodes, running one MPI task on each compute node.

mpixlc usage is very similar to non-IBM mpich wrapper usage.

Note that step 4 uses environment variables to set compiler and linker flags. This particular example uses the -qsource compiler flag which will write the source code to the listing file that is produced, you should of course only use that flag if you want that. See Producing Compiler Listings for more information.

Top

Back to User Guide


GNU Cross Compiler Example Using BASH Shell

Example Description

  1. Copy the source code for a C language "Hello World" MPI program to any test subdirectory of your home directory:
    cp /bgl/samplecodes/c/hello.c /home/johndoe/tests/c/

  2. cd /home/johndoe/tests/c

    Next, compile and link using either step 3 or step 4:

  3. mpicc -O2 -o helloc.exe hello.c

  4. export CFLAGS="-O2"
    export LDFLAGS="-o helloc.exe"
    mpicc hello.c

    Now, run:

  5. mpirun -np 128 -exe /home/johndoe/helloc.exe

  6. The output is very similar to that for the example on the User Guide page except that your output will be bigger because you used more processors.

Example Description: This example uses the BASH shell and compiles and links using the mpich wrapper mpicc for the GNU C cross compiler, then runs the resulting executable on 128 NY Blue compute nodes, running one MPI task on each compute node.

mpicc usage is very similar to standard mpich wrapper usage.

Note that step 4 uses environment variables to set compiler and linker flags. This particular example compiles using compiler optimization level 2 (-O2), but the implication is not that you necessarily should or must use -O2. We have randomly chosen this flag simply to illustrate the use of environment variables to set flags.

Top

Back to User Guide


This site maintained by: bgwebmaster@bnl.gov

One of ten national laboratories overseen and primarily funded by the Office of Science of the U.S. Department of Energy (DOE), Brookhaven National Laboratory conducts research in the physical, biomedical, and environmental sciences, as well as in energy technologies and national security. Brookhaven Lab also builds and operates major scientific facilities available to university, industry and government researchers. Brookhaven is operated and managed for DOE's Office of Science by Brookhaven Science Associates, a limited-liability company founded by Stony Brook University, the largest academic user of Laboratory facilities, and Battelle, a nonprofit, applied science and technology organization.
Privacy and Security Notice