Compiling and Running NPB on Linux

Here you can find some help to build your C version of the NAS Parallel Benchmarks on Linux. The results presented here are based on some errors I got when trying to build the project for the first time on a Ubuntu 8.10 computer.
The benchmarks are being build on Linux to guarantee their well functioning, so we can have a well build base to parallelize the NPB with CUDA on Windows Server 2008.

First Steps

After downloading the benchmarks from here and decompressing the files, you will have a directory tree like this:
  • NPB
    • bin
    • bt
    • cg
    • common
    • config
      • NAS.samples
    • Doc
    • ep
    • ft
    • is
    • lu
    • mg
    • sp
    • sys
The compiled programs will be saved in bin. The two letters directories have their respective benchmarks. In common and sys you will find some files used by the different benchmarks. Doc comprises some documentation and config stores the configuration used when compiling the benchmarks.

First Error

The first problem found when trying to make this project involves a silly error. The directories are listed in uppercase in the file named Makefile. To correct that, just change the directories' names. A corrected version can be found on the downloads section.

Classes of problems

For each benchmark, there are 5 classes of problems: S, W, A, B and C. The S class is just a small sample, utilized to test if everything is working. The W class is a bigger problem, used to test workstations. Finally, the last three classes are much bigger instances used to benchmark supercomputers.
When compiling instances of a benchmark, you will have to choose which classes will be compiled. For an example, the file bin/ep.S is a compiled instance of the Embarrassingly Parallel Benchmark to a small size of problem (size 25).


To compile the NPB, you will need a file config/make.def. A template can be found on the same directory. There, you will define the compiler, flags, libraries, etc. To compile a benchmark, you just have to use the command make <name of the benchmark> CLASS=<letter of the chosen class>. Example: make lu CLASS=B.
If you choose to just copy the template and rename it, you will have an error. The template does not include the -lm parameter that has to be passed to the linker (C_LIB). The absence of this parameter makes the linking fail by not finding the math library (pow, sqrt,...).
If you just compile it this way, you will have a sequential version of the benchmarks. To use OpenMP, you should include -fopenmp on both C_FLAGS and C_LIB. Still, the cc compiler is not compatible with OpenMP. I am currently using the gcc-4.3 compiler to correct that.

Compiling Multiple Benchmarks

To compile multiple benchmarks, you can use the command make suite_. For that, you will need a file named config/suite.def. You can find a template on this folder. When describing the instances that you want to compile, you just have to put at each line the name of the benchmark followed by the class. An example can be seeing below:

ft S
ft A
cg B
mg S

These samples (suite.def and make.def) can be found in the download section.

Running the Benchmarks

There is nothing special to be made to run the benchmarks. When using OpenMP, do not forget to set the number of threads that you would like to use with the command export OMP_NUM_THREADS=n, where n is that number.

New Errors

When running the benchmark IS and classes B and C, I get tragic message of segmentation fault. Considering that the IS benchmark is the only one orignaly written in the C language, I've downloaded the NPB3.3. Now this benchmark is working correctly with this instances. I will take a better look at the diferences on both implementations and try to figure out why that happened.

Last edited Apr 23, 2009 at 5:42 PM by Pilla, version 5


No comments yet.