diff --git a/shootout/fasta/fasta-c.c b/shootout/fasta/fasta-c.c index bd00efdd8e8eef279676b7b5af2131637509ca84..54344d0f7f6ea197fd4fbda3367b7697b88d79aa 100644 --- a/shootout/fasta/fasta-c.c +++ b/shootout/fasta/fasta-c.c @@ -38,7 +38,7 @@ amino homosapiens[] = { #define LENGTH(a) (sizeof(a)/sizeof(a[0])) static inline void str_write(char *s) { - write(fileno(stdout), s, strlen(s)); + (void)! write(fileno(stdout), s, strlen(s)); } void str_repeat(char *s, int outlen) { @@ -61,7 +61,7 @@ void str_repeat(char *s, int outlen) { int l = 0; while (outlen > 0) { l = outlen > len ? len : outlen; - write(fd, buf, l); + (void)! write(fd, buf, l); outlen -= len; } if (buf[l-1] != '\n') str_write("\n"); @@ -107,13 +107,13 @@ void rand_fasta(amino *s, size_t outlen) { while (outlen--) { buf[i++] = lookup[rnd()]; if (i == WIDTH) { - write(fd, buf, WIDTH + 1); + (void)! write(fd, buf, WIDTH + 1); i = 0; } } if (i) { buf[i] = '\n'; - write(fd, buf, i + 1); + (void)! write(fd, buf, i + 1); } } diff --git a/shootout/reverse-complement/Makefile b/shootout/reverse-complement/Makefile index 3dc42dc9b7ea8b9b8d9e98bef21752272ed87260..6679417141d2013fbf502d594dbb4d69286a460a 100644 --- a/shootout/reverse-complement/Makefile +++ b/shootout/reverse-complement/Makefile @@ -26,62 +26,34 @@ SLOW_OPTS = 50000000 # The benchmark game also uses -fllvm, which we can't since it might # not be available on the developer's machine. -#------------------------------------------------------------------ -# Create input - -fasta-c : ../fasta/fasta-c.c - $(CC) -std=gnu99 -O3 -fomit-frame-pointer $< -o $@ - -reverse-complement.faststdin : fasta-c - ./fasta-c $(FAST_OPTS) | tr -d '\r' > $@ - -reverse-complement.stdin : fasta-c - ./fasta-c $(NORM_OPTS) | tr -d '\r' > $@ - -reverse-complement.slowstdin : fasta-c - ./fasta-c $(SLOW_OPTS) | tr -d '\r' > $@ - # Since we only decide here what the INPUT_FILE is, it's required to first run # `make boot` and only than `make` (otherwise `make` doesn't "see" the file and # doesn't call `runstdtest` correctly) ifeq "$(mode)" "slow" INPUT_FILE = reverse-complement.slowstdin + OUTPUT_FILE = reverse-complement.slowstdout else ifeq "$(mode)" "fast" INPUT_FILE = reverse-complement.faststdin + OUTPUT_FILE = reverse-complement.faststdout else INPUT_FILE = reverse-complement.stdin + OUTPUT_FILE = reverse-complement.stdout endif endif -#------------------------------------------------------------------ -# Create output to validate against - -revcomp-c : revcomp-c.o - $(CC) $< -o $@ -pthread - -reverse-complement.faststdout : revcomp-c $(INPUT_FILE) - ./revcomp-c < $(INPUT_FILE) | tr -d '\r' > $@ - -reverse-complement.stdout : revcomp-c $(INPUT_FILE) - ./revcomp-c < $(INPUT_FILE) | tr -d '\r' > $@ +boot :: $(INPUT_FILE) $(OUTPUT_FILE) -reverse-complement.slowstdout : revcomp-c $(INPUT_FILE) - ./revcomp-c < $(INPUT_FILE) | tr -d '\r' > $@ +# Input/Output files generated with boot.sh script +# This is a "pattern rule", the '%' is required. Just a trick to tell make +# that this command generates multiple files. +reverse-complement%faststdin reverse-complement%faststdout: boot.sh ../fasta/fasta-c.c + ./boot.sh . . ${HC} $(mode) -# Since we only decide here what the OUTPUT_FILE is, it's required to first run -# `make boot` and only than `make` (otherwise `make` doesn't "see" the file and -# doesn't call `runstdtest` correctly) -ifeq "$(mode)" "slow" - OUTPUT_FILE = reverse-complement.slowstdout -else - ifeq "$(mode)" "fast" - OUTPUT_FILE = reverse-complement.faststdout - else - OUTPUT_FILE = reverse-complement.stdout - endif -endif +reverse-complement%stdin reverse-complementi%stdout: boot.sh ../fasta/fasta-c.c + ./boot.sh . . ${HC} $(mode) -boot :: $(INPUT_FILE) $(OUTPUT_FILE) +reverse-complement%slowstdin reverse-complement%slowstdout: boot.sh ../fasta/fasta-c.c + ./boot.sh . . ${HC} $(mode) include $(TOP)/mk/target.mk diff --git a/shootout/reverse-complement/boot.sh b/shootout/reverse-complement/boot.sh new file mode 100755 index 0000000000000000000000000000000000000000..de7b3a64b06d66054628813823e3b9ff7bc86fa9 --- /dev/null +++ b/shootout/reverse-complement/boot.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +# Arguments: +# $1 - src folder +# $2 - output folder +# $3 - path to ghc +# $4 - mode + +set -e +src=${1:-.} +output=${2:-.} +HC=${3:-ghc} +mode=${4:-norm} + +EXE="" +if [[ $(shell uname -s | grep -c 'MSYS\|MINGW') -eq 1 ]] +then + EXE=".exe" +fi + +# These values are only used in this file. They are ignored by the +# executable itself. +FAST_OPTS=5000000 +NORM_OPTS=50000000 +# Normally, we'd want to have SLOW_OPTS = $((5*NORM_OPTS)) to run this for 5s +# in 2018. But that means +# - slow generation of huge input and output files +# - having to diff the generated output files +# - the input parser in fasta-c.c overflows, so we're generating an incorrect +# reference output +# So we don't do it. +SLOW_OPTS=50000000 +# This is the official shootout setting ($((NORM_OPTS/2)), i.e. running 0.5s in +# 2018): +# SLOW_OPTS = 25000000 + +# The benchmark game also uses -fllvm, which we can't since it might +# not be available on the developer's machine. + +case $mode in +"norm"*) + MODE_ARGS=$NORM_OPTS + INPUT_FILE=reverse-complement.stdin + OUTPUT_FILE=reverse-complement.stdout + ;; +"slow"*) + MODE_ARGS=$SLOW_OPTS + INPUT_FILE=reverse-complement.slowstdin + OUTPUT_FILE=reverse-complement.slowstdout + ;; +*) + MODE_ARGS=$FAST_OPTS + INPUT_FILE=reverse-complement.faststdin + OUTPUT_FILE=reverse-complement.faststdout + ;; +esac + +# +# Create Input +# +set -x +${HC} -O2 ${src}/../fasta/fasta-c.c -c -o ${output}/fasta-c.o +${HC} -O2 ${output}/fasta-c.o -o ${output}/fasta-c$EXE -no-hs-main +${output}/fasta-c${EXE} $MODE_ARGS | tr -d '\r' > ${output}/${INPUT_FILE} + +# +# Create Output for validation +# +${HC} -O2 ${src}/revcomp-c.c -c -o ${output}/revcomp-c.o +${HC} -O2 ${output}/revcomp-c.o -o ${output}/revcomp-c$EXE -no-hs-main +${output}/revcomp-c$EXE < ${output}/${INPUT_FILE} | tr -d '\r' > ${output}/${OUTPUT_FILE} + diff --git a/shootout/reverse-complement/revcomp-c.c b/shootout/reverse-complement/revcomp-c.c index 610c7999e1dc354fc541a4a04da7a5425863b5df..fe9d4f0dfb4c6d3dea40bcb4e5c474269043dac3 100644 --- a/shootout/reverse-complement/revcomp-c.c +++ b/shootout/reverse-complement/revcomp-c.c @@ -89,7 +89,7 @@ int main() { free(w); } - write(fileno(stdout), buf, end); + (void)! write(fileno(stdout), buf, end); free(buf); return 0;