Showing posts with label C. Show all posts
Showing posts with label C. Show all posts

Mac: Install OPEN MPI on Mac OS

Step 1 : If you haven't installed XCODE. Download and Install XCODE

Step 2 :
Install Open MPI. Download the latest stable release of Open MPI from the Open Source High Performance Computing website.

Step 3:
Open terminal and Go to the downloaded directory

Extract the downloaded archive :
tar -zxvf openmpi-1.6.5.tar.gz

Open terminal and Go to the extracted directory:
cd /path/to/extracted/openmpi-1.6.5

Run the following commands
./configure --prefix=/usr/local
make all
sudo make install

Step 4: Add OpenMPI path to your path, run the following commands export

PATH=/usr/local/openmpi/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/openmpi/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH

Step 5: Compile your C/C++ program
For C:
mpicc -o myProgExe myProg.c

For C++:
mpic++ -o myProgExe myProg.cpp

Step 6: Run, where -np is the number of processor to run on.
mpirun -np 8 myProgExe




Python contextlib for Timing Python code

If you've ever found yourself needing to measure the execution time of specific portions of your Python code, the `contextlib` module o...