CSE 260 Assignment 2
Due in class on Friday, 10/10/08
TO BE DONE INDIVIDUALLY
(5 points)

The purpose of this assignment is to establish a working platform for running pthreads programs, to and to get you thinking about concurrency and its implications. You may run the program on any machine you wish. If you have questions about compiling or running your program, be sure to post to the A2 conference on the web board.

This assignment must be done individually. The reason for this is to establish that each of you has a working platform for developing your code.

This assignment contains 2 parts involving Pthreads code provided to you. The code you need can be found as two C++ programs:

  • summation.C
  • sum.C
  • New portable versions of these codes have been posted.
  • summation_08_10_06.C
  • sum_08_10_06.C
  • Run experiments with each code, and write a report discussing your results and findings. For each experiment, create a script file using the script command so that your output will be saved to a file:

    script summation.txt
    script sum.txt

    Look over each code, including the comments. Compile using a native C++ compiler, for example with the Gnu C++ compiler (There should be a Gnu g++ compiler on your machine, but use any compiler you wish):

    g++ summation.C -lpthread
    
    Next, perform the following experiments with each code.

    Summation.C

    Does the output verify correctly? Modify the code to enable you to input the number of threads NT and the array size N. Run the program for various values of N and NT

    Experiment with different values of NT, but be sure to run with the following settings:

    1, 4, 7, 16

    If you are on a system that you are sharing with others, use care in running with more than 16 threads.

    Next, comment out the lock invocations so that the global summation computation is no longer serialized. Did anything change? If you note any anomlous behavior, be sure to comment on it and attempt to offer an explanation

    When done with your experiments, close out the script file by typing exit or ^D.

    You will now have a file called summation.txt

    sum.C

    As we discussed in class, this program reports incorrect results. Insert barrier synchronization to fix the bug. Barrier code has been provided for you in the gzipped tar file Barrier.tgz. Be sure to use the InitBarrier routine to initialize the barrier before using it.

    As before, experiment with differing numbers of threads. This time, use the script command to output to the file sum.txt

    Configuration

    When you are finished running the two programs, generate a third script file, config.txt and run the following commands that will produce output describing your operating system, compiler, and the machine you ran the program by running the following commands

    1. Identify the operating system: uname -a
    2. Identify the machine you ran on: hostname
    3. Identify your compiler and version number: g++ -v (If you aren’t using the Gnu C++ compiler, consult the compiler’s documentation to determine the command needed to generate the version information.)
    When done running these commands, close the script file by typing exit or ^D.

    You will now have a file called config.txt

    Things you should turn in

    Submit a lab report containing a discussion of your experiments and the results, together with the three file summation.txt, sum.txt, and config.txt. Do not transmit the assignment electronically.


    Useful on-line material on PThreads

    Tutorial on Threads https://computing.llnl.gov/tutorials/pthreads.

    Exercises https://computing.llnl.gov/tutorials/pthreads/exercise.html.


    Maintained by baden @ ucsd.
    edu   [Thu Oct 2 10:07:12 PDT 2008]