1. Example:
------------------------------------------------------
#include<iostream>
#include<iomanip>
#include<ctime>
using namespace std;
int main()
{
double sum=0;
double w =0;
double startime,endtime;
startime = clock();
int nsim =1.234e6;
//#pragma omp parallel for private(w) reduction(+:sum) schedule(static,1)
#pragma omp parallel for
for(int i = 0; i <=nsim; i++)
{
w = i*i;
sum = sum + w;
}
endtime = clock();
cout<<"sum="<< setprecision(5)<<sum<<endl;
cout<<"time pass "<<(endtime - startime)/CLOCKS_PER_SEC<<"second"<<endl;
return(0);
}
---------------------------------------
2. Makefile in glacier.westgrid.ca
--------------------------------------
CC = icpc
CFLAGS = -g -O3 -openmp
OBJECTS = *cpp
main.exe : $(OBJECTS)
$(CC) $(CFLAGS) $(OBJECTS) -o main.exe
%.o : %.c
$(CC) $(CFLAGS) -c $<
----------------------------------------------
3. submit to the queue:
-------------------------------------
#!/bin/bash
#PBS -S /bin/bash
#PBS -l nodes=1:ppn=2
#PBS -l mem=2000mb
#PBS -l walltime=120:00:00
#PBS -M jiansen@triumf.ca
# Script for running OpenMP sample program main.exe on 2 processors on glacier
# If this file is "run_main.pbs", submit with "qsub run_main.pbs"
# Check on some basics:
echo "Running on host: " `hostname`
echo "Changing to directory from which PBS script was submitted."
cd $PBS_O_WORKDIR
echo "Current working directory is now: " `pwd`
# Note: The OMP_NUM_THREADS should match the number of processors requested.
echo "Node file: $PBS_NODEFILE :"
echo "---------------------"
cat $PBS_NODEFILE
echo "---------------------"
echo "JOb name: $PBS_JOBNAME"
NUM_PROCS=`/bin/awk 'END {print NR}' $PBS_NODEFILE`
echo "Running on $NUM_PROCS processors."
echo "Starting main.exe at `date`"
main.exe > run-main-pbs.out$PBS_JOBID
echo "main.exe run completed at `date`"
Online computer courses, code, programming tutorial and sidebar information for monitoring Canadian S&P/TSX index. Build friendship and networking. Welcome to visit my blogs often!!! I also have two other sites: YouTube Channel and Google site.
Adsense
Popular Posts
- PHPWind-- A PHP forum script applcaition in China
- How to blend adsense inside your post?
- Formatting my post
- Install PHPMailer 5.2.4 and use smtp gmail
- Datatable export excel wraptext and newline
- phpexcel toggle expand and hide column in EXCEL and summary
- Linux, automatically backup MySQL database daily
- SPSS job interview questions
- Notepad++ - Add C++ compiler
- Install PHP ibm_db2 extension in Linux (redHat)
Tuesday, June 29, 2010
openmp in westgrid
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment