| 1 | #cxx . . $ `<file>/seatac/thr-search.C`/include "seatac.H"cxx . . $ `<file>/seatac/seatac.H`/ |
| 2 | |
| 3 | char const *srchGbyecxx . . $ srchGbye. = "[%ld] computed: "uint64FMTWcxx . . $ `libutil/util.h:54:10`!(8)" blocked: "uint64FMTWcxx . . $ `libutil/util.h:54:10`!(4)"/"uint64FMTWcxx . . $ `libutil/util.h:54:10`!(4)" encodeTime: %7.2f searchTime: %7.2f processTime: %7.2f\n"; |
| 4 | |
| 5 | class searcherStatecxx . . $ searcherState# { |
| 6 | public: |
| 7 | uint64cxx . . $ uint64# posnMaxcxx . . $ searcherState#posnMax.; |
| 8 | uint64cxx . . $ uint64# posnLencxx . . $ searcherState#posnLen.; |
| 9 | uint64cxx . . $ uint64# *posncxx . . $ searcherState#posn.; |
| 10 | |
| 11 | double encodeTimecxx . . $ searcherState#encodeTime.; |
| 12 | double maskTimecxx . . $ searcherState#maskTime.; |
| 13 | double searchTimecxx . . $ searcherState#searchTime.; |
| 14 | double processTimecxx . . $ searcherState#processTime.; |
| 15 | |
| 16 | searcherStatecxx . . $ searcherState#searcherState(49f6e7a06ebc5aa8).() { |
| 17 | posnMaxcxx . . $ searcherState#posnMax. = 16384; |
| 18 | posnLencxx . . $ searcherState#posnLen. = 0; |
| 19 | posncxx . . $ searcherState#posn. = new uint64cxx . . $ uint64# [ posnMaxcxx . . $ searcherState#posnMax. ]; |
| 20 | |
| 21 | encodeTimecxx . . $ searcherState#encodeTime. = 0.0; |
| 22 | maskTimecxx . . $ searcherState#maskTime. = 0.0; |
| 23 | searchTimecxx . . $ searcherState#searchTime. = 0.0; |
| 24 | processTimecxx . . $ searcherState#processTime. = 0.0; |
| 25 | }; |
| 26 | |
| 27 | ~cxx . . $ searcherState#`~searcherState`(ced63f7c635d850d).searcherStatecxx . . $ searcherState#() { |
| 28 | delete [] posncxx . . $ searcherState#posn.; |
| 29 | }; |
| 30 | }; |
| 31 | |
| 32 | |
| 33 | void |
| 34 | doSearchcxx . . $ doSearch(517d947672db2af1).(searcherStatecxx . . $ searcherState# *state, |
| 35 | seqInCorecxx . . $ seqInCore# *seq, |
| 36 | uint32cxx . . $ uint32# idx, |
| 37 | bool rc, |
| 38 | filterObjcxx . . $ filterObj# *FO) { |
| 39 | encodedQuerycxx . . $ encodedQuery# *query = 0L; |
| 40 | hitMatrixcxx . . $ hitMatrix# *matrix = 0L; |
| 41 | double startTime = 0.0; |
| 42 | uint64cxx . . $ uint64# mer = uint64ZEROcxx . . $ `libutil/util.h:50:10`!; |
| 43 | uint32cxx . . $ uint32# pos = uint32ZEROcxx . . $ `libutil/util.h:60:10`!; |
| 44 | uint64cxx . . $ uint64# count = 0; |
| 45 | |
| 46 | // Build and mask the query |
| 47 | // |
| 48 | startTime = getTime(); |
| 49 | query = new encodedQuerycxx . . $ encodedQuery#(seq->sequencecxx . . $ seqInCore#sequence(e7e5aa338b9d5147).(), seq->sequenceLengthcxx . . $ seqInCore#sequenceLength(ddd8539a2fcdd4ce).(), configcxx . . $ config.._merSizecxx . . $ configuration#_merSize., rc); |
| 50 | state->encodeTimecxx . . $ searcherState#encodeTime. += getTime() - startTime; |
| 51 | |
| 52 | // Get the hits |
| 53 | // |
| 54 | startTime = getTime(); |
| 55 | matrix = new hitMatrixcxx . . $ hitMatrix#(seq->sequenceLengthcxx . . $ seqInCore#sequenceLength(ddd8539a2fcdd4ce).(), idx); |
| 56 | |
| 57 | while (query->getMercxx . . $ encodedQuery#getMer(4c1b2b38f691f6d0).(mer, pos) == true) |
| 58 | if (positionscxx . . $ positions.->getExactcxx . . $ positionDB#getExact(b58b54e41cf135a2).(mer, state->posncxx . . $ searcherState#posn., state->posnMaxcxx . . $ searcherState#posnMax., state->posnLencxx . . $ searcherState#posnLen., count)) |
| 59 | matrix->addHitscxx . . $ hitMatrix#addHits(19fbb4f67f92d147).(pos, state->posncxx . . $ searcherState#posn., state->posnLencxx . . $ searcherState#posnLen.); |
| 60 | |
| 61 | state->searchTimecxx . . $ searcherState#searchTime. += getTime() - startTime; |
| 62 | |
| 63 | // Begin processing |
| 64 | // |
| 65 | startTime = getTime(); |
| 66 | matrix->processMatrixcxx . . $ hitMatrix#processMatrix(b2e8704fc2713a96).(rc ? 'r' : 'f', FO); |
| 67 | state->processTimecxx . . $ searcherState#processTime. += getTime() - startTime; |
| 68 | |
| 69 | delete matrix; |
| 70 | delete query; |
| 71 | } |
| 72 | |
| 73 | |
| 74 | |
| 75 | void* |
| 76 | searchThreadcxx . . $ searchThread(9f162e79bfc6c74).(void *U) { |
| 77 | uint32cxx . . $ uint32# idx = 0; |
| 78 | seqInCorecxx . . $ seqInCore# *seq = 0L; |
| 79 | uint32cxx . . $ uint32# blockedI = 0; |
| 80 | uint32cxx . . $ uint32# blockedO = 0; |
| 81 | uint32cxx . . $ uint32# computed = 0; |
| 82 | |
| 83 | searcherStatecxx . . $ searcherState# *state = new searcherStatecxx . . $ searcherState#; |
| 84 | |
| 85 | // Allocate and fill out the thread stats -- this ensures that we |
| 86 | // always have stats (even if they're bogus). |
| 87 | // |
| 88 | threadStatscxx . . $ threadStats.[(long)U] = new char [1025]; |
| 89 | sprintf(threadStatscxx . . $ threadStats.[(long)U], srchGbyecxx . . $ srchGbye., |
| 90 | (long)U, |
| 91 | (uint32cxx . . $ uint32#)0, (uint32cxx . . $ uint32#)0, (uint32cxx . . $ uint32#)0, |
| 92 | 0.0, 0.0, 0.0); |
| 93 | |
| 94 | while (inputTailcxx . . $ inputTail. < numberOfQueriescxx . . $ numberOfQueries.) { |
| 95 | |
| 96 | // Grab the next sequence. |
| 97 | // |
| 98 | pthread_mutex_lock(&inputTailMutexcxx . . $ inputTailMutex.); |
| 99 | idx = inputTailcxx . . $ inputTail.; |
| 100 | if (idx < numberOfQueriescxx . . $ numberOfQueries.) { |
| 101 | seq = inputcxx . . $ input.[idx]; |
| 102 | inputcxx . . $ input.[idx] = 0L; |
| 103 | if (seq) |
| 104 | inputTailcxx . . $ inputTail.++; |
| 105 | } |
| 106 | pthread_mutex_unlock(&inputTailMutexcxx . . $ inputTailMutex.); |
| 107 | |
| 108 | // Still need to check that the index is valid. Another thread |
| 109 | // could (and does) steal execution between the while and the |
| 110 | // mutex lock. |
| 111 | // |
| 112 | if (idx < numberOfQueriescxx . . $ numberOfQueries.) { |
| 113 | |
| 114 | // If there is no sequence, oh boy, we are in bad shape. Sleep a |
| 115 | // little bit to let the loader catch up, then try again. |
| 116 | // |
| 117 | if (seq == 0L) { |
| 118 | //if (config._loaderWarnings) |
| 119 | // fprintf(stderr, "%lu Blocked by input.\n", (uint64)U); |
| 120 | blockedI++; |
| 121 | nanosleep(&configcxx . . $ config.._searchSleepcxx . . $ configuration#_searchSleep., 0L); |
| 122 | } else { |
| 123 | |
| 124 | // If our idx is too far away from the output thread, sleep |
| 125 | // a little bit. We keep the idx and seq that we have obtained, |
| 126 | // though. |
| 127 | // |
| 128 | while (idx > (outputPoscxx . . $ outputPos. + configcxx . . $ config.._writerHighWaterMarkcxx . . $ configuration#_writerHighWaterMark.)) { |
| 129 | if (configcxx . . $ config.._writerWarningscxx . . $ configuration#_writerWarnings.) |
| 130 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, uint64FMTcxx . . $ `libutil/util.h:55:10`!" Blocked by output (idx = "uint32FMTcxx . . $ `libutil/util.h:65:10`!", outputPos = "uint32FMTcxx . . $ `libutil/util.h:65:10`!").\n", (long)U, idx, outputPoscxx . . $ outputPos.); |
| 131 | blockedO++; |
| 132 | nanosleep(&configcxx . . $ config.._searchSleepcxx . . $ configuration#_searchSleep., 0L); |
| 133 | } |
| 134 | |
| 135 | // Construct a filter object |
| 136 | // |
| 137 | filterObjcxx . . $ filterObj# *FO = new filterObjcxx . . $ filterObj#(configcxx . . $ config.._filterObjcxx . . $ configuration#_filterObj., configcxx . . $ config.._filteroptscxx . . $ configuration#_filteropts.); |
| 138 | |
| 139 | // Do searches. |
| 140 | // |
| 141 | if (configcxx . . $ config.._doForwardcxx . . $ configuration#_doForward.) |
| 142 | doSearchcxx . . $ doSearch(517d947672db2af1).(state, seq, idx, false, FO); |
| 143 | if (configcxx . . $ config.._doReversecxx . . $ configuration#_doReverse.) |
| 144 | doSearchcxx . . $ doSearch(517d947672db2af1).(state, seq, idx, true, FO); |
| 145 | |
| 146 | // Do filtering. |
| 147 | // |
| 148 | FO->filtercxx . . $ filterObj#filter(49f6e7a06ebc5aa8).(); |
| 149 | |
| 150 | // Signal that we are done. |
| 151 | // |
| 152 | outputcxx . . $ output.[idx] = FO; |
| 153 | computed++; |
| 154 | |
| 155 | delete seq; |
| 156 | |
| 157 | } // end of seq != 0L |
| 158 | } // end of idx < numberOfQueries |
| 159 | } // end of inputTail < numberOfQueries |
| 160 | |
| 161 | |
| 162 | // OK, now fill out the read thread stats |
| 163 | // |
| 164 | sprintf(threadStatscxx . . $ threadStats.[(long)U], srchGbyecxx . . $ srchGbye., (long)U, |
| 165 | computed, blockedI, blockedO, |
| 166 | state->encodeTimecxx . . $ searcherState#encodeTime., |
| 167 | state->searchTimecxx . . $ searcherState#searchTime., |
| 168 | state->processTimecxx . . $ searcherState#processTime.); |
| 169 | |
| 170 | delete state; |
| 171 | |
| 172 | return(0L); |
| 173 | } |