Unformatted text preview:

COSC 6374 Parallel Computation 1st homework assignment Edgar Gabriel Fall 2011 Edgar Gabriel 1st Homework Rules Each team should deliver Source code c file Documentation pdf doc tex or txt file explanations to the code answers to questions Deliver electronically to gabriel cs uh edu Expected by Friday October 7 11 59pm In case of questions ask ask ask Parallel Computation Edgar Gabriel 1 Given the sequential code for an image processing algorithm which performs a k means clustering operation on an image 1 Parallelize the algorithm using MPI using a 1 D block row wise data distribution each process holds the same number of rows of the image need to add timing functions into the code as well 2 Measure the execution time for the k means clustering for 1 2 4 and 8 processors for the 1024x1024 and 2048x2048 pixel image provided 1024 featurevec out and 2048 featurevec out no performance data required for the 512x512 pixel image its only there fore development purposes 3 Determine the parallel speedup and the parallel efficiency of the code sequence on the shark cluster for the 2 4 and 8 processor cases Parallel Computation Edgar Gabriel Code consists of three parts reading input image suggestion for parallelization provided later perform k means clustering your work write output image suggestion for parallelization provided later Small input file 512 featurevec out available on the course webpage Large input files for measurement 1024 featurevec out and 2048 featurevec out will be available in the directory pvfs2 cosc6374 f11 on the shark cluster later next week Parallel Computation Edgar Gabriel 2 K means clustering sequential version Input I i1 ik Instances to be clustered n Number of clusters Output C c1 cn cluster centroids m I C cluster membership Algorithm Set C to initial value while m has changed ctemp k 0 k 1 n count k 0 k 1 n for each i I m ij min distance ij ck k 1 n ctemp k i countk end recompute C based on ctemp and count Parallel Computation Edgar Gabriel how to compile the code for measurements gcc o clustering clustering c O3 how to compile the code for debugging gcc o clustering clustering c g O0 how to run the sequential code clustering 1024 featurevec out outlabel 1024 out 1024 1024 Parallel Computation Edgar Gabriel 3 Multispectral images Image data contains multiple spectral channels Number of spectral channels in the file 24 Storage order Pixel i j has first the data for channel1 then channel 2 channel 3 etc Each data item is a double precision floating point number Parallel Computation Edgar Gabriel How to read a portion of a matrix Determine the number of rows a process has to read e g localnrows height no of processes used Allocate buffersizes accordingly fpa fopen infile1 rb fseek fpa localnrows width sizeof double rank NUM CHANNELS SEEK SET fread data 0 0 0 sizeof double localnrows width NUM CHANNELS fpa fclose fpa Parallel Computation Edgar Gabriel 4 How to write a portion of the matrix for i 0 i size i if rank i fpa fopen outfile ab fwrite labels 0 0 sizeof int localnrows width fpa fclose fpa MPI Barrier MPI COMM WORLD Synchronization between the processes required to ensure that process i 1 has written the data before process i Parallel Computation Edgar Gabriel Documentation The Documentation should contain Brief Problem description Solution strategy Results section Description of resources used Description of measurements performed Results graphs findings Parallel Computation Edgar Gabriel 5 The document should not contain Replication of the entire source code that s why you have to deliver the sources Screen shots of every single measurement you made Actually no screen shots at all The slurm output files Parallel Computation Edgar Gabriel How to use a cluster A cluster usually consists of a front end node and compute nodes You can login to the front end node using ssh from windows or linux machines using the login name and the password assigned to you The front end node is supposed to be there for editing and compiling not for running jobs If 45 students would run their jobs on the same processor everything would stall To allocate a node for interactive development teamxy shark salloc n 4 bash teamxy shark squeue JOBID PARTITION NAME USER ST TIME NODES NODELIST REASON 489 calc smith R 0 02 2 teamxy shark mpirun np 4 mytest shark 08 09 Parallel Computation Edgar Gabriel 6 How to use a cluster II Note the mpirun command will know where to execute the job only if you type the command from the very same terminal window where you typed the salloc command Maximum time an allocation will be available to you 30 minutes after that time your job gets automatically killed by the system fairness rule Note that when you request e g 8 processors you might receive either 4 nodes with 2 cores shark01 20 or 1 nodes with 8 cores shark25 29 Parallel Computation Edgar Gabriel Once your code is correct and you would like to do the measurements You have to submit a batch job The command you need is sbatch e g sbatch n 8 measurements sh Your job goes into a queue and will be executed as soon as a node is available You can check the status of your job with squeue Parallel Computation Edgar Gabriel 7 How to use a cluster III The output of squeue gives you a job id for your job Once your job finishes you will have a file called slurm jobid out in your home directory which contains all the output of your printf statements etc Note the batch script used for the job submission e g measurements sh has to be executable This means that after you downloaded it from the webpage and copied it to shark you have to type chmod x measurements sh Please do not edit the measurements sh file on MS Windows Windows does not add the UNIX EOL markers and this confuses slurm when reading the file Parallel Computation Edgar Gabriel Notes If you need hints on how to use a UNIX Linux machine through ssh http www cs uh edu gabriel cosc4397 s06 ParCo 08 IntroductionUNIX pdf How to use a cluster such as shark http pstl cs uh edu resources html Parallel Computation Edgar Gabriel 8


View Full Document

UH COSC 6374 - COSC 6374 1st homework assignment

Documents in this Course
Load more
Loading Unlocking...
Login

Join to view COSC 6374 1st homework assignment and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view COSC 6374 1st homework assignment and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?