Image Compression - Implementation

We code the binary image compression algorithm in pC++ by representing each pixel as an object and the image as a collection of objects distributed on a set a of processors. pC++ provides parallel method invocation that allows the compression function to be invoked in parallel.

We notice that the program newbic runs to completion but often generates images that are too small. So, we set out to investigate the behavior of the program in Ariadne.

The source code is modified by adding user level Ariadne events for Merge and NoMerge. We also trace other element id, level and the element number for each merge. Part of the source code for the bic program is given below.

const int MERGE_EVENT = 3;
class imageElement { // represents a portion of an image
  char myColor;  // WHITE, BLACK, or TREE
  Treeptr myTree;   // if (myColor == TREE), myTree points to structure of tree
  char myStatus; // ACTIVE, WAITING, or DISABLED

#include "kernel.h"

Collection imageCollection : public SuperKernel {
  // represents an entire image, with imageElements
  imageCollection(Distribution *T, Align *A);

  void findWork(int totalLevels);

  virtual char myColor;
  virtual Treeptr myTree;
  virtual char myStatus;

  void getInitialData();

  void merge(int oid, int level);
  void nomerge(int oid, int level);

  void doWork(const int totalLevels);

void imageCollection::merge(int oid, int level)
  pcxx_AriadneRecordUserEvent(MERGE_EVENT, 3, oid, level, index1);
  printf("Elt %d merged elt %d at level %d\n", index1, oid, level);
Three variables (index1- the element id, oid- the element id of the other element participating in the merge, and level- the level at which the merge takes place) are traced along with every MERGE_EVENT. Here, MERGE_EVENT is a constant with the value 3. This causes a trace record to be generated for U_PCXX_user_event3. The function
pcxx_AriadneRecordUserEvent(int event_id, int no_of_vars_traced, char var1, char var2, char var3);
can take upto 16 user events, and can trace three variables that are 8 bytes long each. It is inserted in the source code by the user to trigger a user-level event.