mpicc - Compiles and links MPI programs written in C
This shell script is used to compile and link MPI programs written in C. It performs necessary pre-processing and linking of external libraries in order to create a working MPI program. Do not use a normal C compiler to compile MPI code as this needed extra processing will be missing.
The shell script adds a few extra options to the command line passed to the compiler. The most important of these are -fpic and -pie, which turn on position-independent code generation. This implementation of MPI loads multiple copies of the program within the same address space. In order for this to work, each copy needs to exist at a different address.
The other options to the compiler turn on threading support, and make sure that the MPI library can hook calls to pthread_create(). The extra hooking is needed so that threads can safely call function pointers referencing code in other programs within the same address space. MPI uses the %gs segment register to maintain references to thread-local variables as %fs-based references will be at differing offsets.
Finally, the shell script includes the argument that links with the MPI library. If you install the library in a non-default location, you may want to alter the LIB variable.
If you use a compiler other than gcc, edit the CC variable. You will want to alter the arguments to produce the same effects as those used for gcc.
COMMAND LINE ARGUMENTS
The shell script expects the normal arguments passed to the C compiler. All arguments are passed through directly to the C compiler with no alteration.
To compile a single file foo.c, use:
To make an executable, use:
Compilation and linking can be combined i.e. with two source files foo1.c and foo2.c
Copyright (C) 2012 Lockless Inc.
Company Info |
Product Index |
Category Index |
Copyright © Lockless Inc All Rights Reserved.