aboutsummaryrefslogtreecommitdiff
path: root/measurements/2017-11-16/bench-android.sh
blob: f644ce49f727e90600b4c7336e820b4abe7228b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
set -e
export PATH="$PATH:$HOME/android-toolchain/bin/"
for p in $(cat primes.txt | sed 's:#.*::g' | grep . | tr -d ' ' | tr '^*+-' 'expm'); do
  for synth in solinas32 montgomery32; do
    impls=$(ls -d "src/Specific/${synth}_${p}_"*"limbs" 2>/dev/null || true)
    if [ -z "$impls" ]; then
      printf "# MISSING src/Specific/%s_%s_*limbs\n" "$synth" "$p";
      continue
    fi
    for impl in $impls; do
      if ! sh -c "arm-linux-androideabi-gcc -pie \
        $(tail -1 "$impl/compiler.sh" | tr ' ' '\n' | grep -A99999 -- -D  | grep -v '"$@"' | tr '\n' ' ') \
        -I \"$impl\" \
        -std=gnu11 -O3 -flto -fomit-frame-pointer -fwrapv -Wno-attributes -fno-strict-aliasing \
        src/Specific/Framework/bench/fibe.c \
        -o /tmp/main" \
        > /dev/null 2> /dev/null
      then
        printf "# MISSING %s\n" "$impl/fibe"
        continue
      fi
      adb push /tmp/main /data/local/tmp/main >/dev/null 2>/dev/null
      printf "$impl/fibe"
      adb shell "time /data/local/tmp/main 2>/dev/null" | sed 's:0m::g' | sed 's:s\sreal.*::g'
    done
  done
  for ref in gmpvar gmpsec; do
    impl=$(ls -d "src/Specific/montgomery32_$p"* 2>/dev/null || true)
    if ! sh -c "arm-linux-androideabi-gcc -pie \
      $(tail -1 "$impl/compiler.sh" | tr ' ' '\n' | grep -A99999 -- -D  | grep -v '"$@"' | tr '\n' ' ') \
      -I \"$impl\" \
      -I ~/android-toolchain/gmp-6.1.2/ \
      -std=gnu11 -O3 -flto -fomit-frame-pointer -fwrapv -Wno-attributes -fno-strict-aliasing \
      src/Specific/Framework/bench/$ref.c \
      $HOME/android-toolchain/gmp-6.1.2/.libs/libgmp.a \
      -o /tmp/main" \
      > /dev/null 2> /dev/null
    then
      printf "# MISSING %s\n" "$impl/$ref"
      continue
    fi
    adb push /tmp/main /data/local/tmp/main >/dev/null 2>/dev/null
    printf "$impl/$ref"
    adb shell "time /data/local/tmp/main 2>/dev/null" | sed 's:0m::g' | sed 's:s\sreal.*::g'
  done
done