Runs into memory allocation error for test cases of -n16777216. (see ReadMe for argument info)
randomPtr = new Random();
randomPtr.random_alloc(randomPtr);
randomPtr.random_seed(randomPtr, 0);
-
- System.out.println("");
- System.out.println("INFO: ");
- System.out.println("GeneLength: " + geneLength);
- System.out.println("SegmentLength: " + segmentLength);
- System.out.println("MinNumSegment: " + minNumSegment);
- System.out.println("NumThread: " + numThread);
genePtr = new Gene(geneLength);
genePtr.create(randomPtr);
}
Genome(int myThreadid, long myGeneLength, long mySegLength, long myMinNumSegs, long myNumThread, Random myRandomPtr, Gene myGenePtr, Segments mySegmentsPtr, Sequencer mySequencerPtr) {
+// System.out.println("New thread! My id is " + myThreadid + "!");
threadid = myThreadid;
geneLength = myGeneLength;
segmentLength = mySegLength;
}
public void run() {
- while(true) {
Barrier.enterBarrier();
+// System.out.println("*** Thread " + threadid + " about to run ***");
Sequencer.run(threadid, numThread, randomPtr, sequencerPtr);
Barrier.enterBarrier();
- }
}
public static void main(String x[]){
System.out.println("Gene length = " + g.genePtr.length);
System.out.println("Segment length = " + g.segmentsPtr.length);
System.out.println("Number segments = " + g.segmentsPtr.contentsPtr.size());
+ System.out.println("Number threads = " + g.numThread);
Barrier.setBarrier((int)g.numThread);
Genome[] gn = new Genome[g.numThread];
- for(int i = 0; i<g.numThread; i++) {
+ for(int i = 1; i<g.numThread; i++) {
gn[i] = new Genome(i, g.geneLength, g.segmentLength, g.minNumSegment, g.numThread, g.randomPtr, g.genePtr, g.segmentsPtr, g.sequencerPtr);
}
System.out.print("Sequencing gene... ");
+
+// g.start();
- for(int i = 0; i<g.numThread; i++) {
+ for(int i = 1; i<g.numThread; i++) {
gn[i].start();
}
+ Barrier.enterBarrier();
+// System.out.println("*** Thread " + g.threadid + " about to run ***");
+ Sequencer.run(0, g.numThread, g.randomPtr, g.sequencerPtr);
+ Barrier.enterBarrier();
+
+
// fflush(stdout);
/* Check result */
{
String sequence = g.sequencerPtr.sequence;
- System.out.println("gene: " + gene);
- System.out.println("sequence: " + sequence);
boolean result = (gene.compareTo(sequence) == 0) ? true:false;
- System.out.println("result: " + result);
- System.out.println("Sequence matches gene: " + (result ? "no" : "yes"));
+ System.out.println("Sequence matches gene: " + (result ? "yes" : "no"));
if (result) {
- System.out.println("gene = " + gene);
- System.out.println("sequence = " + sequence);
+// System.out.println("gene = " + gene);
+// System.out.println("sequence = " + sequence);
}
// fflush(stdout);
// assert(strlen(sequence) >= strlen(gene));
randomPtr = new Random();
randomPtr.random_alloc(randomPtr);
randomPtr.random_seed(randomPtr, 0);
-
- System.out.println("");
- System.out.println("INFO: ");
- System.out.println("GeneLength: " + geneLength);
- System.out.println("SegmentLength: " + segmentLength);
- System.out.println("MinNumSegment: " + minNumSegment);
- System.out.println("NumThread: " + numThread);
genePtr = new Gene(geneLength);
genePtr.create(randomPtr);
}
Genome(int myThreadid, long myGeneLength, long mySegLength, long myMinNumSegs, long myNumThread, Random myRandomPtr, Gene myGenePtr, Segments mySegmentsPtr, Sequencer mySequencerPtr) {
+// System.out.println("New thread! My id is " + myThreadid + "!");
threadid = myThreadid;
geneLength = myGeneLength;
segmentLength = mySegLength;
}
public void run() {
- while(true) {
Barrier.enterBarrier();
+// System.out.println("*** Thread " + threadid + " about to run ***");
Sequencer.run(threadid, numThread, randomPtr, sequencerPtr);
Barrier.enterBarrier();
- }
}
public static void main(String x[]){
System.out.println("Gene length = " + g.genePtr.length);
System.out.println("Segment length = " + g.segmentsPtr.length);
System.out.println("Number segments = " + g.segmentsPtr.contentsPtr.size());
+ System.out.println("Number threads = " + g.numThread);
Barrier.setBarrier((int)g.numThread);
Genome[] gn = new Genome[g.numThread];
- for(int i = 0; i<g.numThread; i++) {
+ for(int i = 1; i<g.numThread; i++) {
gn[i] = new Genome(i, g.geneLength, g.segmentLength, g.minNumSegment, g.numThread, g.randomPtr, g.genePtr, g.segmentsPtr, g.sequencerPtr);
}
+ System.out.print("Sequencing gene... ");
+// g.start();
- for(int i = 0; i<g.numThread; i++) {
+ for(int i = 1; i<g.numThread; i++) {
gn[i].start();
}
+ Barrier.enterBarrier();
+// System.out.println("*** Thread " + g.threadid + " about to run ***");
+ Sequencer.run(0, g.numThread, g.randomPtr, g.sequencerPtr);
+ Barrier.enterBarrier();
+
+
// fflush(stdout);
/* Benchmark */
- System.out.print("Sequencing gene... ");
+
// fflush(stdout);
// TIMER_READ(start);
// GOTO_SIM();
/* Check result */
{
String sequence = g.sequencerPtr.sequence;
- System.out.println("gene: " + gene);
- System.out.println("sequence: " + sequence);
boolean result = (gene.compareTo(sequence) == 0) ? true:false;
System.out.println("result: " + result);
- System.out.println("Sequence matches gene: " + (result ? "no" : "yes"));
+ System.out.println("Sequence matches gene: " + (result ? "yes" : "no"));
if (result) {
- System.out.println("gene = " + gene);
- System.out.println("sequence = " + sequence);
+// System.out.println("gene = " + gene);
+// System.out.println("sequence = " + sequence);
}
// fflush(stdout);
// assert(strlen(sequence) >= strlen(gene));
+++ /dev/null
-public class List {
-
-private class list_node {
- void* dataPtr;
- struct list_node* nextPtr;
-}
-
-typedef list_node_t* list_iter_t;
-
- list_node_t head;
- long (*compare)(const void*, const void*); /* returns {-1,0,1}, 0 -> equal */
- long size;
-} list_t;
-
-
-/* =============================================================================
- * list_iter_reset
- * =============================================================================
- */
-void
-list_iter_reset (list_iter_t* itPtr, list_t* listPtr);
-
-
-/* =============================================================================
- * TMlist_iter_reset
- * =============================================================================
- */
-TM_CALLABLE
-void
-TMlist_iter_reset (TM_ARGDECL list_iter_t* itPtr, list_t* listPtr);
-
-
-/* =============================================================================
- * list_iter_hasNext
- * =============================================================================
- */
-bool_t
-list_iter_hasNext (list_iter_t* itPtr, list_t* listPtr);
-
-
-/* =============================================================================
- * TMlist_iter_hasNext
- * =============================================================================
- */
-TM_CALLABLE
-bool_t
-TMlist_iter_hasNext (TM_ARGDECL list_iter_t* itPtr, list_t* listPtr);
-
-
-/* =============================================================================
- * list_iter_next
- * =============================================================================
- */
-void*
-list_iter_next (list_iter_t* itPtr, list_t* listPtr);
-
-
-/* =============================================================================
- * TMlist_iter_next
- * =============================================================================
- */
-TM_CALLABLE
-void*
-TMlist_iter_next (TM_ARGDECL list_iter_t* itPtr, list_t* listPtr);
-
-
-/* =============================================================================
- * list_alloc
- * -- If NULL passed for 'compare' function, will compare data pointer addresses
- * -- Returns NULL on failure
- * =============================================================================
- */
-list_t*
-list_alloc (long (*compare)(const void*, const void*));
-
-
-/* =============================================================================
- * Plist_alloc
- * -- If NULL passed for 'compare' function, will compare data pointer addresses
- * -- Returns NULL on failure
- * =============================================================================
- */
-list_t*
-Plist_alloc (long (*compare)(const void*, const void*));
-
-
-/* =============================================================================
- * TMlist_alloc
- * -- If NULL passed for 'compare' function, will compare data pointer addresses
- * -- Returns NULL on failure
- * =============================================================================
- */
-list_t*
-TMlist_alloc (TM_ARGDECL long (*compare)(const void*, const void*));
-
-
-/* =============================================================================
- * list_free
- * =============================================================================
- */
-void
-list_free (list_t* listPtr);
-
-
-/* =============================================================================
- * Plist_free
- * -- If NULL passed for 'compare' function, will compare data pointer addresses
- * -- Returns NULL on failure
- * =============================================================================
- */
-void
-Plist_free (list_t* listPtr);
-
-
-/* =============================================================================
- * TMlist_free
- * -- If NULL passed for 'compare' function, will compare data pointer addresses
- * -- Returns NULL on failure
- * =============================================================================
- */
-void
-TMlist_free (TM_ARGDECL list_t* listPtr);
-
-
-
-/* =============================================================================
- * list_isEmpty
- * -- Return TRUE if list is empty, else FALSE
- * =============================================================================
- */
-bool_t
-list_isEmpty (list_t* listPtr);
-
-
-/* =============================================================================
- * TMlist_isEmpty
- * -- Return TRUE if list is empty, else FALSE
- * =============================================================================
- */
-TM_CALLABLE
-bool_t
-TMlist_isEmpty (TM_ARGDECL list_t* listPtr);
-
-
-/* =============================================================================
- * list_getSize
- * -- Returns size of list
- * =============================================================================
- */
-long
-list_getSize (list_t* listPtr);
-
-
-/* =============================================================================
- * TMlist_getSize
- * -- Returns size of list
- * =============================================================================
- */
-TM_CALLABLE
-long
-TMlist_getSize (TM_ARGDECL list_t* listPtr);
-
-
-/* =============================================================================
- * list_find
- * -- Returns NULL if not found, else returns pointer to data
- * =============================================================================
- */
-void*
-list_find (list_t* listPtr, void* dataPtr);
-
-
-/* =============================================================================
- * TMlist_find
- * -- Returns NULL if not found, else returns pointer to data
- * =============================================================================
- */
-TM_CALLABLE
-void*
-TMlist_find (TM_ARGDECL list_t* listPtr, void* dataPtr);
-
-
-/* =============================================================================
- * list_insert
- * -- Return TRUE on success, else FALSE
- * =============================================================================
- */
-bool_t
-list_insert (list_t* listPtr, void* dataPtr);
-
-
-/* =============================================================================
- * Plist_insert
- * -- Return TRUE on success, else FALSE
- * =============================================================================
- */
-bool_t
-Plist_insert (list_t* listPtr, void* dataPtr);
-
-
-/* =============================================================================
- * TMlist_insert
- * -- Return TRUE on success, else FALSE
- * =============================================================================
- */
-TM_CALLABLE
-bool_t
-TMlist_insert (TM_ARGDECL list_t* listPtr, void* dataPtr);
-
-
-/* =============================================================================
- * list_remove
- * -- Returns TRUE if successful, else FALSE
- * =============================================================================
- */
-bool_t
-list_remove (list_t* listPtr, void* dataPtr);
-
-
-/* =============================================================================
- * Plist_remove
- * -- Returns TRUE if successful, else FALSE
- * =============================================================================
- */
-bool_t
-Plist_remove (list_t* listPtr, void* dataPtr);
-
-
-/* =============================================================================
- * TMlist_remove
- * -- Returns TRUE if successful, else FALSE
- * =============================================================================
- */
-TM_CALLABLE
-bool_t
-TMlist_remove (TM_ARGDECL list_t* listPtr, void* dataPtr);
-
-
-/* =============================================================================
- * list_clear
- * -- Removes all elements
- * =============================================================================
- */
-void
-list_clear (list_t* listPtr);
-
-
-/* =============================================================================
- * Plist_clear
- * -- Removes all elements
- * =============================================================================
- */
-void
-Plist_clear (list_t* listPtr);
-
-}
startBitmapPtr = genePtr.startBitmapPtr;
numStart = geneLength - length + 1;
- System.out.println("minNum: " + minNum);
+// System.out.println("minNum: " + minNum);
/* Pick some random segments to start */
for (i = 0; i < minNum; i++) {
int j = (int)(randomPtr.random_generate(randomPtr) % numStart);
}
}
- System.out.println("gene: " + geneString);
- for(i = 0; i < contentsPtr.size(); i++) {
- System.out.print(" " + contentsPtr.array[i]);
- }
- System.out.println("");
+// System.out.println("gene: " + geneString);
+// for(i = 0; i < contentsPtr.size(); i++) {
+// System.out.print(" " + contentsPtr.array[i]);
+// }
+// System.out.println("");
}
}
for(i = 0; i < contentsPtr.size(); i++) {
System.out.print(" " + contentsPtr.array[i]);
}
- System.out.println();
+ System.out.println("");
}
}
constructEntries = new constructEntry[maxNumUniqueSegment];
for (i= 0; i < maxNumUniqueSegment; i++) {
- constructEntries[i] = new constructEntry(null, true, 0, constructEntries[i], null, constructEntries[i], 0, segmentLength);
+ constructEntries[i] = new constructEntry(null, true, 0, null, null, null, 0, segmentLength);
}
hashToConstructEntryTable = new Table(myGeneLength);
// long threadId = thread_getId();
long threadId = threadNum;
+// System.out.println("threadNum: " + threadId);
Segments segmentsPtr = sequencerPtr.segmentsPtr;
for (ii = i; ii < ii_stop; ii++) {
String segment = (String)segmentsContentsPtr.elementAt((int)ii);
// TMHASHTABLE_INSERT(uniqueSegmentsPtr, segment, segment);
- System.out.print("Placing: " + segment + " into uniqueSegmentsPtr...");
+// System.out.print("Placing: " + segment + " into uniqueSegmentsPtr...");
if(uniqueSegmentsPtr.put(segment, segment) == null) {
- System.out.println("success!");
+// System.out.println("success!");
} else {
- System.out.println("fail, double entry.");
+// System.out.println("fail, double entry.");
}
} /* ii */
}
{
/* Choose disjoint segments [i_start,i_stop) for each thread */
long num = uniqueSegmentsPtr.size();
- System.out.println("num: " + num);
+// System.out.println("num: " + num);
long partitionSize = (num + numThread/2) / numThread; /* with rounding */
i_start = threadId * partitionSize;
if (threadId == (numThread - 1)) {
int ind = 0;
HashMapIterator iterarian = uniqueSegmentsPtr.iterator(1);
String roar;
- System.out.println("uniqueSegmentsPtr contents: ");
+// System.out.println("uniqueSegmentsPtr contents: ");
while(iterarian.hasNext()) {
roar = (String)iterarian.next();
uniqueArray[ind++] = roar;
- System.out.println(" " + roar);
+// System.out.println(" " + roar);
}
i_stop = Math.imin(ind, (int)i_stop);
for (i = i_start; i < i_stop; i++) {
String segment = uniqueArray[(int)i];
- System.out.println("segment[" + i + "]: " + segment);
+// System.out.println("segment[" + i + "]: " + segment);
// list_iter_t it;
// list_iter_reset(&it, chainPtr);
// constructEntryPtr = &constructEntries[entryIndex];
// TM_SHARED_WRITE_P(constructEntryPtr->segment, segment);
constructEntries[(int)entryIndex].segment = segment;
- System.out.println("constructEntries[" + entryIndex + "]: " + constructEntries[(int)entryIndex].segment);
// TM_END();
}
/* constructEntryPtr is local now */
constructEntryPtr.endHash = hashString(segment.substring(1));
- System.out.println("constructEntryPtr.segment: " + constructEntryPtr.segment);
- System.out.println("constructentryPtr.hash: " + constructEntryPtr.endHash);
-
startHash = 0;
for (newj = 1; newj < segmentLength; newj++) {
startHash = segment.charAt((int)newj-1) + (startHash << 6) + (startHash << 16) - startHash;
atomic {
// TM_BEGIN();
// status = TMTABLE_INSERT(startHashToConstructEntryTables[j], (ulong_t)startHash, (void*)constructEntryPtr );
- System.out.println("BEFORE INSERTION INTO TABLE");
- System.out.println("constructEntryPtr.segment: " + constructEntryPtr.segment);
- System.out.println("constructentryPtr.hash: " + constructEntryPtr.endHash);
-
boolean check = startHashToConstructEntryTables[(int)newj].table_insert(startHash, constructEntryPtr);
- System.out.println("check: " + check);
// TM_END();
}
// assert(status);
- System.out.println("AFTER INSERTION INTO TABLE");
- System.out.println("constructEntryPtr.segment: " + constructEntryPtr.segment);
- System.out.println("constructentryPtr.hash: " + constructEntryPtr.endHash);
-
}
- System.out.println("OUTSIDE INTO TABLE");
- System.out.println("constructEntryPtr.segment: " + constructEntryPtr.segment);
- System.out.println("constructentryPtr.hash: " + constructEntryPtr.endHash);
-
-
- int tempi;
- for(tempi = 0; tempi < 4; tempi++) {
- System.out.println("centries[" + tempi + "]: " + constructEntries[tempi].segment);
- }
/*
* For looking up construct entries quickly
int tempi;
for(tempi = 0; tempi < 4; tempi++) {
- System.out.println("centries[" + tempi + "]: " + constructEntries[tempi].segment);
+// System.out.println("constructEntries[" + tempi + "]: " + constructEntries[tempi].segment);
}
- System.out.println("out of for");
-
// thread_barrier_wait();
Barrier.enterBarrier();
LinkedList buckets[] = startHashToConstructEntryTablePtr.buckets;
long numBucket = startHashToConstructEntryTablePtr.numBucket;
- System.out.println("Retrieved the buckets.");
+// System.out.println("Retrieved the buckets.");
long index_start;
long index_stop;
index_stop = Math.imin(ind, (int)index_stop);
- System.out.println("index_start: " + index_start);
- System.out.println("index_stop: " + index_stop);
-
- System.out.println("endSegment: " + constructEntries[(int)index_start].segment);
+// System.out.println("index_start: " + index_start);
+// System.out.println("index_stop: " + index_stop);
/* Iterating over disjoint itervals in the range [0, numUniqueSegment) */
for (entryIndex = index_start;
/* ConstructEntries[entryIndex] is local data */
constructEntry endConstructEntryPtr = constructEntries[(int)entryIndex];
- System.out.println("Retrieved constructEntry[" + entryIndex + "].");
String endSegment = endConstructEntryPtr.segment;
- System.out.println("pyah.");
- System.out.println("endSegment: " + constructEntries[(int)entryIndex].segment);
long endHash = endConstructEntryPtr.endHash;
- System.out.println("endHash: " + endHash);
LinkedList chainPtr = buckets[(int)(endHash % numBucket)]; /* buckets: constant data */
LinkedListIterator it = (LinkedListIterator)chainPtr.iterator();
-// list_iter_reset(&it, chainPtr);
-
- /* Linked list at chainPtr is constant */
while (it.hasNext()) {
-
constructEntry startConstructEntryPtr = (constructEntry)it.next();
String startSegment = startConstructEntryPtr.segment;
+// System.out.println("startSegment: " + startSegment);
long newLength = 0;
/* endConstructEntryPtr is local except for properties startPtr/endPtr/length */
// (strncmp(startSegment,
// &endSegment[segmentLength - substringLength],
// substringLength) == 0))
+// System.out.println("end = " + endSegment);
+// System.out.println("strt= " + startSegment);
+// System.out.println("at " + (segmentLength-substringLength) + " size " + substringLength);
+
+// System.out.println(startSegment.substring(0, (int)substringLength) + ".compareTo(" + endSegment.substring((int)(segmentLength-substringLength)) + ") == 0: " + (startSegment.substring(0, (int)substringLength).compareTo(endSegment.substring((int)(segmentLength-substringLength))) == 0));
+
+// System.out.println("startConstructEntryPtr.isStart: " + startConstructEntryPtr.isStart);
+// System.out.println("endConstructEntryPtr.startPtr != startConstructEntryPtr: " + (endConstructEntryPtr.startPtr != startConstructEntryPtr));
+
if(startConstructEntryPtr.isStart &&
(endConstructEntryPtr.startPtr != startConstructEntryPtr) &&
- (startSegment != endSegment.substring((int)(segmentLength-substringLength), (int)substringLength)))
+ (startSegment.substring(0, (int)substringLength).compareTo(endSegment.substring((int)(segmentLength-substringLength))) == 0))
{
+// System.out.println("Match!");
// TM_SHARED_WRITE(startConstructEntryPtr->isStart, FALSE);
startConstructEntryPtr.isStart = false;
-
+// System.out.println("A");
constructEntry startConstructEntry_endPtr;
constructEntry endConstructEntry_startPtr;
/* Update endInfo (appended something so no longer end) */
// TM_LOCAL_WRITE(endInfoEntries[entryIndex].isEnd, FALSE);
endInfoEntries[(int)entryIndex].isEnd = false;
-
+// System.out.println("B");
/* Update segment chain construct info */
// startConstructEntry_endPtr = (constructEntry_t*)TM_SHARED_READ_P(startConstructEntryPtr->endPtr);
startConstructEntry_endPtr = startConstructEntryPtr.endPtr;
+// System.out.println("C");
// endConstructEntry_startPtr = (constructEntry_t*)TM_SHARED_READ_P(endConstructEntryPtr->startPtr);
endConstructEntry_startPtr = endConstructEntryPtr.startPtr;
-
+// System.out.println("D");
// assert(startConstructEntry_endPtr);
// assert(endConstructEntry_startPtr);
// TM_SHARED_WRITE_P(startConstructEntry_endPtr->startPtr, endConstructEntry_startPtr);
+// if(startConstructEntry_endPtr == null) System.out.println("pwnted");
startConstructEntry_endPtr.startPtr = endConstructEntry_startPtr;
+// System.out.println("E");
// TM_LOCAL_WRITE_P(endConstructEntryPtr->nextPtr, startConstructEntryPtr);
endConstructEntryPtr.nextPtr = startConstructEntryPtr;
+// System.out.println("F");
// TM_SHARED_WRITE_P(endConstructEntry_startPtr->endPtr, startConstructEntry_endPtr);
endConstructEntry_startPtr.endPtr = startConstructEntry_endPtr;
+// System.out.println("G");
// TM_SHARED_WRITE(endConstructEntryPtr->overlap, substringLength);
endConstructEntryPtr.overlap = substringLength;
+// System.out.println("H");
newLength = endConstructEntry_startPtr.length + startConstructEntryPtr.length - substringLength;
// TM_SHARED_WRITE(endConstructEntry_startPtr->length, newLength);
+// System.out.println("I");
endConstructEntry_startPtr.length = newLength;
- } /* if (matched) */
-
+// System.out.println("J");
+ } else {/* if (matched) */
+// System.out.println("Non match.");
+ }
// TM_END();
}
if (!endInfoEntries[(int)entryIndex].isEnd) { /* if there was a match */
+// System.out.println("match means break");
break;
}
} /* iterate over chain */
} /* for (endIndex < numUniqueSegment) */
- System.out.println("out of for2");
+// System.out.println("out of for2");
// thread_barrier_wait();
Barrier.enterBarrier();
* because parallelization did not perform better.
. */
+// System.out.println("Length: " + constructEntries.length);
+
+// int ellemeno;
+// for(ellemeno = 0; ellemeno < constructEntries.length; ellemeno++) {
+// System.out.println("construct[" + ellemeno + "]: " + constructEntries[ellemeno].segment + " isStart: " + constructEntries[ellemeno].isStart + " length: " + constructEntries[ellemeno].length + " overlap: " + constructEntries[ellemeno].overlap);
+// }
+
+
+ // BUGGINZ
+
if (threadId == 0) {
if (substringLength > 1) {
+ //System.out.println("inside bugginz");
long index = segmentLength - substringLength + 1;
/* initialization if j and i: with i being the next end after j=0 */
for (i = 1; !endInfoEntries[(int)i].isEnd; i+=endInfoEntries[(int)i].jumpToNext) {
/* find first non-null */
}
+ //System.out.println("post inner for");
/* entry 0 is handled seperately from the loop below */
endInfoEntries[0].jumpToNext = i;
if (endInfoEntries[0].isEnd) {
String segment = constructEntries[0].segment;
constructEntries[0].endHash = hashString(segment.substring((int)index));
}
+ //System.out.println("post inner if");
/* Continue scanning (do not reset i) */
- for (j = 0; i < numUniqueSegment; i+=endInfoEntries[(int)i].jumpToNext) {
+ for (j = 0; i < ind; i+=endInfoEntries[(int)i].jumpToNext) {
+ //System.out.print("i: " + i + " ");
+ //System.out.print("j: " + j + " ");
+
if (endInfoEntries[(int)i].isEnd) {
+ //System.out.println("isEnd");
String segment = constructEntries[(int)i].segment;
+ //System.out.println("segment[" + i + "]: " + segment);
constructEntries[(int)i].endHash = hashString(segment.substring((int)index));
endInfoEntries[(int)j].jumpToNext = Math.imax((int)1, (int)(i - j));
j = i;
}
+ //System.out.println("done end");
}
endInfoEntries[(int)j].jumpToNext = i - j;
}
}
+ //System.out.println("past threadId0");
// thread_barrier_wait();
Barrier.enterBarrier();
} /* for (substringLength > 0) */
-
+ //System.out.println("Out of for3");
// thread_barrier_wait();
Barrier.enterBarrier();
long totalLength = 0;
- for (i = 0; i < numUniqueSegment; i++) {
+// System.out.println("numUS: " + numUniqueSegment);
+// System.out.println("ind: " + ind);
+ //numUniqueSegment
+ for (i = 0; i < ind; i++) {
if (constructEntries[(int)i].isStart) {
totalLength += constructEntries[(int)i].length;
}
}
+ //System.out.println("totalLength: " + totalLength);
+
String sequence = sequencerPtr.sequence;
String copyPtr = sequence;
long sequenceLength = 0;
- for (i = 0; i < numUniqueSegment; i++) {
+ for (i = 0; i < ind; i++) {
/* If there are several start segments, we append in arbitrary order */
constructEntry constructEntryPtr = constructEntries[(int)i];
+// System.out.println("segment[" + i + "]: " + constructEntryPtr.segment);
if (constructEntryPtr.isStart) {
- long newSequenceLength = sequenceLength + constructEntries[(int)i].length;
+// System.out.println("Start new chain...");
+ long newSequenceLength = sequenceLength + constructEntryPtr.length;
+ long prevOverlap = 0;
// assert( newSequenceLength <= totalLength );
- copyPtr = sequence + sequenceLength;
- sequenceLength = newSequenceLength;
+// copyPtr = sequence + sequenceLength;
+// sequenceLength = newSequenceLength;
do {
- long numChar = segmentLength - constructEntries[(int)i].overlap;
+ long numChar = segmentLength - constructEntryPtr.overlap;
// if ((copyPtr + numChar) > (sequence + newSequenceLength)) {
// System.out.print("ERROR: sequence length != actual length\n");
// break;
// }
- copyPtr = constructEntries[(int)i].segment;
- copyPtr += numChar;
+ copyPtr = constructEntryPtr.segment;
+// System.out.println("copyPtr: " + constructEntryPtr.segment);
+// System.out.println("overlap: " + prevOverlap); // OVERLAP MAKESS NOOOO SEEEENNSEEEE
+// System.out.println("length: " + constructEntryPtr.length);
+// System.out.println("numChar: " + numChar);
+ if(sequencerPtr.sequence == null) {
+// System.out.println("nulled");
+ sequencerPtr.sequence = copyPtr;
+ } else {
+// System.out.println("not null, concat");
+ sequencerPtr.sequence = sequencerPtr.sequence.concat(copyPtr.substring((int)(prevOverlap)));
+ }
+// System.out.println("sequence: " + sequencerPtr.sequence);
+ prevOverlap = constructEntryPtr.overlap;
constructEntryPtr = constructEntryPtr.nextPtr;
} while (constructEntryPtr != null);
// assert(copyPtr <= (sequence + sequenceLength));
// assert(sequence != NULL);
}
+
+// System.out.println("Natural run finish.");
// TM_THREAD_EXIT();
char c = str.charAt(index);
hash = c + (hash << 6) + (hash << 16) - hash;
}
+
+ if(hash < 0) hash *= -1;
return hash;
}
constructEntries = new constructEntry[maxNumUniqueSegment];
for (i= 0; i < maxNumUniqueSegment; i++) {
- constructEntries[i] = new constructEntry(null, true, 0, constructEntries[i], null, constructEntries[i], 0, segmentLength);
+ constructEntries[i] = new constructEntry(null, true, 0, null, null, null, 0, segmentLength);
}
hashToConstructEntryTable = new Table(myGeneLength);
// long threadId = thread_getId();
long threadId = threadNum;
+// System.out.println("threadNum: " + threadId);
Segments segmentsPtr = sequencerPtr.segmentsPtr;
for (ii = i; ii < ii_stop; ii++) {
String segment = (String)segmentsContentsPtr.elementAt((int)ii);
// TMHASHTABLE_INSERT(uniqueSegmentsPtr, segment, segment);
- System.out.print("Placing: " + segment + " into uniqueSegmentsPtr...");
+// System.out.print("Placing: " + segment + " into uniqueSegmentsPtr...");
if(uniqueSegmentsPtr.put(segment, segment) == null) {
- System.out.println("success!");
+// System.out.println("success!");
} else {
- System.out.println("fail, double entry.");
+// System.out.println("fail, double entry.");
}
} /* ii */
}
{
/* Choose disjoint segments [i_start,i_stop) for each thread */
long num = uniqueSegmentsPtr.size();
- System.out.println("num: " + num);
+// System.out.println("num: " + num);
long partitionSize = (num + numThread/2) / numThread; /* with rounding */
i_start = threadId * partitionSize;
if (threadId == (numThread - 1)) {
int ind = 0;
HashMapIterator iterarian = uniqueSegmentsPtr.iterator(1);
String roar;
- System.out.println("uniqueSegmentsPtr contents: ");
+// System.out.println("uniqueSegmentsPtr contents: ");
while(iterarian.hasNext()) {
roar = (String)iterarian.next();
uniqueArray[ind++] = roar;
for (i = i_start; i < i_stop; i++) {
String segment = uniqueArray[(int)i];
- System.out.println("segment[" + i + "]: " + segment);
+// System.out.println("segment[" + i + "]: " + segment);
// list_iter_t it;
// list_iter_reset(&it, chainPtr);
// constructEntryPtr = &constructEntries[entryIndex];
// TM_SHARED_WRITE_P(constructEntryPtr->segment, segment);
constructEntries[(int)entryIndex].segment = segment;
- System.out.println("constructEntries[" + entryIndex + "]: " + constructEntries[(int)entryIndex].segment);
// TM_END();
}
/* constructEntryPtr is local now */
constructEntryPtr.endHash = hashString(segment.substring(1));
- System.out.println("constructEntryPtr.segment: " + constructEntryPtr.segment);
- System.out.println("constructentryPtr.hash: " + constructEntryPtr.endHash);
-
startHash = 0;
for (newj = 1; newj < segmentLength; newj++) {
startHash = segment.charAt((int)newj-1) + (startHash << 6) + (startHash << 16) - startHash;
atomic {
// TM_BEGIN();
// status = TMTABLE_INSERT(startHashToConstructEntryTables[j], (ulong_t)startHash, (void*)constructEntryPtr );
- System.out.println("BEFORE INSERTION INTO TABLE");
- System.out.println("constructEntryPtr.segment: " + constructEntryPtr.segment);
- System.out.println("constructentryPtr.hash: " + constructEntryPtr.endHash);
-
boolean check = startHashToConstructEntryTables[(int)newj].table_insert(startHash, constructEntryPtr);
- System.out.println("check: " + check);
// TM_END();
}
// assert(status);
- }
- System.out.println("AFTER INSERTION INTO TABLE");
- System.out.println("constructEntryPtr.segment: " + constructEntryPtr.segment);
- System.out.println("constructentryPtr.hash: " + constructEntryPtr.endHash);
-
-
- int tempi;
- for(tempi = 0; tempi < 4; tempi++) {
- System.out.println("centries[" + tempi + "]: " + constructEntries[tempi].segment);
}
+
/*
* For looking up construct entries quickly
*/
int tempi;
for(tempi = 0; tempi < 4; tempi++) {
- System.out.println("centries[" + tempi + "]: " + constructEntries[tempi].segment);
+// System.out.println("constructEntries[" + tempi + "]: " + constructEntries[tempi].segment);
}
- System.out.println("out of for");
-
// thread_barrier_wait();
Barrier.enterBarrier();
LinkedList buckets[] = startHashToConstructEntryTablePtr.buckets;
long numBucket = startHashToConstructEntryTablePtr.numBucket;
- System.out.println("Retrieved the buckets.");
+// System.out.println("Retrieved the buckets.");
long index_start;
long index_stop;
index_stop = Math.imin(ind, (int)index_stop);
- System.out.println("index_start: " + index_start);
- System.out.println("index_stop: " + index_stop);
-
- System.out.println("endSegment: " + constructEntries[(int)index_start].segment);
+// System.out.println("index_start: " + index_start);
+// System.out.println("index_stop: " + index_stop);
/* Iterating over disjoint itervals in the range [0, numUniqueSegment) */
for (entryIndex = index_start;
/* ConstructEntries[entryIndex] is local data */
constructEntry endConstructEntryPtr = constructEntries[(int)entryIndex];
- System.out.println("Retrieved constructEntry[" + entryIndex + "].");
String endSegment = endConstructEntryPtr.segment;
- System.out.println("pyah.");
- System.out.println("endSegment: " + constructEntries[(int)entryIndex].segment);
long endHash = endConstructEntryPtr.endHash;
- System.out.println("endHash: " + endHash);
LinkedList chainPtr = buckets[(int)(endHash % numBucket)]; /* buckets: constant data */
LinkedListIterator it = (LinkedListIterator)chainPtr.iterator();
-// list_iter_reset(&it, chainPtr);
-
- /* Linked list at chainPtr is constant */
while (it.hasNext()) {
-
constructEntry startConstructEntryPtr = (constructEntry)it.next();
String startSegment = startConstructEntryPtr.segment;
+// System.out.println("startSegment: " + startSegment);
long newLength = 0;
/* endConstructEntryPtr is local except for properties startPtr/endPtr/length */
// (strncmp(startSegment,
// &endSegment[segmentLength - substringLength],
// substringLength) == 0))
+// System.out.println("end = " + endSegment);
+// System.out.println("strt= " + startSegment);
+// System.out.println("at " + (segmentLength-substringLength) + " size " + substringLength);
+
+// System.out.println(startSegment.substring(0, (int)substringLength) + ".compareTo(" + endSegment.substring((int)(segmentLength-substringLength)) + ") == 0: " + (startSegment.substring(0, (int)substringLength).compareTo(endSegment.substring((int)(segmentLength-substringLength))) == 0));
+
+// System.out.println("startConstructEntryPtr.isStart: " + startConstructEntryPtr.isStart);
+// System.out.println("endConstructEntryPtr.startPtr != startConstructEntryPtr: " + (endConstructEntryPtr.startPtr != startConstructEntryPtr));
+
if(startConstructEntryPtr.isStart &&
(endConstructEntryPtr.startPtr != startConstructEntryPtr) &&
- (startSegment != endSegment.substring((int)(segmentLength-substringLength), (int)substringLength)))
+ (startSegment.substring(0, (int)substringLength).compareTo(endSegment.substring((int)(segmentLength-substringLength))) == 0))
{
+// System.out.println("Match!");
// TM_SHARED_WRITE(startConstructEntryPtr->isStart, FALSE);
startConstructEntryPtr.isStart = false;
-
+// System.out.println("A");
constructEntry startConstructEntry_endPtr;
constructEntry endConstructEntry_startPtr;
/* Update endInfo (appended something so no longer end) */
// TM_LOCAL_WRITE(endInfoEntries[entryIndex].isEnd, FALSE);
endInfoEntries[(int)entryIndex].isEnd = false;
-
+// System.out.println("B");
/* Update segment chain construct info */
// startConstructEntry_endPtr = (constructEntry_t*)TM_SHARED_READ_P(startConstructEntryPtr->endPtr);
startConstructEntry_endPtr = startConstructEntryPtr.endPtr;
+// System.out.println("C");
// endConstructEntry_startPtr = (constructEntry_t*)TM_SHARED_READ_P(endConstructEntryPtr->startPtr);
endConstructEntry_startPtr = endConstructEntryPtr.startPtr;
-
+// System.out.println("D");
// assert(startConstructEntry_endPtr);
// assert(endConstructEntry_startPtr);
// TM_SHARED_WRITE_P(startConstructEntry_endPtr->startPtr, endConstructEntry_startPtr);
+// if(startConstructEntry_endPtr == null) System.out.println("pwnted");
startConstructEntry_endPtr.startPtr = endConstructEntry_startPtr;
+// System.out.println("E");
// TM_LOCAL_WRITE_P(endConstructEntryPtr->nextPtr, startConstructEntryPtr);
endConstructEntryPtr.nextPtr = startConstructEntryPtr;
+// System.out.println("F");
// TM_SHARED_WRITE_P(endConstructEntry_startPtr->endPtr, startConstructEntry_endPtr);
endConstructEntry_startPtr.endPtr = startConstructEntry_endPtr;
+// System.out.println("G");
// TM_SHARED_WRITE(endConstructEntryPtr->overlap, substringLength);
endConstructEntryPtr.overlap = substringLength;
+// System.out.println("H");
newLength = endConstructEntry_startPtr.length + startConstructEntryPtr.length - substringLength;
// TM_SHARED_WRITE(endConstructEntry_startPtr->length, newLength);
+// System.out.println("I");
endConstructEntry_startPtr.length = newLength;
- } /* if (matched) */
-
+// System.out.println("J");
+ } else {/* if (matched) */
+// System.out.println("Non match.");
+ }
// TM_END();
}
if (!endInfoEntries[(int)entryIndex].isEnd) { /* if there was a match */
+// System.out.println("match means break");
break;
}
} /* iterate over chain */
} /* for (endIndex < numUniqueSegment) */
- System.out.println("out of for2");
+// System.out.println("out of for2");
// thread_barrier_wait();
Barrier.enterBarrier();
* because parallelization did not perform better.
. */
+// System.out.println("Length: " + constructEntries.length);
+
+// int ellemeno;
+// for(ellemeno = 0; ellemeno < constructEntries.length; ellemeno++) {
+// System.out.println("construct[" + ellemeno + "]: " + constructEntries[ellemeno].segment + " isStart: " + constructEntries[ellemeno].isStart + " length: " + constructEntries[ellemeno].length + " overlap: " + constructEntries[ellemeno].overlap);
+// }
+
+
+ // BUGGINZ
+
if (threadId == 0) {
if (substringLength > 1) {
+ //System.out.println("inside bugginz");
long index = segmentLength - substringLength + 1;
/* initialization if j and i: with i being the next end after j=0 */
for (i = 1; !endInfoEntries[(int)i].isEnd; i+=endInfoEntries[(int)i].jumpToNext) {
/* find first non-null */
}
+ //System.out.println("post inner for");
/* entry 0 is handled seperately from the loop below */
endInfoEntries[0].jumpToNext = i;
if (endInfoEntries[0].isEnd) {
String segment = constructEntries[0].segment;
constructEntries[0].endHash = hashString(segment.substring((int)index));
}
+ //System.out.println("post inner if");
/* Continue scanning (do not reset i) */
- for (j = 0; i < numUniqueSegment; i+=endInfoEntries[(int)i].jumpToNext) {
+ for (j = 0; i < ind; i+=endInfoEntries[(int)i].jumpToNext) {
+ //System.out.print("i: " + i + " ");
+ //System.out.print("j: " + j + " ");
+
if (endInfoEntries[(int)i].isEnd) {
+ //System.out.println("isEnd");
String segment = constructEntries[(int)i].segment;
+ //System.out.println("segment[" + i + "]: " + segment);
constructEntries[(int)i].endHash = hashString(segment.substring((int)index));
endInfoEntries[(int)j].jumpToNext = Math.imax((int)1, (int)(i - j));
j = i;
}
+ //System.out.println("done end");
}
endInfoEntries[(int)j].jumpToNext = i - j;
}
}
+ //System.out.println("past threadId0");
// thread_barrier_wait();
Barrier.enterBarrier();
} /* for (substringLength > 0) */
-
+ //System.out.println("Out of for3");
// thread_barrier_wait();
Barrier.enterBarrier();
long totalLength = 0;
- for (i = 0; i < numUniqueSegment; i++) {
+// System.out.println("numUS: " + numUniqueSegment);
+// System.out.println("ind: " + ind);
+ //numUniqueSegment
+ for (i = 0; i < ind; i++) {
if (constructEntries[(int)i].isStart) {
totalLength += constructEntries[(int)i].length;
}
}
+ //System.out.println("totalLength: " + totalLength);
+
String sequence = sequencerPtr.sequence;
String copyPtr = sequence;
long sequenceLength = 0;
- for (i = 0; i < numUniqueSegment; i++) {
+ for (i = 0; i < ind; i++) {
/* If there are several start segments, we append in arbitrary order */
constructEntry constructEntryPtr = constructEntries[(int)i];
+// System.out.println("segment[" + i + "]: " + constructEntryPtr.segment);
if (constructEntryPtr.isStart) {
- long newSequenceLength = sequenceLength + constructEntries[(int)i].length;
+// System.out.println("Start new chain...");
+ long newSequenceLength = sequenceLength + constructEntryPtr.length;
+ long prevOverlap = 0;
// assert( newSequenceLength <= totalLength );
- copyPtr = sequence + sequenceLength;
- sequenceLength = newSequenceLength;
+// copyPtr = sequence + sequenceLength;
+// sequenceLength = newSequenceLength;
do {
- long numChar = segmentLength - constructEntries[(int)i].overlap;
+ long numChar = segmentLength - constructEntryPtr.overlap;
// if ((copyPtr + numChar) > (sequence + newSequenceLength)) {
// System.out.print("ERROR: sequence length != actual length\n");
// break;
// }
- copyPtr = constructEntries[(int)i].segment;
- copyPtr += numChar;
+ copyPtr = constructEntryPtr.segment;
+// System.out.println("copyPtr: " + constructEntryPtr.segment);
+// System.out.println("overlap: " + prevOverlap); // OVERLAP MAKESS NOOOO SEEEENNSEEEE
+// System.out.println("length: " + constructEntryPtr.length);
+// System.out.println("numChar: " + numChar);
+ if(sequencerPtr.sequence == null) {
+// System.out.println("nulled");
+ sequencerPtr.sequence = copyPtr;
+ } else {
+// System.out.println("not null, concat");
+ sequencerPtr.sequence = sequencerPtr.sequence.concat(copyPtr.substring((int)(prevOverlap)));
+ }
+// System.out.println("sequence: " + sequencerPtr.sequence);
+ prevOverlap = constructEntryPtr.overlap;
constructEntryPtr = constructEntryPtr.nextPtr;
} while (constructEntryPtr != null);
// assert(copyPtr <= (sequence + sequenceLength));
// assert(sequence != NULL);
}
+
+// System.out.println("Natural run finish.");
// TM_THREAD_EXIT();
char c = str.charAt(index);
hash = c + (hash << 6) + (hash << 16) - hash;
}
+
+ if(hash < 0) hash *= -1;
return hash;
}
* =============================================================================
*/
boolean table_insert (long hash, Object dataPtr) {
- System.out.println("Inside insert- hash: " + hash);
- System.out.println("Inside insert- dataPtr: " + ((constructEntry)(dataPtr)).segment);
int i = (int)(hash % numBucket);
+ if(i < 0) i *= -1;
if(buckets[i].contains(dataPtr)) {
return false;
}
* =============================================================================
*/
boolean table_insert (long hash, Object dataPtr) {
- System.out.println("Inside insert- hash: " + hash);
- System.out.println("Inside insert- dataPtr: " + dataPtr);
int i = (int)(hash % numBucket);
if(buckets[i].contains(dataPtr)) {
return false;
--- /dev/null
+public class constructEntry {
+ boolean isStart;
+ String segment;
+ long endHash;
+ constructEntry startPtr;
+ constructEntry nextPtr;
+ constructEntry endPtr;
+ long overlap;
+ long length;
+
+ constructEntry(String mySegment, boolean myStart, long myEndHash, constructEntry myStartPtr, constructEntry myNextPtr, constructEntry myEndPtr, long myOverlap, long myLength) {
+ segment = mySegment;
+ isStart = myStart;
+ endHash = myEndHash;
+ startPtr = this;
+ nextPtr = myNextPtr;
+ endPtr = this;
+ overlap = myOverlap;
+ length = myLength;
+ }
+
+ boolean equals(constructEntry copy) {
+ return ((segment == copy.segment) && (isStart == copy.isStart) && (endHash == copy.endHash) && (startPtr == copy.startPtr) && (nextPtr == copy.nextPtr) && (endPtr == copy.endPtr) && (overlap == copy.overlap) && (length == copy.length));
+ }
+}
--- /dev/null
+ public class endInfoEntry {
+ boolean isEnd;
+ long jumpToNext;
+
+ public endInfoEntry() {
+ isEnd = false;
+ jumpToNext = 0;
+ }
+ public endInfoEntry(boolean myEnd, long myNext) {
+ isEnd = myEnd;
+ jumpToNext = myNext;
+ }
+ }
--- /dev/null
+MAINCLASS=Genome
+SRC=${MAINCLASS}.java \
+ Random.java \
+ Bitmap.java \
+ Gene.java \
+ Segments.java \
+ endInfoEntry.java \
+ constructEntry.java \
+ ../../../../ClassLibrary/JavaSTM/Barrier.java \
+ Sequencer.java
+FLAGS=-mainclass ${MAINCLASS} -singleTM -nooptimize -debug -dcopts -joptimize
+
+default:
+ ../../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC}
+
+clean:
+ rm -rf tmpbuilddirectory
+ rm *.bin