From 109b1fe4e677390568d649f84103030307bd3f72 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 2 Jan 2018 16:45:43 -0500 Subject: [PATCH 1/6] Add channel.advancePastByte --- modules/standard/IO.chpl | 23 ++++++++++++++++++ runtime/include/qio/qio.h | 3 +++ runtime/src/qio/qio.c | 49 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/modules/standard/IO.chpl b/modules/standard/IO.chpl index ff2462457a34..6ffb8b7d622f 100644 --- a/modules/standard/IO.chpl +++ b/modules/standard/IO.chpl @@ -931,6 +931,8 @@ private extern proc qio_channel_write_byte(threadsafe:c_int, ch:qio_channel_ptr_ private extern proc qio_channel_offset_unlocked(ch:qio_channel_ptr_t):int(64); private extern proc qio_channel_advance(threadsafe:c_int, ch:qio_channel_ptr_t, nbytes:int(64)):syserr; +private extern proc qio_channel_advance_past_byte(threadsafe:c_int, ch:qio_channel_ptr_t, byte:c_int):syserr; + private extern proc qio_channel_mark(threadsafe:c_int, ch:qio_channel_ptr_t):syserr; private extern proc qio_channel_revert_unlocked(ch:qio_channel_ptr_t); private extern proc qio_channel_commit_unlocked(ch:qio_channel_ptr_t); @@ -2249,6 +2251,27 @@ proc channel.advance(amount:int(64)) throws { } } +// TODO: this advances to just after the requested byte, or returns EEOF +proc channel.advancePastByte(byte:c_int, ref error:syserr) { + on this.home { + try! this.lock(); + error = qio_channel_advance_past_byte(false, _channel_internal, byte); + this.unlock(); + } +} + +// documented with the error= version +pragma "no doc" +proc channel.advancePastByte(byte:c_int) throws { + on this.home { + try! this.lock(); + var err = qio_channel_advance_past_byte(false, _channel_internal, byte); + if err then try this._ch_ioerror(err, "in advanceToByte"); + this.unlock(); + } +} + + // These begin with an _ to indicated that // you should have a lock before you use these... there is probably // a better name for them... diff --git a/runtime/include/qio/qio.h b/runtime/include/qio/qio.h index a72dbe2fcb40..134c805dede5 100644 --- a/runtime/include/qio/qio.h +++ b/runtime/include/qio/qio.h @@ -1266,6 +1266,9 @@ qioerr qio_channel_end_peek_cached(const int threadsafe, qio_channel_t* ch, void return err; } + +qioerr qio_channel_advance_past_byte(const int threadsafe, qio_channel_t* ch, int byte); + qioerr qio_channel_begin_peek_buffer(const int threadsafe, qio_channel_t* ch, int64_t require, int writing, qbuffer_t** buf_out, qbuffer_iter_t* start_out, qbuffer_iter_t* end_out); qioerr qio_channel_end_peek_buffer(const int threadsafe, qio_channel_t* ch, int64_t advance); diff --git a/runtime/src/qio/qio.c b/runtime/src/qio/qio.c index 4dae3fc47e7b..864e488fcefa 100644 --- a/runtime/src/qio/qio.c +++ b/runtime/src/qio/qio.c @@ -3441,6 +3441,51 @@ qioerr qio_channel_end_peek_buffer(const int threadsafe, qio_channel_t* ch, int6 return err; } +qioerr qio_channel_advance_past_byte(const int threadsafe, qio_channel_t* ch, int byte) +{ + qioerr err=0; + + if( threadsafe ) { + err = qio_lock(&ch->lock); + if( err ) { + return err; + } + } + + // Is there room in our fast path buffer? + while (err==0) { + if( qio_space_in_ptr_diff(1, ch->cached_end, ch->cached_cur) ) { + size_t len = qio_ptr_diff(ch->cached_end, ch->cached_cur); + void* found = memchr(ch->cached_cur, byte, len); + if (found != NULL) { + ssize_t off = qio_ptr_diff(found, ch->cached_cur); + off += 1; + ch->cached_cur = qio_ptr_add(ch->cached_cur, off); + break; + } else { + // We checked the data in the buffer, advance to the next section. + ch->cached_cur = ch->cached_end; + } + } else { + // There's not enough data in the buffer, apparently. Try it the slow way. + ssize_t amt_read; + uint8_t tmp; + err = _qio_slow_read(ch, &tmp, 1, &amt_read); + if( err == 0 ) { + if (tmp == byte) break; + if (amt_read != 1) err = QIO_ESHORT; + } + } + } + + if( threadsafe ) { + qio_unlock(&ch->lock); + } + + return err; +} + + qioerr qio_channel_mark_maybe_flush_bits(const int threadsafe, qio_channel_t* ch, int flushbits) { qioerr err; @@ -3599,6 +3644,10 @@ qioerr qio_channel_advance_unlocked(qio_channel_t* ch, int64_t nbytes) if( use_buffered ) { err = _qio_buffered_behind(ch, false); } + } else { + if( use_buffered ) { + _qio_buffered_setup_cached(ch); + } } return err; } From 1279813c3dbffd68096fb762ba55e5bf6959339f Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 2 Jan 2018 16:49:49 -0500 Subject: [PATCH 2/6] Add mark-skip-read version of revcomp This version of the benchmark finds the terminators within the I/O buffer and then reads the appropriate amount of data directly. --- .../revcomp-mark-skip-read-begin.chpl | 87 +++++++++ .../revcomp-mark-skip-read-begin.good | 171 ++++++++++++++++++ .../revcomp-mark-skip-read-begin.perfkeys | 2 + .../revcomp-mark-skip-read-begin.suppressif | 2 + .../shootout/reverse-complement/revcomp.graph | 6 +- 5 files changed, 265 insertions(+), 3 deletions(-) create mode 100644 test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.chpl create mode 100644 test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.good create mode 100644 test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.perfkeys create mode 100644 test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.suppressif diff --git a/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.chpl b/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.chpl new file mode 100644 index 000000000000..0aa7eb14778b --- /dev/null +++ b/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.chpl @@ -0,0 +1,87 @@ +/* The Computer Language Benchmarks Game + http://benchmarksgame.alioth.debian.org/ + contributed by Ben Harshbarger + derived from the Rust #2 version by Matt Brubeck +*/ + +const table = initTable("ATCGGCTAUAMKRYWWSSYRKMVBHDDHBVNN\n\n"); + +config const readSize = 16 * 1024; + +proc main(args: [] string) { + const stdin = openfd(0); + var input = stdin.reader(iokind.native, locking=false); + var len = stdin.length(); + var data : [0..#len] uint(8); + + sync { // wait for all process() tasks to complete before continuing + + while true { + const descOffset = input._offset(); + var nextDescOffset = descOffset; + var seqOffset = descOffset; + var eof = false; + + // Mark where we start scanning (keep bytes in I/O buffer in input) + input._mark(); + + // Scan forward until we get to the \n (end of description) + input.advancePastByte(ascii("\n")); + seqOffset = input._offset(); + + try { + // Scan forward until we get to the > (end of sequence) + input.advancePastByte(ascii(">")); + nextDescOffset = input._offset(); + } catch UnexpectedEOFError { + eof = true; + nextDescOffset = len; + } + + // Go back to the point we marked + input._revert(); + + // Read until nextDescOffset into the data array. + input.readBytes(c_ptrTo(data[descOffset]), nextDescOffset-descOffset); + + + if !eof { + // '-3' to skip over '\n>' + begin process(data, seqOffset, nextDescOffset-3); + } else { + // '-2' to skip over '\n' + begin process(data, seqOffset, len-2); + break; + } + } + } + + const stdoutBin = openfd(1).writer(iokind.native, locking=false, + hints=QIO_CH_ALWAYS_UNBUFFERED); + stdoutBin.write(data); +} + +proc process(data, in start, in end) { + + proc advance(ref cursor, dir) { + do { cursor += dir; } while data[cursor] == ascii("\n"); + } + while start <= end { + ref d1 = data[start], d2 = data[end]; + (d1, d2) = (table[d2], table[d1]); + advance(start, 1); + advance(end, -1); + } +} + +proc initTable(pairs) { + var table: [1..128] uint(8); + + for i in 1..pairs.length by 2 { + table[ascii(pairs[i])] = ascii(pairs[i+1]); + if pairs[i] != "\n" then + table[ascii(pairs[i].toLower())] = ascii(pairs[i+1]); + } + + return table; +} diff --git a/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.good b/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.good new file mode 100644 index 000000000000..14d792ade8d5 --- /dev/null +++ b/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.good @@ -0,0 +1,171 @@ +>ONE Homo sapiens alu +CGGAGTCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAAC +CTCCGCCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACA +GGCGCGCGCCACCACGCCCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCAT +GTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAA +AGTGCTGGGATTACAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTC +TGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCGCCTCCCGG +GTTCAAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGCGCGCCACC +ACGCCCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGGCCAGGCTG +GTCTCGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTA +CAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTCTGTCGCCCAGGCT +GGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCGCCTCCCGGGTTCAAGCGATTC +TCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGCGCGCCACCACGCCCGGCTAAT +TTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGGCCAGGCTGGTCTCGAACTCCT +GACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCA +CCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGC +GCGATCTCGGCTCACTGCAACCTCCGCCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCC +TCCCGAGTAGCTGGGATTACAGGCGCGCGCCACCACGCCCGGCTAATTTTTGTATTTTTA +GTAGAGACGGGGTTTCACCATGTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGAT +CCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCACCGCGCCCGGCCT +TTTTGAGACGGAGTCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTC +ACTGCAACCTCCGCCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTG +GGATTACAGGCGCGCGCCACCACGCCCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGT +TTCACCATGTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGG +CCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAG +TCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCG +CCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGC +GCGCCACCACGCCCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGG +CCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGC +TGGGATTACAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTCTGTCG +CCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCGCCTCCCGGGTTCA +AGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGCGCGCCACCACGCC +CGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGGCCAGGCTGGTCTC +GAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGC +GTGAGCCACCGCGCCCGGCC +>TWO IUB ambiguity codes +TAGGDHACHATCRGTRGVTGAGWTATGYTGCTGTCABACDWVTRTAAGAVVAGATTTNDA +GASMTCTGCATBYTTCAAKTTACMTATTACTTCATARGGYACMRTGTTTTYTATACVAAT +TTCTAKGDACKADACTATATNTANTCGTTCACGBCGYSCBHTANGGTGATCGTAAAGTAA +CTATBAAAAGATSTGWATBCSGAKHTTABBAACGTSYCATGCAAVATKTSKTASCGGAAT +WVATTTNTCCTTCTTCTTDDAGTGGTTGGATACVGTTAYMTMTBTACTTTHAGCTAGBAA +AAGAGKAAGTTRATWATCAGATTMDDTTTAAAVAAATATTKTCYTAAATTVCNKTTRACG +ADTATATTTATGATSADSCAATAWAGCGRTAGTGTAAGTGACVGRADYGTGCTACHVSDT +CTVCARCSYTTAATATARAAAATTTAATTTACDAATTGBACAGTAYAABATBTGCAGBVG +TGATGGDCAAAATBNMSTTABKATTGGSTCCTAGBTTACTTGTTTAGTTTATHCGATSTA +AAGTCGAKAAASTGTTTTAWAKCAGATATACTTTTMTTTTGBATAGAGGAGCMATGATRA +AAGGNCAYDCCDDGAAAGTHGBTAATCKYTBTACBGTBCTTTTTGDTAASSWTAAWAARA +TTGGCTAAGWGRADTYACATAGCTCBTAGATAWAGCAATNGTATMATGTTKMMAGTAWTC +CCNTSGAAWATWCAAAAMACTGAADNTYGATNAATCCGAYWNCTAACGTTAGAGDTTTTC +ATCTGGKRTAVGAABVCTGWGBTCTDVGKATTBTCTAAGGVADAAAVWTCTAGGGGAGGG +TTAGAACAATTAAHTAATNAAATGCATKATCTAAYRTDTCAGSAYTTYHGATRTTWAVTA +BGNTCDACAGBCCRCAGWCRTCABTGMMAWGMCTCAACCGATRTGBCAVAATCGTDWDAA +CAYAWAATWCTGGTAHCCCTAAGATAACSCTTAGTGSAACAWTBGTCDTTDGACWDBAAC +HTTTNGSKTYYAAYGGATNTGATTTAARTTAMBAATCTAAGTBTCATYTAACTTADTGTT +TCGATACGAAHGGCYATATACCWDTKYATDCSHTDTCAAAATGTGBACTGSCCVGATGTA +TCMMAGCCTTDAAABAATGAAGAGTAACTHATMGVTTAATAACCCGGTTVSANTGCAATT +GTGAGATTTAMGTTTAMAAYGCTGACAYAAAAAGGCACAMYTAAGVGGCTGGAABVTACG +GATTSTYGTBVAKTATWACCGTGTKAGTDTGTATGTTTAAAGGAAAAAGTAACATARAAA +GGTYCAMNYAAABTATAGNTSATANAGTCATCCTATWADKAACTRGTMSACDGTATSAYT +AAHSHGTAABYGACTYTATADTGSTATAGAGAAATCGNTAAAGGAAATCAGTTGTNCYMV +TNACDRTATBNATATASTAGAAMSCGGGANRCKKMCAAACATTNAGTCTRMAATBMTACC +CGTACTTCTBGDSYAATWGAAAATGACADDCHAKAAAYATATTKTTTTCACANACWAGAA +AKATCCTTATTAYKHKCTAAACARTATTTTDATBTVWCYGCAATACTAGGKAAASTTDGA +MGGCHTTHAATVCAHDRYAGGRCTATACGTCMAGAGAGCTBTHGNACARTCCBDCTAAGA +GCGGCTTTARTAAAGAATCCNAGTAWBTGACTTGAATTACWTVACAGAAABCAATNAAAC +CGTNTRANTTGAYCMAWBADTANABRGGTKTHTWTAGTTVCTMBKTAGMTVKCCAGCANT +TVAGSWTTAGCCGCRHTTTCCTTHNTATTAAGAAGAATAGGMTRAARTCTABGTACDTTT +TATAAVDHAHTATAGATCCTAGTAAGYTWATDWCATGAGGGATAGTAAMDMNGBASTWAM +TSTATRBAYDABATGTATATYCGCACTGTTTTAACMCWBTATAWAGTATBTSTATVTTAR +CCTMTTAAKADATCAACTAATYTSVTAKGDATTATGCKTCAYCAKAATACTTKAANGAGT +ATTSDAGATCGGAAATACTTAAYAAVGTATMCGCTTGTGTDCTAATYTATTTTATTTWAA +CAGWRCTATGTAGMTGTTTGTTYKTNGTTKTCAGAACNTRACCTACKTGSRATGTGGGGG +CTGTCATTAAGTAAATNGSTTABCCCCTCGCAGCTCWHTCGCGAAGCAVATGCKACGHCA +ACAKTTAATAACASAAADATTWNYTGTAATTGTTCGTMHACHTWATGTGCWTTTTGAAHY +ACTTTGTAYAMSAAACTTAADAAATATAGTABMATATYAATGSGGTAGTTTGTGTBYGGT +TWSGSVGWMATTDMTCCWWCABTCSVACAGBAATGTTKATBGTCAATAATCTTCTTAAAC +ARVAATHAGYBWCTRWCABGTWWAATCTAAGTCASTAAAKTAAGVKBAATTBGABACGTA +AGGTTAAATAAAAACTRMDTWBCTTTTTAATAAAAGATMGCCTACKAKNTBAGYRASTGT +ASSTCGTHCGAAKTTATTATATTYTTTGTAGAACATGTCAAAACTWTWTHGKTCCYAATA +AAGTGGAYTMCYTAARCSTAAATWAKTGAATTTRAGTCTSSATACGACWAKAASATDAAA +TGYYACTSAACAAHAKTSHYARGASTATTATTHAGGYGGASTTTBGAKGATSANAACACD +TRGSTTRAAAAAAAACAAGARTCVTAGTAAGATAWATGVHAAKATWGAAAAGTYAHVTAC +TCTGRTGTCAWGATRVAAKTCGCAAVCGASWGGTTRTCSAMCCTAACASGWKKAWDAATG +ACRCBACTATGTGTCTTCAAAHGSCTATATTTCGTVWAGAAGTAYCKGARAKSGKAGTAN +TTTCYACATWATGTCTAAAADMDTWCAATSTKDACAMAADADBSAAATAGGCTHAHAGTA +CGACVGAATTATAAAGAHCCVAYHGHTTTACATSTTTATGNCCMTAGCATATGATAVAAG +>THREE Homo sapiens frequency +ATATTTATCTTTTCACTTCCTACATTGGTCAGACCATTATTCGACACGTGGCGTCATTTT +GTCATACCGGGTAATGTTGGAAACAAAACGTACTGATAAAATACTGAGTTGTAAACTCTA +ATCAGATAACGCGCTTGGATATTAAGATTCACACAGGGGTTTCGGCTGTAAAAAAACTTG +TGGAGCTGTTCTGGGACAGATAAGTTGTACCTCGTACTTAGCTAATTAATGAACCAACTG +ATTACGATAGAACAATTCTGAGGCCGCCAGGACAGCCAAATTTTAATCTTATAAAGCTGG +AAACAGCCGGTATTAGCTTCTCGCATACTTTGCCTGCATTGGTACCTTACAGATATCAGC +GTAGTCATATACACCTCGGTCTCAGCTAAGCTTGTATCTCTTAGAGTAGTTCAAAGATAG +TGGACAATACCTGTGGAATCGATTGCAGATATGGATTTATTTAACTACTGAGTCTCATTC +ACAAGCTAAGCAAGGAGCACGTTTTGGTGCCGGCATACCGATTTGCTATCATGTCAGCAA +ATTTGCGTTGTATTCCTAGTTGCACCCATTAAGGCCACACTCCGAACCTAATTATTACAT +CGCAAAGACATGTACGAAGGACCCGATGTCGAATAGAAGGGAGGACTGTTCATTGGAAGC +TAGACCAGAGGAATCGCAAAGATGCAACTCTTACAATAAAAATCTAATTTCAGTCAACAC +GCAATTTCTATAAGGTTTCCGATAATAATGAACCGTCTTCCACAGGGGAATTTGCCATGC +TCGTAAAAGTAGTTAATCCAAGTAGAAGAAATTTTGATAATGTTTTAAGTTGGCACGAAG +GAATTCAGAGAGATCTTACCTAACAAAGGCATTAGTAGATGTTCCTTGGTTCACACTCGG +TCAATCAGAGCACATACTACGGGCGATACCGGGAATGACACAACATCAATGAGATTGTTA +AGTGAGGTAATTGACTTTAGAGGACTCGATCAGTATACTGTCACTATGAACATCGTATTA +ATTGTTATCCGATATATACACCACCGATTTGCTTGTGCAAGGTTACAGACCCATTCGATA +AATACAAACACGGAGCGATATTATTTAAGGAGTGCTGTCTTCAAAAGAATTATTCCCACA +CCGACATAAGAACTTCGCTCCGTCATTCCAGATTTAAATAACATAACGTAACGCTTTGCT +GATAACATAACATAACCGAGAATTTGCTTAGGAAATTTGGAGCAATATTGCATTGTTTCT +CAGTCATCACAAGGCCCGCCAAAGAACTCTGAGAATCAGGATTCAACATGATTGGTAAGA +CTCTATATATATAACTTAATTCTTGTGTCCGGAGATAGAAAGAGGACGAGAGATACTACG +AAAGAAAGTGTACTTCGATGTATCAATTCAGACGCCTTCTCTATCATCAACATTATAGGT +CTCGTATATGCTCGGCGCGATCTGCTTCTCTCCGCCAATAGCCCCATAGTGTATTTCAAG +CGCAGTAACAGTGAAATCGTTACGAAGGTAGGGATGTTGCTTATAATTGTCGTAACTTAT +CGCTTATGTATCTTTCAAGAATGAACGGCAGCATATACATACGTTCTACCTTTAGCTACA +AAGCATCCATATACTCCCTCTCATGATTGAAACTCTTCCCTATTTTGTAGCCAATAGTGA +AAGCGTATTAGTATAAATTCGTCGGTTTTTCACTCGCAACTGTTATACTCTGCAAACAAA +CGAAAGCCTCATAGTACAAACCTAAAGCTACATACTTCATCATTGGCAGACCAGTGGCGG +TATTTCTACGGAAGCATCACTATAGATATAAAGTTTCCCTTCATGTACGTCTGTTAACCA +TATCACAAGAAACTGCTATCTCTGTCACGTAACAATTCACGCGCCTTATCGCCAAATGTT +CATATATGCGCGGTATACGTATGAACGAATACTAATTAGTATAACGGAGGATTCACGGGA +GGGATACTTGGGGCATTTATAAATCGTCTAAAAATTTTCTATCAGCACTTGCGGGTTATA +GTGGATTACTAGGCAACATAATATTCTGTATTGGTCCAAATGACGCTATAGATAAATTAG +CAAAATACATTGTTTCCATTTATGTAAGTCGAAACTCCAGGACTCCCGGGAACCAGTTAA +ACCGTCTGGAAAAGACACATTGTGAGCGGGACTTCAATGATAGCTTTCAATGAGCTTCTC +ATGCTTGGGGTCTGTACATATATGTTGGCGAAATTATCGTCTGTATTCTGTTATGCTTTG +ATCATGGGTTATTAGTATAGTGTCCGGTTAAGTACCAATACCGCTAGAGACCCGACCTAA +GTCGATAACTAACGATCATCGACGTAAGGATCGTCTCGATCAGTACTTCAGTCTAGATCT +GGGAATAGTAACTCGTTAGTGAACTATGTCGTGTCATAACTCTAAAATGCAATCAAATCT +TATTATTGAGTATTGATTATATAAAGCATCCGCTTAGCTTTACCCTCAAATGTTATATGC +AATTTAAAGCGCTTGATATCGTCTACTCAAGTTCAGGTTTCACATGGCCGCAACGTGACG +TTATTAGAGGTGGGTCATCATCTCTGAGGCTAGTGATGTTGAATACTCATTGAATGGGAA +GTGGAATACCATGCTCGTAGGTAACAGCATGACCTATAAAATATACTATGGGTGTGTGGT +AGATCAATATTGTTCAAGCATATCGTAACAATAACGGCTGAAATGTTACTGACATGAAAG +AGGGAGTCCAAACCATTCTAACAGCTGATCAAGTCGTCTAAAAACGCCTGGTTCAGCCTT +AAGAGTTATAAGCCAGACAAATTGTATCAATAGAGAATCCGTAAATTCCTCGGCCAACCT +CTTGCAAAGACATCACTATCAATATACTACCGTGATCTTAATTAGTGAACTTATATAAAT +ATCTACAACCAGATTCAACGGAAAAGCTTTAGTGGATTAGAAATTGCCAAGAATCACATT +CATGTGGGTTCGAATGCTTTAGTAATACCATTTCGCCGAGTAGTCACTTCGCTGAACTGT +CGTAAATTGCTATGACATAATCGAAAAGGATTGTCAAGAGTCGATTACTGCGGACTAATA +ATCCCCACGGGGGTGGTCTCATGTCTCCCCAGGCGAGTGGGGACGGTTGATAAACACGCT +GCATCGCGGACTGATGTTCCCAGTATTACATAGTCACATTGGATTGCGAGTAGTCTACCT +ATTTATGAGCGAGAGATGCCTCTAACTACTTCGACTTTTAAAACCTTTCCACGCCAGTAT +TCGGCGAAAGGGAAGTATTAAGGGTTGTCATAATTAAGCTGATACCACTTCAGACTTTGC +TCTACTTCTGTCTTTCATTGGTTTAGTAAAGTCTGTCCATTCGTCGAGACCGTCTTTTGC +AGCCTCATTCTACCAACTGCTCCGACTCTTAGTCTGCTTCTCCCAGCGTTATAACAAGAG +GCATTTTGTCATCCTTAAAACAATAATAAAGAACTCGGAGCACTGATATAATGACTGAAT +TAGAACCGCTTAAAAATACAACGAATAGATAAGACTATCGGATAAGATCTAATATGTAGT +GATTAAGCCCTTTATTAATTAATAATAGTTACCCTTTCTGATGTAACGCGACATATTACG +ATTTAGTGGCACGTCTGAATTGCAAAGCAGATCTCTACCCGATTTTTATTATAAATCCCG +TATACATCTTGACTTGAGTAATTGTTCATCTTTTTATATCTCTTCGTACTACAAATAATT +AATATCTCAACCCGTATTGTGTGATTCTAATTACCAACAGAATACGAGGAGGTTTTTGCT +TAGGGCCATATATAATGAATCTATCTCGTTTATTCGCGGAACCCGAGATAACATTACGAT +GTAACTATTTTAGAGAACTTAATACAAGAAACATTGCTGATTACTCATAACTAAATGCTT +GGTAATATATCCTCAGTGCCCCTACCATCTTTTACGCAGGGATGTAATTACTTAGGATTC +ATTGTGTAAGAATTACAATGAACGATGGATATGAAGGCATGTTGCGAGGTGTTCCTTGGT +ATGTGAAGTTCGCAGGGCAACAAAAATTTCGCAGAATAGGCCTCAAAGTATTGGTAAAGA +AGACAACTAATCATCACGAGCTTCTGATATCAATACGAACGAGTCCTGTGATGGATGAAA +GAAAGTCGTATCGAAAATGTCAAGAGTCTGCCCAATGTAACTTACTTCAAAAAATAACGC +TTCCGCCAAGTACGTTCGAATAAACGTAATTTTAAAAATACATAAGGGGTGTTAGAAAGT +AAGCGACGGGATATAAGTTAGACTCAAGATTCCGCCGTAAAACGAGACTGATTCCGAAGA +TTGTTCGTGGATCTGGTCATGACTTTCACTGAGTAAGGAGTTTCGACATATGTCAATAAA +CACAAAAATAGAAGCTATTCGATCTGAAAAATATTAGGACAAGAAACTATCTCACGCTAG +CCCAGAATATTCACTCACCCACGGGCGATACTAAAGCACTATATAGTCGCGTGATTACTA +TACATATGGTACACATAAGAATCACGATCAGGTTCTCAATTTTCAACAATATATGTTTAT +TTGCATAGGTAATATTAGGCCTTTAAGAGAAGGATGGGTGAGATACTCCGGGGATGGCGG +CAATAAAGAAAAACACGATATGAGTAATAGGATCCTAATATCTTGGCGAGAGACTTAAGG +TACGAATTTTGCGCAATCTATTTTTTACTTGGCCAGAATTCATGTATGGTATAAGTACGA +ACTTTTTTGATCACTTTCATGGCTACCTGATTAGGATAGTTTGAGGAATTTCCCAAATAT +ACCGATTTAATATACACTAGGGCTTGTCACTTTGAGTCAGAAAAAGAATATAATTACTTA +GGGTAATGCTGCATACATATTCTTATATTGCAAAGGTTCTCTGGGTAATCTTGAGCCTTC +ACGATACCTGGTGAAGTGTT diff --git a/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.perfkeys b/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.perfkeys new file mode 100644 index 000000000000..a84cfd1fb639 --- /dev/null +++ b/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.perfkeys @@ -0,0 +1,2 @@ +real +verify:4166671:CCGACTATTGTAGTTATGGG diff --git a/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.suppressif b/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.suppressif new file mode 100644 index 000000000000..5412d1dc2b4a --- /dev/null +++ b/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.suppressif @@ -0,0 +1,2 @@ +CHPL_LAUNCHER <= slurm +CHPL_LAUNCHER <= aprun diff --git a/test/studies/shootout/reverse-complement/revcomp.graph b/test/studies/shootout/reverse-complement/revcomp.graph index 60ed80a131ff..fbd2917ad4f8 100644 --- a/test/studies/shootout/reverse-complement/revcomp.graph +++ b/test/studies/shootout/reverse-complement/revcomp.graph @@ -1,6 +1,6 @@ -perfkeys: real, real, real, real, real -files: revcomp.dat, revcomp-begin.dat, revcomp-blc.dat, revcomp-buf.dat, revcomp-line.dat -graphkeys: release version, revcomp-begin, Brad version, Buffered, BufferedLine +perfkeys: real, real, real, real, real, real +files: revcomp.dat, revcomp-begin.dat, revcomp-blc.dat, revcomp-buf.dat, revcomp-line.dat, revcomp-mark-skip-read-begin +graphkeys: release version, revcomp-begin, Brad version, Buffered, BufferedLine, mark-skip-read graphtitle: Reverse-complement Shootout Benchmark ylabel: Time (seconds) graphname: revcomp From 5fcd30301849093c447440aa1b9b46091a0e9422 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 1 Feb 2018 11:45:35 -0500 Subject: [PATCH 3/6] Fix catch in the new test --- .../bharshbarg/revcomp-mark-skip-read-begin.chpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.chpl b/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.chpl index 0aa7eb14778b..4aa20723e2a9 100644 --- a/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.chpl +++ b/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.chpl @@ -33,7 +33,7 @@ proc main(args: [] string) { // Scan forward until we get to the > (end of sequence) input.advancePastByte(ascii(">")); nextDescOffset = input._offset(); - } catch UnexpectedEOFError { + } catch e:UnexpectedEOFError { eof = true; nextDescOffset = len; } From 109cab3856a4f1c5f0b30688bd09965c8cbf97fa Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 1 Feb 2018 11:55:26 -0500 Subject: [PATCH 4/6] Fix advancePastByte argument type, add docs --- modules/standard/IO.chpl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/standard/IO.chpl b/modules/standard/IO.chpl index 6ffb8b7d622f..faa4f4aa0166 100644 --- a/modules/standard/IO.chpl +++ b/modules/standard/IO.chpl @@ -2251,21 +2251,23 @@ proc channel.advance(amount:int(64)) throws { } } -// TODO: this advances to just after the requested byte, or returns EEOF -proc channel.advancePastByte(byte:c_int, ref error:syserr) { +pragma "no doc" +proc channel.advancePastByte(byte:uint(8), ref error:syserr) { on this.home { try! this.lock(); - error = qio_channel_advance_past_byte(false, _channel_internal, byte); + error = qio_channel_advance_past_byte(false, _channel_internal, byte:c_int); this.unlock(); } } -// documented with the error= version -pragma "no doc" -proc channel.advancePastByte(byte:c_int) throws { +/* + Reads until ``byte`` is found and then leave the channel offset + just after it. If that byte is never found, raises an EOFError. + */ +proc channel.advancePastByte(byte:uint(8)) throws { on this.home { try! this.lock(); - var err = qio_channel_advance_past_byte(false, _channel_internal, byte); + var err = qio_channel_advance_past_byte(false, _channel_internal, byte:c_int); if err then try this._ch_ioerror(err, "in advanceToByte"); this.unlock(); } From 8c8b7f315ce8b8652c6f2ae6bdc146e3ef0abb3f Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 1 Feb 2018 11:55:39 -0500 Subject: [PATCH 5/6] Fix test catch one more time --- .../bharshbarg/revcomp-mark-skip-read-begin.chpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.chpl b/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.chpl index 4aa20723e2a9..6506a627723d 100644 --- a/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.chpl +++ b/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.chpl @@ -33,7 +33,7 @@ proc main(args: [] string) { // Scan forward until we get to the > (end of sequence) input.advancePastByte(ascii(">")); nextDescOffset = input._offset(); - } catch e:UnexpectedEOFError { + } catch e:EOFError { eof = true; nextDescOffset = len; } From cc64e266c815b4c685426ebfb3199630edcdbd3d Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 1 Feb 2018 11:58:58 -0500 Subject: [PATCH 6/6] Fix 32-bit issue --- .../bharshbarg/revcomp-mark-skip-read-begin.chpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.chpl b/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.chpl index 6506a627723d..17eab975419a 100644 --- a/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.chpl +++ b/test/studies/shootout/reverse-complement/bharshbarg/revcomp-mark-skip-read-begin.chpl @@ -42,7 +42,8 @@ proc main(args: [] string) { input._revert(); // Read until nextDescOffset into the data array. - input.readBytes(c_ptrTo(data[descOffset]), nextDescOffset-descOffset); + input.readBytes(c_ptrTo(data[descOffset]), + (nextDescOffset-descOffset):ssize_t); if !eof {