multicore compilation (dumb script)
[metatrace:metatrace.git] / stupid-and-blind-multicore.sh
1 #!/bin/bash
2
3 mkdir -p supertrace
4
5 TOTAL_WIDTH=256
6 TOTAL_HEIGHT=256
7
8 TILE_WIDTH=5
9 TILE_HEIGHT=1
10
11 if [ ${1} = "join" ] ; then
12         do_join="yes"
13         render="no"
14 elif [ $1 = "multi" ] ; then 
15         do_join="no"
16         render="yes"
17         y_start=$2
18         n_th=$3
19 else
20         do_join="yes"
21         render="yes"
22         y_start=0
23         n_th=1
24 fi;
25
26
27
28 if [ $render = "yes" ] ; then
29         for ((y=$y_start; y<TOTAL_HEIGHT; y+=((TILE_HEIGHT*$n_th)) )); do
30                 for ((x=0; x<TOTAL_WIDTH; x+=TILE_WIDTH)); do
31                         mkdir -p supertrace/$y/
32                         binname=$x.$y.out
33                         g++-4.4 -o $binname -std=c++0x -ftemplate-depth-10000  \
34                             -DTOTAL_WIDTH=$TOTAL_WIDTH   \
35                             -DTOTAL_HEIGHT=$TOTAL_HEIGHT \
36                             -DTILE_WIDTH=$TILE_WIDTH     \
37                             -DTILE_HEIGHT=$TILE_HEIGHT   \
38                             -DTOTAL_X=$x -DTOTAL_Y=$y    \
39                         main.cc && ./$binname > supertrace/$y/$x.ppm
40                         rm $binname
41                 done;
42                 pushd supertrace/$y/
43                 convert +append $(ls *.ppm | sort -n) ../$y.ppm
44                 popd
45         done;
46 fi;
47 if [ $do_join = "yes" ] ; then
48         echo "joining..."
49         pushd supertrace
50         convert -append $(ls *.ppm | sort -n) final.ppm
51         popd
52 fi;