Project 4: A Max-Heap Job Queue

Due: Tuesday, April 23, before 9:00 pm


Addenda


Objectives


Introduction

On High Performance Computing (HPC) clusters, there is typically greater demand for compute resources than can be met at any one time. The job management system maintains a queue of submitted compute jobs and determines which jobs can be run based on policy set by the administrators. For example, a compute job that requires a small number of processors, say 16, and is expected to run for only a few minutes, might be prioritized ahead of a job that requires many processors and hours or days to run. On the other hand, there may be times (e.g. times of lower demand such as nighttime or over school breaks) where the resource-intensive jobs are given priority. Therefore, the job queue must be very flexible and able to support a wide range of prioritization functions.

In this project, you will implement a job queue class (JQueue) based on a max-heap data structure; it will maintain a max-heap based on the computed priority of each job, where the priority function is provided to the JQueue constructor via a function pointer. Inserting to and extracting from the max-heap requires “bubbling up ” or “bubbling down” to maintain the max-heap property; the comparisons that are part of the “bubbling” process will be made on the computed priorities of jobs in the heap. In addition, if the prioritization function is changed, the heap must be rebuilt, which also requires using the appropriate “bubbling” method.

For the purposes of this project, compute jobs have the following attributes (defined in JQueue.h) that can be used by the prioritization function:

A particularly simple prioritization function would be to just use the user-specified priority. However, the function can be much more complicated. The following function is implemented in the sample driver:

  1. Let pri be the computed priority. Initialize pri to the user-specified priority.
  2. If the user id is 7 or 23, add 300 to pri; otherwise, add 100 to pri.
  3. If the group id is 0 or 11, add 200 to pri; otherwise, add 100 to pri.
  4. Subtract the number of processors requested from pri.
  5. Subtract 1/100 of the requested memory size from pri.
  6. Subtract 1/3600 of the requested time from pri.
  7. The computed priority is the integer value of pri.

Assignment

Your assignment is to complete the JQueue class, testing it thoroughly with a variety of job data and prioritization functions. To get started, you are provided with the following files:

First, you must implement the methods of the JQueue class. The methods are described in the requirements section, below. Then, you must write your own, extensive test driver; your test driver should check at least the following properties of your JQueue implementation:


Specifications

Requirement: Private helper functions must be declared in JQueue.h. No other modifications to JQueue.h are permitted!

Requirement: You must use a max-heap data structure to store the job queue. The heap must be ordered according to the prioritization function priority declared in JQueue.h and set by the constructor or setter method. If the prioritization function is changed using the setter method, then the max-heap must be rebuilt using the new prioritization function.

Requirement: Computed priority values may not be pre-computed and stored with the jobs in the queue. They must be computed as needed using the priority function.

Requirement: Insertion to and extraction from the max-heap must run in logarithmic time.

Requirement: You must use the provided operator<< to output job_t objects.


These are the member functions of the JQueue class.


Test Programs

The following program may be used as a basic test of your implementation. Remember, you are required to submit an extensive test program as described above. Additional test programs may be provided at a later date.

These and all the provided project files are available on GL:

/afs/umbc.edu/users/c/m/cmarron/pub/www/cs341.s19/projects/proj4files/


Implementation Notes


What to Submit

You must submit the following files to the proj4 directory.

If you followed the instructions in the Project Submission page to set up your directories, you can submit your code using this Unix command command:

cp JQueue.h JQueue.cpp MyJQTest.cpp ~/cs341proj/proj4/