Просмотр исходного кода

Let user restrict to first n threads

Vecna 3 месяцев назад
Родитель
Сommit
22b63ab7ad
3 измененных файлов с 34 добавлено и 4 удалено
  1. 13 1
      run-fast.sh
  2. 14 1
      run.sh
  3. 7 2
      scripts/generate-lox-results.sh

+ 13 - 1
run-fast.sh

@@ -1,3 +1,15 @@
 #!/bin/sh
 
-./run.sh --fast
+ncpus=$(nproc)
+
+while -n "$1"; do
+    if [ "$1" == "--fast" ]; then
+        fast=true
+    elif [ "$1" == "-n" ]; then
+        ncpus="$2"
+        shift
+    fi
+    shift
+done
+
+./run.sh --fast -n "$ncpus"

+ 14 - 1
run.sh

@@ -1,5 +1,18 @@
 #!/bin/bash
 
+fast=false
+ncpus=$(nproc)
+
+while -n "$1"; do
+    if [ "$1" == "--fast" ]; then
+        fast=true
+    elif [ "$1" == "-n" ]; then
+        ncpus="$2"
+        shift
+    fi
+    shift
+done
+
 abort() {
     echo "Step $1 failed."
     echo "To restart from this step, try running:"
@@ -61,7 +74,7 @@ if [[ ! -d parsing-results/lox-old || ! -d parsing-results/lox-new || ! -d parsi
     # Clean up any remnants of previous attempts and try again
     rm -rf parsing-results/{lox-{old,new},troll-patrol}
 
-    ./scripts/generate-lox-results.sh || abort "lox-gen"
+    ./scripts/generate-lox-results.sh -n "$ncpus" || abort "lox-gen"
 fi
 
 # Process Lox benchmark results

+ 7 - 2
scripts/generate-lox-results.sh

@@ -1,5 +1,10 @@
 #!/bin/bash
 
+ncpus=$(nproc)
+if [ "$1" == "-n" ]; then
+    ncpus="$2"
+fi
+
 hosts=()
 for i in $(seq 1 5); do
     hosts+=(lox-old)
@@ -55,8 +60,8 @@ for i in $(seq 0 15); do
     index=$((index + 1))
     echo "Command started and pushed to background."
 
-    if [ $index == $(nproc) ]; then
-        echo "Waiting for the first $(nproc) commands to complete..."
+    if [ $index == "$ncpus" ]; then
+        echo "Waiting for the first $ncpus commands to complete..."
         wait
         index=0
     fi