Rewrite tests for hex_bytes/2.

Rewrite tests for hex_bytes/2.

:- include(misc(common)).

:- begin_tests('bson_bits:float_bytes/2').

test('float, bad zero', [true(Got \== Expected)]) :-
    Expected = 0, % Not a float.
    bson_bits:float_bytes(Expected, Bytes),
    bson_bits:float_bytes(Got,      Bytes).

test('float, zero', [true(Got == Expected)]) :-
    Expected = 0.0,
    bson_bits:float_bytes(Expected, Bytes),
    bson_bits:float_bytes(Got,      Bytes).

test('float, -5.05', [true(Got == Expected)]) :-
    Expected = -5.05,
    bson_bits:float_bytes(Expected, Bytes),
    bson_bits:float_bytes(Got,      Bytes).

test('float, 5.05', [true(Got == Expected)]) :-
    Expected = 5.05,
    bson_bits:float_bytes(Expected, Bytes),
    bson_bits:float_bytes(Got,      Bytes).

test('float, pi', [true(Got == Expected)]) :-
    Expected is 3.14159,
    bson_bits:float_bytes(Expected, Bytes),
    bson_bits:float_bytes(Got,      Bytes).

:- end_tests('bson_bits:float_bytes/2').

:- begin_tests('bson_bits:integer_bytes/4').

test('32-bit big-endian, zero', [true(Got == Expected)]) :-
    Expected = 0,
    bson_bits:integer_bytes(Expected, 4, big, Bytes),
    bson_bits:integer_bytes(Got,      4, big, Bytes).

test('32-bit big-endian, -1', [true(Got == Expected)]) :-
    Expected = -1,
    bson_bits:integer_bytes(Expected, 4, big, Bytes),
    bson_bits:integer_bytes(Got,      4, big, Bytes).

test('32-bit big-endian, 1', [true(Got == Expected)]) :-
    Expected = 1,
    bson_bits:integer_bytes(Expected, 4, big, Bytes),
    bson_bits:integer_bytes(Got,      4, big, Bytes).

test('32-bit big-endian, verify endian', [true(Got == Expected)]) :-
    Expected = [0,0,0,1],
    bson_bits:integer_bytes(1, 4, big, Got).

test('32-bit big-endian, min', [true(Got == Expected)]) :-
    Expected = -2147483648,
    bson_bits:integer_bytes(Expected, 4, big, Bytes),
    bson_bits:integer_bytes(Got,      4, big, Bytes).

test('32-bit big-endian, min-1', [true(Got \== Expected)]) :-
    Expected = -2147483649, % Too low.
    bson_bits:integer_bytes(Expected, 4, big, Bytes),
    bson_bits:integer_bytes(Got,      4, big, Bytes).

test('32-bit big-endian, max', [true(Got == Expected)]) :-
    Expected = 2147483647,
    bson_bits:integer_bytes(Expected, 4, big, Bytes),
    bson_bits:integer_bytes(Got,      4, big, Bytes).

test('32-bit big-endian, max+1', [true(Got \== Expected)]) :-
    Expected = 2147483648, % Too high.
    bson_bits:integer_bytes(Expected, 4, big, Bytes),
    bson_bits:integer_bytes(Got,      4, big, Bytes).

% ------------------------------------

test('32-bit little-endian, zero', [true(Got == Expected)]) :-
    Expected = 0,
    bson_bits:integer_bytes(Expected, 4, little, Bytes),
    bson_bits:integer_bytes(Got,      4, little, Bytes).

test('32-bit little-endian, -1', [true(Got == Expected)]) :-
    Expected = -1,
    bson_bits:integer_bytes(Expected, 4, little, Bytes),
    bson_bits:integer_bytes(Got,      4, little, Bytes).

test('32-bit little-endian, 1', [true(Got == Expected)]) :-
    Expected = 1,
    bson_bits:integer_bytes(Expected, 4, little, Bytes),
    bson_bits:integer_bytes(Got,      4, little, Bytes).

test('32-bit little-endian, verify endian', [true(Got == Expected)]) :-
    Expected = [1,0,0,0],
    bson_bits:integer_bytes(1, 4, little, Got).

test('32-bit little-endian, min', [true(Got == Expected)]) :-
    Expected = -2147483648,
    bson_bits:integer_bytes(Expected, 4, little, Bytes),
    bson_bits:integer_bytes(Got,      4, little, Bytes).

test('32-bit little-endian, min-1', [true(Got \== Expected)]) :-
    Expected = -2147483649, % Too low.
    bson_bits:integer_bytes(Expected, 4, little, Bytes),
    bson_bits:integer_bytes(Got,      4, little, Bytes).

test('32-bit little-endian, max', [true(Got == Expected)]) :-
    Expected = 2147483647,
    bson_bits:integer_bytes(Expected, 4, little, Bytes),
    bson_bits:integer_bytes(Got,      4, little, Bytes).

test('32-bit little-endian, max+1', [true(Got \== Expected)]) :-
    Expected = 2147483648, % Too high.
    bson_bits:integer_bytes(Expected, 4, little, Bytes),
    bson_bits:integer_bytes(Got,      4, little, Bytes).

% ------------------------------------

test('64-bit big-endian, zero', [true(Got == Expected)]) :-
    Expected = 0,
    bson_bits:integer_bytes(Expected, 8, big, Bytes),
    bson_bits:integer_bytes(Got,      8, big, Bytes).

test('64-bit big-endian, -1', [true(Got == Expected)]) :-
    Expected = -1,
    bson_bits:integer_bytes(Expected, 8, big, Bytes),
    bson_bits:integer_bytes(Got,      8, big, Bytes).

test('64-bit big-endian, 1', [true(Got == Expected)]) :-
    Expected = 1,
    bson_bits:integer_bytes(Expected, 8, big, Bytes),
    bson_bits:integer_bytes(Got,      8, big, Bytes).

test('64-bit big-endian, verify endian', [true(Got == Expected)]) :-
    Expected = [0,0,0,0,0,0,0,1],
    bson_bits:integer_bytes(1, 8, big, Got).

test('64-bit big-endian, min', [true(Got == Expected)]) :-
    Expected = -9223372036854775808,
    bson_bits:integer_bytes(Expected, 8, big, Bytes),
    bson_bits:integer_bytes(Got,      8, big, Bytes).

test('64-bit big-endian, min-1', [true(Got \== Expected)]) :-
    Expected = -9223372036854775809, % Too low.
    bson_bits:integer_bytes(Expected, 8, big, Bytes),
    bson_bits:integer_bytes(Got,      8, big, Bytes).

test('64-bit big-endian, max', [true(Got == Expected)]) :-
    Expected = 9223372036854775807,
    bson_bits:integer_bytes(Expected, 8, big, Bytes),
    bson_bits:integer_bytes(Got,      8, big, Bytes).

test('64-bit big-endian, max+1', [true(Got \== Expected)]) :-
    Expected = 9223372036854775808, % Too high.
    bson_bits:integer_bytes(Expected, 8, big, Bytes),
    bson_bits:integer_bytes(Got,      8, big, Bytes).

% ------------------------------------

test('64-bit little-endian, zero', [true(Got == Expected)]) :-
    Expected = 0,
    bson_bits:integer_bytes(Expected, 8, little, Bytes),
    bson_bits:integer_bytes(Got,      8, little, Bytes).

test('64-bit little-endian, -1', [true(Got == Expected)]) :-
    Expected = -1,
    bson_bits:integer_bytes(Expected, 8, little, Bytes),
    bson_bits:integer_bytes(Got,      8, little, Bytes).

test('64-bit little-endian, 1', [true(Got == Expected)]) :-
    Expected = 1,
    bson_bits:integer_bytes(Expected, 8, little, Bytes),
    bson_bits:integer_bytes(Got,      8, little, Bytes).

test('64-bit little-endian, verify endian', [true(Got == Expected)]) :-
    Expected = [1,0,0,0,0,0,0,0],
    bson_bits:integer_bytes(1, 8, little, Got).

test('64-bit little-endian, min', [true(Got == Expected)]) :-
    Expected = -9223372036854775808,
    bson_bits:integer_bytes(Expected, 8, little, Bytes),
    bson_bits:integer_bytes(Got,      8, little, Bytes).

test('64-bit little-endian, min-1', [true(Got \== Expected)]) :-
    Expected = -9223372036854775809, % Too low.
    bson_bits:integer_bytes(Expected, 8, little, Bytes),
    bson_bits:integer_bytes(Got,      8, little, Bytes).

test('64-bit little-endian, max', [true(Got == Expected)]) :-
    Expected = 9223372036854775807,
    bson_bits:integer_bytes(Expected, 8, little, Bytes),
    bson_bits:integer_bytes(Got,      8, little, Bytes).

test('64-bit little-endian, max+1', [true(Got \== Expected)]) :-
    Expected = 9223372036854775808, % Too high.
    bson_bits:integer_bytes(Expected, 8, little, Bytes),
    bson_bits:integer_bytes(Got,      8, little, Bytes).

:- end_tests('bson_bits:integer_bytes/4').

:- begin_tests('bson_bits:hex_bytes/2').

test('hex to bytes', [true(Got == Expected)]) :-
    Hex = '47cc6709',
    Expected = [0x47,0xcc,0x67,0x09],
    bson_bits:hex_bytes(Hex, Got).

test('bytes to hex', [true(Got == Expected)]) :-
    Bytes = [0x47,0xcc,0x67,0x09],
    Expected = '47cc6709',
    bson_bits:hex_bytes(Got, Bytes).

test('bytes to hex, odd length should fail', [fail]) :-
    HexOddLength = '47c',
    bson_bits:hex_bytes(HexOddLength, _Bytes).

:- end_tests('bson_bits:hex_bytes/2').

:- include(misc(common)).

:- begin_tests('bson_bits:float_bytes/2').

test('float, bad zero', [true(Got \== Expected)]) :-
    Expected = 0, % Not a float.
    bson_bits:float_bytes(Expected, Bytes),
    bson_bits:float_bytes(Got,      Bytes).

test('float, zero', [true(Got == Expected)]) :-
    Expected = 0.0,
    bson_bits:float_bytes(Expected, Bytes),
    bson_bits:float_bytes(Got,      Bytes).

test('float, -5.05', [true(Got == Expected)]) :-
    Expected = -5.05,
    bson_bits:float_bytes(Expected, Bytes),
    bson_bits:float_bytes(Got,      Bytes).

test('float, 5.05', [true(Got == Expected)]) :-
    Expected = 5.05,
    bson_bits:float_bytes(Expected, Bytes),
    bson_bits:float_bytes(Got,      Bytes).

test('float, pi', [true(Got == Expected)]) :-
    Expected is 3.14159,
    bson_bits:float_bytes(Expected, Bytes),
    bson_bits:float_bytes(Got,      Bytes).

:- end_tests('bson_bits:float_bytes/2').

:- begin_tests('bson_bits:integer_bytes/4').

test('32-bit big-endian, zero', [true(Got == Expected)]) :-
    Expected = 0,
    bson_bits:integer_bytes(Expected, 4, big, Bytes),
    bson_bits:integer_bytes(Got,      4, big, Bytes).

test('32-bit big-endian, -1', [true(Got == Expected)]) :-
    Expected = -1,
    bson_bits:integer_bytes(Expected, 4, big, Bytes),
    bson_bits:integer_bytes(Got,      4, big, Bytes).

test('32-bit big-endian, 1', [true(Got == Expected)]) :-
    Expected = 1,
    bson_bits:integer_bytes(Expected, 4, big, Bytes),
    bson_bits:integer_bytes(Got,      4, big, Bytes).

test('32-bit big-endian, verify endian', [true(Got == Expected)]) :-
    Expected = [0,0,0,1],
    bson_bits:integer_bytes(1, 4, big, Got).

test('32-bit big-endian, min', [true(Got == Expected)]) :-
    Expected = -2147483648,
    bson_bits:integer_bytes(Expected, 4, big, Bytes),
    bson_bits:integer_bytes(Got,      4, big, Bytes).

test('32-bit big-endian, min-1', [true(Got \== Expected)]) :-
    Expected = -2147483649, % Too low.
    bson_bits:integer_bytes(Expected, 4, big, Bytes),
    bson_bits:integer_bytes(Got,      4, big, Bytes).

test('32-bit big-endian, max', [true(Got == Expected)]) :-
    Expected = 2147483647,
    bson_bits:integer_bytes(Expected, 4, big, Bytes),
    bson_bits:integer_bytes(Got,      4, big, Bytes).

test('32-bit big-endian, max+1', [true(Got \== Expected)]) :-
    Expected = 2147483648, % Too high.
    bson_bits:integer_bytes(Expected, 4, big, Bytes),
    bson_bits:integer_bytes(Got,      4, big, Bytes).

% ------------------------------------

test('32-bit little-endian, zero', [true(Got == Expected)]) :-
    Expected = 0,
    bson_bits:integer_bytes(Expected, 4, little, Bytes),
    bson_bits:integer_bytes(Got,      4, little, Bytes).

test('32-bit little-endian, -1', [true(Got == Expected)]) :-
    Expected = -1,
    bson_bits:integer_bytes(Expected, 4, little, Bytes),
    bson_bits:integer_bytes(Got,      4, little, Bytes).

test('32-bit little-endian, 1', [true(Got == Expected)]) :-
    Expected = 1,
    bson_bits:integer_bytes(Expected, 4, little, Bytes),
    bson_bits:integer_bytes(Got,      4, little, Bytes).

test('32-bit little-endian, verify endian', [true(Got == Expected)]) :-
    Expected = [1,0,0,0],
    bson_bits:integer_bytes(1, 4, little, Got).

test('32-bit little-endian, min', [true(Got == Expected)]) :-
    Expected = -2147483648,
    bson_bits:integer_bytes(Expected, 4, little, Bytes),
    bson_bits:integer_bytes(Got,      4, little, Bytes).

test('32-bit little-endian, min-1', [true(Got \== Expected)]) :-
    Expected = -2147483649, % Too low.
    bson_bits:integer_bytes(Expected, 4, little, Bytes),
    bson_bits:integer_bytes(Got,      4, little, Bytes).

test('32-bit little-endian, max', [true(Got == Expected)]) :-
    Expected = 2147483647,
    bson_bits:integer_bytes(Expected, 4, little, Bytes),
    bson_bits:integer_bytes(Got,      4, little, Bytes).

test('32-bit little-endian, max+1', [true(Got \== Expected)]) :-
    Expected = 2147483648, % Too high.
    bson_bits:integer_bytes(Expected, 4, little, Bytes),
    bson_bits:integer_bytes(Got,      4, little, Bytes).

% ------------------------------------

test('64-bit big-endian, zero', [true(Got == Expected)]) :-
    Expected = 0,
    bson_bits:integer_bytes(Expected, 8, big, Bytes),
    bson_bits:integer_bytes(Got,      8, big, Bytes).

test('64-bit big-endian, -1', [true(Got == Expected)]) :-
    Expected = -1,
    bson_bits:integer_bytes(Expected, 8, big, Bytes),
    bson_bits:integer_bytes(Got,      8, big, Bytes).

test('64-bit big-endian, 1', [true(Got == Expected)]) :-
    Expected = 1,
    bson_bits:integer_bytes(Expected, 8, big, Bytes),
    bson_bits:integer_bytes(Got,      8, big, Bytes).

test('64-bit big-endian, verify endian', [true(Got == Expected)]) :-
    Expected = [0,0,0,0,0,0,0,1],
    bson_bits:integer_bytes(1, 8, big, Got).

test('64-bit big-endian, min', [true(Got == Expected)]) :-
    Expected = -9223372036854775808,
    bson_bits:integer_bytes(Expected, 8, big, Bytes),
    bson_bits:integer_bytes(Got,      8, big, Bytes).

test('64-bit big-endian, min-1', [true(Got \== Expected)]) :-
    Expected = -9223372036854775809, % Too low.
    bson_bits:integer_bytes(Expected, 8, big, Bytes),
    bson_bits:integer_bytes(Got,      8, big, Bytes).

test('64-bit big-endian, max', [true(Got == Expected)]) :-
    Expected = 9223372036854775807,
    bson_bits:integer_bytes(Expected, 8, big, Bytes),
    bson_bits:integer_bytes(Got,      8, big, Bytes).

test('64-bit big-endian, max+1', [true(Got \== Expected)]) :-
    Expected = 9223372036854775808, % Too high.
    bson_bits:integer_bytes(Expected, 8, big, Bytes),
    bson_bits:integer_bytes(Got,      8, big, Bytes).

% ------------------------------------

test('64-bit little-endian, zero', [true(Got == Expected)]) :-
    Expected = 0,
    bson_bits:integer_bytes(Expected, 8, little, Bytes),
    bson_bits:integer_bytes(Got,      8, little, Bytes).

test('64-bit little-endian, -1', [true(Got == Expected)]) :-
    Expected = -1,
    bson_bits:integer_bytes(Expected, 8, little, Bytes),
    bson_bits:integer_bytes(Got,      8, little, Bytes).

test('64-bit little-endian, 1', [true(Got == Expected)]) :-
    Expected = 1,
    bson_bits:integer_bytes(Expected, 8, little, Bytes),
    bson_bits:integer_bytes(Got,      8, little, Bytes).

test('64-bit little-endian, verify endian', [true(Got == Expected)]) :-
    Expected = [1,0,0,0,0,0,0,0],
    bson_bits:integer_bytes(1, 8, little, Got).

test('64-bit little-endian, min', [true(Got == Expected)]) :-
    Expected = -9223372036854775808,
    bson_bits:integer_bytes(Expected, 8, little, Bytes),
    bson_bits:integer_bytes(Got,      8, little, Bytes).

test('64-bit little-endian, min-1', [true(Got \== Expected)]) :-
    Expected = -9223372036854775809, % Too low.
    bson_bits:integer_bytes(Expected, 8, little, Bytes),
    bson_bits:integer_bytes(Got,      8, little, Bytes).

test('64-bit little-endian, max', [true(Got == Expected)]) :-
    Expected = 9223372036854775807,
    bson_bits:integer_bytes(Expected, 8, little, Bytes),
    bson_bits:integer_bytes(Got,      8, little, Bytes).

test('64-bit little-endian, max+1', [true(Got \== Expected)]) :-
    Expected = 9223372036854775808, % Too high.
    bson_bits:integer_bytes(Expected, 8, little, Bytes),
    bson_bits:integer_bytes(Got,      8, little, Bytes).

:- end_tests('bson_bits:integer_bytes/4').

:- begin_tests('bson_bits:hex_bytes/2').

test('hexatom bytes', [true(Got == Expected)]) :-
    Expected = '47cc67093475061e3d95369d',
    bson_bits:hex_bytes(Expected, Bytes),
    bson_bits:hex_bytes(Got,      Bytes).

:- end_tests('bson_bits:hex_bytes/2').


Improved separation

Improved separation

between dynamic and static part.

####################################################################################
# Gnuplot 4.6 script for plotting multiple groups of 3 bars in a barchart.
# This part is dynamic and can be altered to influence the look of the graph.
####################################################################################

### plot setup
#set terminal pngcairo transparent enhanced font "inconsolata,10" fontscale 1.0 size 500, 350
set terminal pngcairo size 800,600 enhanced font 'Liberation Mono,10' background "#002b36"
set output 'test.png'
COLORS = "red green gray"
STARTCOL = 2
ENDCOL = 4

### titles and labels
set title "income\_vs\_expenses\n(Extra info here?)"
set xlabel "Year"
set xlabel  offset character 0, -2, 0 font "" textcolor lt -1 norotate
set ylabel "Value (EUR)"

####################################################################################
# Gnuplot 4.6 script for plotting multiple groups of 3 bars in a barchart.
# This part is static and can not be altered.
####################################################################################

### legend
set key bmargin center horizontal Left reverse noenhanced autotitles columnhead nobox

### main code
GAPSIZE = 5
NCOL = ENDCOL-STARTCOL+1
BOXWIDTH = 1./(GAPSIZE+NCOL)

### barchart layout - axis + grid
#set border 3 front linetype -1 linewidth 1.000
set style fill solid 1.00 border lt -1
set boxwidth BOXWIDTH absolute
set grid nopolar
set grid noxtics nomxtics ytics nomytics noztics nomztics \
 nox2tics nomx2tics noy2tics nomy2tics nocbtics nomcbtics
set grid layerdefault linetype 0 linewidth 1.000,  linetype 0 linewidth 1.000
set xzeroaxis linetype 0 linewidth 1.000
set yzeroaxis linetype 0 linewidth 1.000
set zzeroaxis linetype 0 linewidth 1.000

### Set tics and histograms
# Note: I can not use GAPSIZE below, for some reason... hardcoded 4 is used instead
set style histogram clustered gap 5 title offset character 2, 0.25, 0
set datafile missing '-'
set style data histograms
set xtics border in scale 0,0 nomirror rotate by -45  offset character 0, 0, 0 autojustify
set xtics  norangelimit font ",8"
set xtics ()
set ytics border in scale 0,0 mirror norotate  offset character 0, 0, 0 autojustify
set ztics border in scale 0,0 nomirror norotate  offset character 0, 0, 0 autojustify
set cbtics border in scale 0,0 mirror norotate  offset character 0, 0, 0 autojustify
set rtics axis in scale 0,0 nomirror norotate  offset character 0, 0, 0 autojustify

#x = 0.0
#i = 23
### plotting
plot for [COL=STARTCOL:ENDCOL] 'test.dat' u COL:xtic(1) w histogram title columnheader(COL) lc rgb word(COLORS, COL), \
    for [COL=STARTCOL:ENDCOL] 'test.dat' u (column(0)+BOXWIDTH*(COL-STARTCOL+GAPSIZE/2+1)-0.5):COL:COL notitle w labels

####################################################################################
# Gnuplot 4.6 script for plotting multiple groups of 3 bars in a barchart.
####################################################################################

### plot setup
#set terminal pngcairo transparent enhanced font "inconsolata,10" fontscale 1.0 size 500, 350
set terminal pngcairo size 800,600 enhanced font 'Liberation Mono,10' background "#002b36"
set output 'test.png'
COLORS = "red green gray"
STARTCOL=2
ENDCOL=4
GAPSIZE=5

NCOL=ENDCOL-STARTCOL+1
BOXWIDTH=1./(GAPSIZE+NCOL)

### legend
set key bmargin center horizontal Left reverse noenhanced autotitles columnhead nobox

### barchart layout - axis + grid
#set border 3 front linetype -1 linewidth 1.000
set boxwidth BOXWIDTH absolute
set style fill solid 1.00 border lt -1
set grid nopolar
set grid noxtics nomxtics ytics nomytics noztics nomztics \
 nox2tics nomx2tics noy2tics nomy2tics nocbtics nomcbtics
set grid layerdefault linetype 0 linewidth 1.000,  linetype 0 linewidth 1.000
set xzeroaxis linetype 0 linewidth 1.000
set yzeroaxis linetype 0 linewidth 1.000
set zzeroaxis linetype 0 linewidth 1.000

### Set tics and histograms
set style histogram clustered gap 4 title  offset character 2, 0.25, 0
set datafile missing '-'
set style data histograms
set xtics border in scale 0,0 nomirror rotate by -45  offset character 0, 0, 0 autojustify
set xtics  norangelimit font ",8"
set xtics ()
set ytics border in scale 0,0 mirror norotate  offset character 0, 0, 0 autojustify
set ztics border in scale 0,0 nomirror norotate  offset character 0, 0, 0 autojustify
set cbtics border in scale 0,0 mirror norotate  offset character 0, 0, 0 autojustify
set rtics axis in scale 0,0 nomirror norotate  offset character 0, 0, 0 autojustify

### titles and labels
set title "income\_vs\_expenses\n(Extra info here?)"
#set xlabel "(Note: )"
set xlabel  offset character 0, -2, 0 font "" textcolor lt -1 norotate
set ylabel "Value (EUR)"

#x = 0.0
#i = 23
### plotting
plot for [COL=STARTCOL:ENDCOL] 'test.dat' u COL:xtic(1) w histogram title columnheader(COL) lc rgb word(COLORS, COL), \
    for [COL=STARTCOL:ENDCOL] 'test.dat' u (column(0)+BOXWIDTH*(COL-STARTCOL+GAPSIZE/2+1)-0.5):COL:COL notitle w labels


Modify gnuplot script, rearrange scales and text color

reset
set ylabel 'time(sec)'
set style fill solid
set title 'perfomance comparison'
set term png enhanced font 'Verdana,10'
set output 'runtime1.png'

plot [:][:0.0005]'output.txt' using 2:xtic(1) with histogram title 'original', \
'' using 3:xtic(1) with histogram title 'optimized'  , \
'' using 4:xtic(1) with histogram title 'B+ tree' , \
'' using 5:xtic(1) with histogram title 'B+ tree bulk' , \
'' using ($0+0.1):(0.0001):2 with labels title ' ' textcolor lt 1, \
'' using ($0+0.1):(0.00012):3 with labels title ' ' textcolor lt 2, \
'' using ($0+0.1):(0.00014):4 with labels title ' ' textcolor lt 3, \
'' using ($0+0.1):(0.00016):5 with labels title ' ' textcolor lt 4, \

reset
set ylabel 'time(sec)'
set style fill solid
set title 'perfomance comparison'
set term png enhanced font 'Verdana,10'
set output 'runtime.png'

plot [:][:80]'output.txt' using 2:xtic(1) with histogram title 'original', \
'' using ($0-0.2):($2+4):2 with labels title ' ', \
'' using 3:xtic(1) with histogram title 'optimized'  , \
'' using ($0):($3+1):3 with labels title ' ', \
'' using 4:xtic(1) with histogram title 'B+ tree' , \
'' using ($0+0.35):($4+3):4 with labels title ' ', \
'' using 5:xtic(1) with histogram title 'B+ tree with bulk loading' , \
'' using ($0+0.45):($5+5):5 with labels title ' ', \


better ytics interval

better ytics interval

# Tested with gnuplot 4.6 patchlevel 6

FN_IN = system("echo $FN_IN")
FN_OUT = system("echo $FN_OUT")

# Get min and max values
set terminal unknown
set xdata time
set timefmt "%y%m%d-%H%M%S"
set format x "'%y"

plot FN_IN u 1:($2/1000000) w fsteps, \
FN_IN u 1:($4+$5) w lines axes x1y2

X_MIN=GPVAL_DATA_X_MIN
X_MAX=GPVAL_DATA_X_MAX
Y_MIN=GPVAL_DATA_Y_MIN
Y_MAX=GPVAL_DATA_Y_MAX
Y2_MIN=GPVAL_DATA_Y2_MIN
Y2_MAX=GPVAL_DATA_Y2_MAX

set terminal pdfcairo enhanced size 3in, 2in
set output FN_OUT

#set tmargin at screen 0.975
#set bmargin at screen 0.152
#set lmargin at screen 0.185
#set rmargin at screen 0.940

set xlabel "Time" offset 0,0.3
set ylabel "Storage size (MB)" offset 1.3,0
set y2label "Storage cost ($)"

set border (1 + 2 + 8) back lc rgb "#808080"
set xtics nomirror scale 0.5,0 tc rgb "#808080" #autofreq 0,(365.25*24*3600)

# Not sure if this is what I wanted. Not important.
x1(a)=(10**floor(log10(a)))
x2(a)=floor(a/x1(a))*x1(a)
x3(a)=floor(a/x1(a)/2)*x1(a)*2
yTicsStep(a, b)=(x2(a/b) == 1 ? x2(a/b) : x3(a/b))

set print "-"
print (sprintf("Y_MAX: %f", Y_MAX))
print (sprintf("Y2_MAX: %f", Y2_MAX))
print (sprintf("yTicsStep(Y_MAX, 2)=%f", yTicsStep(Y_MAX, 2)))
print (sprintf("yTicsStep(Y2_MAX, 2)=%f", yTicsStep(Y2_MAX, 2)))
set ytics  nomirror scale 0.5,0 tc rgb "#808080" autofreq 0,yTicsStep(Y_MAX, 2)
set y2tics nomirror scale 0.5,0 tc rgb "#808080" autofreq 0,yTicsStep(Y2_MAX, 2)
set tics front

set xrange [X_MIN:X_MAX]
set yrange [Y_MIN:Y_MAX]
set y2range [Y2_MIN:Y2_MAX]

set key top left

set pointsize 0.1

plot \
FN_IN u 1:($2/1000000) w steps lc rgb "red" t "Hot", \
FN_IN u 1:($3/1000000) w steps lc rgb "blue" t "Cold", \
FN_IN u 1:4 w linespoints axes x1y2 pt 7 lc rgb "red" not, \
FN_IN u 1:5 w linespoints axes x1y2 pt 7 lc rgb "blue" not, \
FN_IN u 1:($4+$5) w linespoints axes x1y2 pt 7 lc rgb "black" not

#FN_IN u 1:($2/1000000) w fillsteps fs solid 0.15 noborder not, \

# Tested with gnuplot 4.6 patchlevel 6

FN_IN = system("echo $FN_IN")
FN_OUT = system("echo $FN_OUT")

# Get min and max values
set terminal unknown
set xdata time
set timefmt "%y%m%d-%H%M%S"
set format x "'%y"

plot FN_IN u 1:($2/1000000) w fsteps, \
FN_IN u 1:($4+$5) w lines axes x1y2

X_MIN=GPVAL_DATA_X_MIN
X_MAX=GPVAL_DATA_X_MAX
Y_MIN=GPVAL_DATA_Y_MIN
Y_MAX=GPVAL_DATA_Y_MAX
Y2_MIN=GPVAL_DATA_Y2_MIN
Y2_MAX=GPVAL_DATA_Y2_MAX

#set print "-"
#print (sprintf("Y_MAX: %f", Y_MAX))
#print (sprintf("Y2_MAX: %f", Y2_MAX))

set terminal pdfcairo enhanced size 3in, 2in
set output FN_OUT

#set tmargin at screen 0.975
#set bmargin at screen 0.152
#set lmargin at screen 0.185
#set rmargin at screen 0.940

set xlabel "Time" offset 0,0.3
set ylabel "Storage size (MB)" offset 1.3,0
set y2label "Storage cost ($)"

set border (1 + 2 + 8) back lc rgb "#808080"
set xtics nomirror scale 0.5,0 tc rgb "#808080" #autofreq 0,(365.25*24*3600)

# Not sure if this is what I wanted. Not important.
x1(a)=(10**floor(log10(a)))
x2(a)=floor(a/x1(a)/2)*x1(a)*2
yTicsStep(a, b)=x2(a/b)

#print (sprintf("yTicsStep(Y_MAX, 2)=%f", yTicsStep(Y_MAX, 2)))
#print (sprintf("yTicsStep(Y2_MAX, 2)=%f", yTicsStep(Y2_MAX, 2)))
set ytics  nomirror scale 0.5,0 tc rgb "#808080" autofreq 0,yTicsStep(Y_MAX, 2)
set y2tics nomirror scale 0.5,0 tc rgb "#808080" autofreq 0,yTicsStep(Y2_MAX, 2)
set tics front

set xrange [X_MIN:X_MAX]
set yrange [Y_MIN:Y_MAX]
set y2range [Y2_MIN:Y2_MAX]

set key top left

set pointsize 0.1

plot \
FN_IN u 1:($2/1000000) w steps lc rgb "red" t "Hot", \
FN_IN u 1:($3/1000000) w steps lc rgb "blue" t "Cold", \
FN_IN u 1:4 w linespoints axes x1y2 pt 7 lc rgb "red" not, \
FN_IN u 1:5 w linespoints axes x1y2 pt 7 lc rgb "blue" not, \
FN_IN u 1:($4+$5) w linespoints axes x1y2 pt 7 lc rgb "black" not

#FN_IN u 1:($2/1000000) w fillsteps fs solid 0.15 noborder not, \


Charts.

Charts.

reset # do not use any previous settings
set title "F1 score - Keyphrase extraction - Projection of POS sequences over the development data" # title
set xlabel "Min ocurrence of each POS sequence" # x-axis label
set ylabel "F1 score" # y-axis label
set term png size 1200, 700 font "Helvetica" 9
set size ratio 0.55 #plot dimensions
set output "plot_f1score.png" # name of image file
set grid y
set xtics rotate
set ytics 0.02
set yrange [0.04:0.50] writeback
set key right top
set style data linespoints # set default way of data plotting
set pointsize 1.5 # increase size of points on the line

plot "dev_seq_projection_filter_by_count.dat" using 1:5:xtic(2) title "Simple projection", \
"dev_seq_projection_crf_train_with_projections_simple.dat" using 1:5 title "CRF/POSseq/Simple", \
"dev_seq_projection_crf_train_with_projections_largest.dat" using 1:5 title "CRF/POSseq/Largest", \
"dev_seq_projection_crf_train_with_projections_by_class.dat" using 1:5 title "CRF/POSseq/Simple/ByType", \
"dev_seq_projection_crf_train_with_projections_largest_by_class.dat" using 1:5 title "CRF/POSseq/Largest/ByType", \
"dev_seq_projection_crf_train_with_projections_largest_over_results_svm2c_fulltext.dat" using 1:5 title "CRF/POSseq/Largest/SVM2cFullText", \
"dev_seq_projection_crf_train_with_projections_without_types.dat" using 1:5 title "CRF/POSseq/Simple/WithoutType", \
"dev_seq_projection_crf_train_with_projections_largest_without_types.dat" using 1:5 title "CRF/POSseq/Largest/WithoutType", \
0.291463414634 title "CRF"

reset # do not use any previous settings
set title "Precision - Keyphrase extraction - Projection of POS sequences over the development data" # title
set xlabel "Min ocurrence of each POS sequence" # x-axis label
set ylabel "Precision" # y-axis label
set term png size 1200, 700 font "Helvetica" 9
set size ratio 0.55 #plot dimensions
set output "plot_precision.png" # name of image file
set grid y
set xtics rotate
set ytics 0.02
set yrange [0.04:0.50] writeback
set key right top
set style data linespoints # set default way of data plotting
set pointsize 1.5 # increase size of points on the line

plot "dev_seq_projection_filter_by_count.dat" using 1:3:xtic(2) title "Simple projection", \
"dev_seq_projection_crf_train_with_projections_simple.dat" using 1:3 title "CRF/POSseq/Simple", \
"dev_seq_projection_crf_train_with_projections_largest.dat" using 1:3 title "CRF/POSseq/Largest", \
"dev_seq_projection_crf_train_with_projections_by_class.dat" using 1:3 title "CRF/POSseq/Simple/ByType", \
"dev_seq_projection_crf_train_with_projections_largest_by_class.dat" using 1:3 title "CRF/POSseq/Largest/ByType", \
"dev_seq_projection_crf_train_with_projections_largest_over_results_svm2c_fulltext.dat" using 1:3 title "CRF/POSseq/Largest/SVM2cFullText", \
"dev_seq_projection_crf_train_with_projections_without_types.dat" using 1:3 title "CRF/POSseq/Simple/WithoutType", \
"dev_seq_projection_crf_train_with_projections_largest_without_types.dat" using 1:3 title "CRF/POSseq/Largest/WithoutType", \
0.491769547325 title "CRF"

reset # do not use any previous settings
set title "Recall - Keyphrase extraction - Projection of POS sequences over the development data" # title
set xlabel "Min ocurrence of each POS sequence" # x-axis label
set ylabel "Recall" # y-axis label
set term png size 1200, 700 font "Helvetica" 9
set size ratio 0.55 #plot dimensions
set output "plot_recall.png" # name of image file
set grid y
set xtics rotate
set ytics 0.05
set yrange [0.05:1.0] writeback
set key right top
set style data linespoints # set default way of data plotting
set pointsize 1.5 # increase size of points on the line

plot "dev_seq_projection_filter_by_count.dat" using 1:4:xtic(2) title "Simple projection", \
"dev_seq_projection_crf_train_with_projections_simple.dat" using 1:4 title "CRF/POSseq/Simple", \
"dev_seq_projection_crf_train_with_projections_largest.dat" using 1:4 title "CRF/POSseq/Largest", \
"dev_seq_projection_crf_train_with_projections_by_class.dat" using 1:4 title "CRF/POSseq/Simple/ByType", \
"dev_seq_projection_crf_train_with_projections_largest_by_class.dat" using 1:4 title "CRF/POSseq/Largest/ByType", \
"dev_seq_projection_crf_train_with_projections_largest_over_results_svm2c_fulltext.dat" using 1:4 title "CRF/POSseq/Largest/SVM2cFullText", \
"dev_seq_projection_crf_train_with_projections_without_types.dat" using 1:4 title "CRF/POSseq/Simple/WithoutType", \
"dev_seq_projection_crf_train_with_projections_largest_without_types.dat" using 1:4 title "CRF/POSseq/Largest/WithoutType", \
0.207105719237 title "CRF"

reset # do not use any previous settings
set title "F1 score - Keyphrase extraction - Projection of POS sequences over the development data" # title
set xlabel "Min ocurrence of each POS sequence" # x-axis label
set ylabel "F1 score" # y-axis label
set term png size 1200, 700 font "Helvetica" 9
set size ratio 0.55 #plot dimensions
set output "plot_f1score.png" # name of image file
set grid y
set xtics rotate
set ytics 0.01
set yrange [0.04:0.35] writeback
set key right top
set style data linespoints # set default way of data plotting
set pointsize 1.5 # increase size of points on the line

plot "dev_seq_projection_filter_by_count.dat" using 1:5:xtic(2) title "Simple projection", \
"dev_seq_projection_filter_by_count_inkeywords_not_indomains.dat" using 1:5 title "Keywords/DiscartingIfInOtherDomain", \
"dev_seq_projection_svm_only_anntokens_four_classes.dat" using 1:5 title "SVM/4c/AnnotatedTokens", \
"dev_seq_projection_svm_only_anntokens_four_classes_cossimgt0.01.dat" using 1:5 title "SVM/4c/AnnotatedTokens/Sim>0.01", \
"dev_seq_projection_svm4c_not-none.and.maxsimgt0_or_maxsimeq0.dat" using 1:5 title "SVM/4c/AnnotatedTokens/NotNoneOrNotDecision", \
"dev_seq_projection_svm_only_anntokens_four_classes_morefeatures.dat" using 1:5 title "SVM/4c/AnnotatedTokens/MoreFeatures", \
"dev_seq_projection_svm_only_anntokens_two_classes.dat" using 1:5 title "SVM/2c/AnnotatedTokens", \
"dev_seq_projection_svm_only_anntokens_two_classes_cossimgt0.005.dat" using 1:5 title "SVM/2c/AnnotatedTokens/Sim>0.005", \
"dev_seq_projection_svm_only_anntokens_two_classes_cossimgt0.01.dat" using 1:5 title "SVM/2c/AnnotatedTokens/Sim>0.01", \
"dev_seq_projection_svm_shorttext_two_classes.dat" using 1:5 title "SVM/2c/ShortText", \
"dev_seq_projection_svm_fulltext_two_classes.dat" using 1:5 title "SVM/2c/FullText"

reset # do not use any previous settings
set title "Precision - Keyphrase extraction - Projection of POS sequences over the development data" # title
set xlabel "Min ocurrence of each POS sequence" # x-axis label
set ylabel "Precision" # y-axis label
set term png size 1200, 700 font "Helvetica" 9
set size ratio 0.55 #plot dimensions
set output "plot_precision.png" # name of image file
set grid y
set xtics rotate
set ytics 0.01
set yrange [0.04:0.35] writeback
set key right top
set style data linespoints # set default way of data plotting
set pointsize 1.5 # increase size of points on the line
plot "dev_seq_projection_filter_by_count.dat" using 1:3:xtic(2) title "Simple projection", \
"dev_seq_projection_filter_by_count_inkeywords_not_indomains.dat" using 1:3 title "Keywords/DiscartingIfInOtherDomain", \
"dev_seq_projection_svm_only_anntokens_four_classes.dat" using 1:3 title "SVM/4c/AnnotatedTokens", \
"dev_seq_projection_svm_only_anntokens_four_classes_cossimgt0.01.dat" using 1:3 title "SVM/4c/AnnotatedTokens/Sim>0.01", \
"dev_seq_projection_svm4c_not-none.and.maxsimgt0_or_maxsimeq0.dat" using 1:3 title "SVM/4c/AnnotatedTokens/NotNoneOrNotDecision", \
"dev_seq_projection_svm_only_anntokens_four_classes_morefeatures.dat" using 1:3 title "SVM/4c/AnnotatedTokens/MoreFeatures", \
"dev_seq_projection_svm_only_anntokens_two_classes.dat" using 1:3 title "SVM/2c/AnnotatedTokens", \
"dev_seq_projection_svm_only_anntokens_two_classes_cossimgt0.005.dat" using 1:3 title "SVM/2c/AnnotatedTokens/Sim>0.005", \
"dev_seq_projection_svm_only_anntokens_two_classes_cossimgt0.01.dat" using 1:3 title "SVM/2c/AnnotatedTokens/Sim>0.01", \
"dev_seq_projection_svm_shorttext_two_classes.dat" using 1:3 title "SVM/2c/ShortText", \
"dev_seq_projection_svm_fulltext_two_classes.dat" using 1:3 title "SVM/2c/FullText"

reset # do not use any previous settings
set title "Recall - Keyphrase extraction - Projection of POS sequences over the development data" # title
set xlabel "Min ocurrence of each POS sequence" # x-axis label
set ylabel "Recall" # y-axis label
set term png size 1200, 700 font "Helvetica" 9
set size ratio 0.55 #plot dimensions
set output "plot_recall.png" # name of image file
set grid y
set xtics rotate
set ytics 0.05
set yrange [0.05:1.0] writeback
set key right top
set style data linespoints # set default way of data plotting
set pointsize 1.5 # increase size of points on the line

plot "dev_seq_projection_filter_by_count.dat" using 1:4:xtic(2) title "Simple projection", \
"dev_seq_projection_filter_by_count_inkeywords_not_indomains.dat" using 1:4 title "Keywords/DiscartingIfInOtherDomain", \
"dev_seq_projection_svm_only_anntokens_four_classes.dat" using 1:4 title "SVM/4c/AnnotatedTokens", \
"dev_seq_projection_svm_only_anntokens_four_classes_cossimgt0.01.dat" using 1:4 title "SVM/4c/AnnotatedTokens/Sim>0.01", \
"dev_seq_projection_svm4c_not-none.and.maxsimgt0_or_maxsimeq0.dat" using 1:4 title "SVM/4c/AnnotatedTokens/NotNoneOrNotDecision", \
"dev_seq_projection_svm_only_anntokens_four_classes_morefeatures.dat" using 1:4 title "SVM/4c/AnnotatedTokens/MoreFeatures", \
"dev_seq_projection_svm_only_anntokens_two_classes.dat" using 1:4 title "SVM/2c/AnnotatedTokens", \
"dev_seq_projection_svm_only_anntokens_two_classes_cossimgt0.005.dat" using 1:4 title "SVM/2c/AnnotatedTokens/Sim>0.005", \
"dev_seq_projection_svm_only_anntokens_two_classes_cossimgt0.01.dat" using 1:4 title "SVM/2c/AnnotatedTokens/Sim>0.01", \
"dev_seq_projection_svm_shorttext_two_classes.dat" using 1:4 title "SVM/2c/ShortText", \
"dev_seq_projection_svm_fulltext_two_classes.dat" using 1:4 title "SVM/2c/FullText"


add '-std=c++0x -DSTXXL_CXX0X' hint for g++-4.3

git-svn-id: 4e7379b20b57f8e3dde5a0b7363f233184647162@830 4e380d45-d1fd-0310-85a7-d18ec86df0ad

# This -*- Makefile -*- is intended for processing with GNU make.

TOPDIR	?= $(error TOPDIR not defined) # DO NOT CHANGE! This is set elsewhere.

# Change this file according to your paths.

# Instead of modifying this file, you could also set your modified variables
# in make.settings.local (needs to be created first).
-include $(TOPDIR)/make.settings.local

USE_BOOST	?= no	# set 'yes' to use Boost libraries or 'no' to not use Boost libraries
USE_LINUX	?= yes	# set 'yes' if you run Linux, 'no' otherwise
USE_MCSTL	?= no	# will be overriden from main Makefile
USE_ICPC	?= no	# will be overriden from main Makefile

STXXL_ROOT	?= $(HOME)/work/stxxl

ifeq ($(strip $(USE_ICPC)),yes)
COMPILER_ICPC	?= icpc
COMPILER	?= $(COMPILER_ICPC)
#ICPC_GCC	?= gcc-x.y    # override the gcc/g++ used to find headers and libraries
WARNINGS	?= -Wall -w1 -openmp-report0 -vec-report0
endif

ifeq ($(strip $(USE_MCSTL)),yes)
COMPILER_GCC	?= g++-4.2.3
LIBNAME		?= mcstxxl
# the root directory of your MCSTL installation
MCSTL_ROOT	?= $(HOME)/work/mcstl
endif

#BOOST_ROOT	?= /usr/local/boost-1.34.1

COMPILER_GCC	?= g++
COMPILER	?= $(COMPILER_GCC)
LINKER		?= $(COMPILER)
OPT		?= -O3 # compiler optimization level
WARNINGS	?= -W -Wall
DEBUG		?= # put here -g option to include the debug information into the binaries

LIBNAME		?= stxxl

# Hint: for g++-4.3 with c++0x support, enable the following:
#STXXL_SPECIFIC	+= -std=c++0x -DSTXXL_CXX0X

#### TROUBLESHOOTING
#
# For automatical checking of order of the output elements in
# the sorters: stxxl::stream::sort, stxxl::stream::merge_runs,
# stxxl::sort, and stxxl::ksort use
#
#STXXL_SPECIFIC	+= -DSTXXL_CHECK_ORDER_IN_SORTS
#
# If your program aborts with message "read/write: wrong parameter"
# or "Invalid argument"
# this could be that your kernel does not support direct I/O
# then try to set it off recompiling the libs and your code with option
#
#STXXL_SPECIFIC	+= -DSTXXL_DIRECT_IO_OFF
#
# But for the best performance it is strongly recommended
# to reconfigure the kernel for the support of the direct I/O.
#
# FIXME: documentation needed
#
#STXXL_SPECIFIC += -DSTXXL_DEBUGMON

#### You usually shouldn't need to change the sections below #####

#### STXXL OPTIONS ###############################################

# check, whether stxxl has been configured
ifeq (,$(strip $(wildcard $(STXXL_ROOT)/include/stxxl.h)))
$(warning *** WARNING: STXXL has not been configured correctly)
ifeq (,$(strip $(wildcard $(CURDIR)/make.settings.local)))
ifneq (,$(strip $(wildcard $(CURDIR)/include/stxxl.h)))
$(warning *** WARNING: trying autoconfiguration for STXXL_ROOT=$(CURDIR:$(HOME)%=$$(HOME)%))
$(warning *** WARNING: you did not have a make.settings.local file -- creating ...)
$(shell echo 'STXXL_ROOT	 = $(CURDIR:$(HOME)%=$$(HOME)%)' >> $(CURDIR)/make.settings.local)
MCSTL_ROOT	?= $(HOME)/work/mcstl
$(shell echo '#MCSTL_ROOT	 = $(MCSTL_ROOT:$(HOME)%=$$(HOME)%)' >> $(CURDIR)/make.settings.local)
$(shell echo '#COMPILER_GCC	 = g++-4.2.3' >> $(CURDIR)/make.settings.local)
$(shell echo '#COMPILER_ICPC	 = icpc' >> $(CURDIR)/make.settings.local)
$(error ERROR: Please check make.settings.local and try again)
endif
else
$(warning *** WARNING: Please check make.settings.local)
endif
$(error ERROR: could not find a STXXL installation in STXXL_ROOT=$(STXXL_ROOT))
endif

# in the top dir, check whether STXXL_ROOT points to ourselves
ifneq (,$(wildcard make.settings))
stat1	 = $(shell stat -L -c '%d:%i' ./)
stat2	 = $(shell stat -L -c '%d:%i' $(STXXL_ROOT)/)

ifneq ($(stat1),$(stat2))
$(error ERROR: STXXL_ROOT=$(STXXL_ROOT) points to a different STXXL installation)
endif
endif

PTHREAD_FLAG	?= -pthread

STXXL_SPECIFIC	+= \
	$(PTHREAD_FLAG) \
	$(CPPFLAGS_ARCH) \
	-DSORT_OPTIMAL_PREFETCHING \
	-DUSE_MALLOC_LOCK \
	-DCOUNT_WAIT_TIME \
	-I$(strip $(STXXL_ROOT))/include \
	-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE \
	$(POSIX_MEMALIGN) $(XOPEN_SOURCE)

STXXL_LDFLAGS	+= $(PTHREAD_FLAG)
STXXL_LDLIBS	+= -L$(strip $(STXXL_ROOT))/lib -l$(LIBNAME)

STXXL_LIBDEPS	+= $(strip $(STXXL_ROOT))/lib/lib$(LIBNAME).$(LIBEXT)

UNAME_M		:= $(shell uname -m)
CPPFLAGS_ARCH	+= $(CPPFLAGS_$(UNAME_M))
CPPFLAGS_i686	?= -march=i686

##################################################################

#### ICPC OPTIONS ################################################

ifeq ($(strip $(USE_ICPC)),yes)

OPENMPFLAG	?= -openmp

ICPC_CPPFLAGS	+= $(if $(ICPC_GCC),-gcc-name=$(strip $(ICPC_GCC)))
ICPC_LDFLAGS	+= $(if $(ICPC_GCC),-gcc-name=$(strip $(ICPC_GCC)))

STXXL_SPECIFIC	+= -include bits/intel_compatibility.h

endif

##################################################################

#### MCSTL OPTIONS ###############################################

ifeq ($(strip $(USE_MCSTL)),yes)

OPENMPFLAG	?= -fopenmp

ifeq (,$(strip $(wildcard $(strip $(MCSTL_ROOT))/c++/mcstl.h)))
$(error ERROR: could not find a MCSTL installation in MCSTL_ROOT=$(MCSTL_ROOT))
endif

MCSTL_CPPFLAGS		+= $(OPENMPFLAG) -D__MCSTL__ $(MCSTL_INCLUDES_PREPEND) -I$(MCSTL_ROOT)/c++
MCSTL_LDFLAGS		+= $(OPENMPFLAG)

MCSTL_INCLUDES_PREPEND	+= $(if $(findstring 4.3,$(COMPILER)),-I$(MCSTL_ROOT)/c++/mod_stl/gcc-4.3)

endif

##################################################################

#### BOOST OPTIONS ###############################################

BOOST_COMPILER_OPTIONS	 = \
	-DSTXXL_BOOST_TIMESTAMP \
	-DSTXXL_BOOST_CONFIG \
	-DSTXXL_BOOST_FILESYSTEM \
	-DSTXXL_BOOST_THREADS \
	-DSTXXL_BOOST_RANDOM \
	$(if $(strip $(BOOST_ROOT)),-I$(strip $(BOOST_ROOT)))

BOOST_LIB_COMPILER_SUFFIX	?=
BOOST_LIB_MT_SUFFIX		?= -mt
BOOST_LINKER_OPTIONS		 = \
	-lboost_thread$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_date_time$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_iostreams$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_filesystem$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX)

##################################################################

#### CPPUNIT OPTIONS ############################################

CPPUNIT_COMPILER_OPTIONS	+=

CPPUNIT_LINKER_OPTIONS		+= -lcppunit -ldl

##################################################################

#### DEPENDENCIES ################################################

HEADER_FILES_BITS	+= namespace.h noncopyable.h version.h
HEADER_FILES_BITS	+= compat_hash_map.h compat_hash_set.h

HEADER_FILES_COMMON	+= aligned_alloc.h mutex.h rand.h semaphore.h state.h
HEADER_FILES_COMMON	+= timer.h utils.h gprof.h simple_vector.h
HEADER_FILES_COMMON	+= switch.h tmeta.h log.h exceptions.h debug.h tuple.h
HEADER_FILES_COMMON	+= types.h utils_ledasm.h settings.h seed.h

HEADER_FILES_IO		+= completion_handler.h io.h iobase.h iostats.h
HEADER_FILES_IO		+= mmap_file.h simdisk_file.h syscall_file.h
HEADER_FILES_IO		+= ufs_file.h wincall_file.h wfs_file.h boostfd_file.h

HEADER_FILES_MNG	+= adaptor.h async_schedule.h block_prefetcher.h
HEADER_FILES_MNG	+= buf_istream.h buf_ostream.h buf_writer.h mng.h
HEADER_FILES_MNG	+= write_pool.h prefetch_pool.h

HEADER_FILES_CONTAINERS	+= pager.h stack.h vector.h priority_queue.h queue.h
HEADER_FILES_CONTAINERS	+= map.h deque.h

HEADER_FILES_CONTAINERS_BTREE	+= btree.h iterator_map.h leaf.h node_cache.h
HEADER_FILES_CONTAINERS_BTREE	+= root_node.h node.h btree_pager.h iterator.h

HEADER_FILES_ALGO	+= adaptor.h inmemsort.h intksort.h run_cursor.h sort.h
HEADER_FILES_ALGO	+= async_schedule.h interleaved_alloc.h ksort.h
HEADER_FILES_ALGO	+= losertree.h scan.h stable_ksort.h random_shuffle.h

HEADER_FILES_STREAM	+= stream.h sort_stream.h

HEADER_FILES_UTILS	+= malloc.h

###################################################################

#### MISC #########################################################

DEPEXT	 = $(LIBNAME).d # extension of dependency files
OBJEXT	 = $(LIBNAME).o	# extension of object files
IIEXT	 = $(LIBNAME).ii
LIBEXT	 = a		# static library file extension
EXEEXT	 = $(LIBNAME).bin # executable file extension
RM	 = rm -f	# remove file command
LIBGEN	 = ar cr	# library generation
OUT	 = -o		# output file option for the compiler and linker

d	?= $(strip $(DEPEXT))
o	?= $(strip $(OBJEXT))
ii	?= $(strip $(IIEXT))
bin	?= $(strip $(EXEEXT))

###################################################################

#### COMPILE/LINK RULES ###########################################

DEPS_MAKEFILES	:= $(wildcard ../Makefile.subdir.gnu ../make.settings ../make.settings.local GNUmakefile Makefile.local)
%.$o: %.cpp $(DEPS_MAKEFILES)
	@$(RM) $@ $*.$d
	$(COMPILER) $(STXXL_COMPILER_OPTIONS) -MD -MF $*.$dT -c $(OUTPUT_OPTION) $< && mv $*.$dT $*.$d

%.$(ii): %.cpp $(DEPS_MAKEFILES)
	$(COMPILER) $(STXXL_COMPILER_OPTIONS) -E $(OUTPUT_OPTION) $<

LINK_STXXL	 = $(LINKER) $1 $(STXXL_LINKER_OPTIONS) -o $@

%.$(bin): %.$o $(STXXL_LIBDEPS)
	$(call LINK_STXXL, $<)

###################################################################

ifeq ($(strip $(USE_ICPC)),yes)
STXXL_CPPFLAGS_CXX	+= $(ICPC_CPPFLAGS)
STXXL_LDLIBS_CXX	+= $(ICPC_LDFLAGS)
endif

STXXL_COMPILER_OPTIONS	+= $(STXXL_CPPFLAGS_CXX)
STXXL_COMPILER_OPTIONS	+= $(STXXL_SPECIFIC)
STXXL_COMPILER_OPTIONS	+= $(OPT) $(DEBUG) $(WARNINGS)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDLIBS_CXX)
STXXL_LINKER_OPTIONS	+= $(DEBUG)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDFLAGS)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDLIBS)

ifeq ($(strip $(USE_MCSTL)),yes)
STXXL_COMPILER_OPTIONS	+= $(MCSTL_CPPFLAGS)
STXXL_LINKER_OPTIONS	+= $(MCSTL_LDFLAGS)
endif

ifeq ($(strip $(USE_BOOST)),yes)
STXXL_COMPILER_OPTIONS	+= $(BOOST_COMPILER_OPTIONS)
STXXL_LINKER_OPTIONS	+= $(BOOST_LINKER_OPTIONS)
endif

STXXL_COMPILER_OPTIONS	+= $(CPPFLAGS)

# vim: syn=make

# This -*- Makefile -*- is intended for processing with GNU make.

TOPDIR	?= $(error TOPDIR not defined) # DO NOT CHANGE! This is set elsewhere.

# Change this file according to your paths.

# Instead of modifying this file, you could also set your modified variables
# in make.settings.local (needs to be created first).
-include $(TOPDIR)/make.settings.local

USE_BOOST	?= no	# set 'yes' to use Boost libraries or 'no' to not use Boost libraries
USE_LINUX	?= yes	# set 'yes' if you run Linux, 'no' otherwise
USE_MCSTL	?= no	# will be overriden from main Makefile
USE_ICPC	?= no	# will be overriden from main Makefile

STXXL_ROOT	?= $(HOME)/work/stxxl

ifeq ($(strip $(USE_ICPC)),yes)
COMPILER_ICPC	?= icpc
COMPILER	?= $(COMPILER_ICPC)
#ICPC_GCC	?= gcc-x.y    # override the gcc/g++ used to find headers and libraries
WARNINGS	?= -Wall -w1 -openmp-report0 -vec-report0
endif

ifeq ($(strip $(USE_MCSTL)),yes)
COMPILER_GCC	?= g++-4.2.3
LIBNAME		?= mcstxxl
# the root directory of your MCSTL installation
MCSTL_ROOT	?= $(HOME)/work/mcstl
endif

#BOOST_ROOT	?= /usr/local/boost-1.34.1

COMPILER_GCC	?= g++
COMPILER	?= $(COMPILER_GCC)
LINKER		?= $(COMPILER)
OPT		?= -O3 # compiler optimization level
WARNINGS	?= -W -Wall
DEBUG		?= # put here -g option to include the debug information into the binaries

LIBNAME		?= stxxl

#### TROUBLESHOOTING
#
# For automatical checking of order of the output elements in
# the sorters: stxxl::stream::sort, stxxl::stream::merge_runs,
# stxxl::sort, and stxxl::ksort use
#
#STXXL_SPECIFIC	+= -DSTXXL_CHECK_ORDER_IN_SORTS
#
# If your program aborts with message "read/write: wrong parameter"
# or "Invalid argument"
# this could be that your kernel does not support direct I/O
# then try to set it off recompiling the libs and your code with option
#
#STXXL_SPECIFIC	+= -DSTXXL_DIRECT_IO_OFF
#
# But for the best performance it is strongly recommended
# to reconfigure the kernel for the support of the direct I/O.
#
# FIXME: documentation needed
#
#STXXL_SPECIFIC += -DSTXXL_DEBUGMON

#### You usually shouldn't need to change the sections below #####

#### STXXL OPTIONS ###############################################

# check, whether stxxl has been configured
ifeq (,$(strip $(wildcard $(STXXL_ROOT)/include/stxxl.h)))
$(warning *** WARNING: STXXL has not been configured correctly)
ifeq (,$(strip $(wildcard $(CURDIR)/make.settings.local)))
ifneq (,$(strip $(wildcard $(CURDIR)/include/stxxl.h)))
$(warning *** WARNING: trying autoconfiguration for STXXL_ROOT=$(CURDIR:$(HOME)%=$$(HOME)%))
$(warning *** WARNING: you did not have a make.settings.local file -- creating ...)
$(shell echo 'STXXL_ROOT	 = $(CURDIR:$(HOME)%=$$(HOME)%)' >> $(CURDIR)/make.settings.local)
MCSTL_ROOT	?= $(HOME)/work/mcstl
$(shell echo '#MCSTL_ROOT	 = $(MCSTL_ROOT:$(HOME)%=$$(HOME)%)' >> $(CURDIR)/make.settings.local)
$(shell echo '#COMPILER_GCC	 = g++-4.2.3' >> $(CURDIR)/make.settings.local)
$(shell echo '#COMPILER_ICPC	 = icpc' >> $(CURDIR)/make.settings.local)
$(error ERROR: Please check make.settings.local and try again)
endif
else
$(warning *** WARNING: Please check make.settings.local)
endif
$(error ERROR: could not find a STXXL installation in STXXL_ROOT=$(STXXL_ROOT))
endif

# in the top dir, check whether STXXL_ROOT points to ourselves
ifneq (,$(wildcard make.settings))
stat1	 = $(shell stat -L -c '%d:%i' ./)
stat2	 = $(shell stat -L -c '%d:%i' $(STXXL_ROOT)/)

ifneq ($(stat1),$(stat2))
$(error ERROR: STXXL_ROOT=$(STXXL_ROOT) points to a different STXXL installation)
endif
endif

PTHREAD_FLAG	?= -pthread

STXXL_SPECIFIC	+= \
	$(PTHREAD_FLAG) \
	$(CPPFLAGS_ARCH) \
	-DSORT_OPTIMAL_PREFETCHING \
	-DUSE_MALLOC_LOCK \
	-DCOUNT_WAIT_TIME \
	-I$(strip $(STXXL_ROOT))/include \
	-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE \
	$(POSIX_MEMALIGN) $(XOPEN_SOURCE)

STXXL_LDFLAGS	+= $(PTHREAD_FLAG)
STXXL_LDLIBS	+= -L$(strip $(STXXL_ROOT))/lib -l$(LIBNAME)

STXXL_LIBDEPS	+= $(strip $(STXXL_ROOT))/lib/lib$(LIBNAME).$(LIBEXT)

UNAME_M		:= $(shell uname -m)
CPPFLAGS_ARCH	+= $(CPPFLAGS_$(UNAME_M))
CPPFLAGS_i686	?= -march=i686

##################################################################

#### ICPC OPTIONS ################################################

ifeq ($(strip $(USE_ICPC)),yes)

OPENMPFLAG	?= -openmp

ICPC_CPPFLAGS	+= $(if $(ICPC_GCC),-gcc-name=$(strip $(ICPC_GCC)))
ICPC_LDFLAGS	+= $(if $(ICPC_GCC),-gcc-name=$(strip $(ICPC_GCC)))

STXXL_SPECIFIC	+= -include bits/intel_compatibility.h

endif

##################################################################

#### MCSTL OPTIONS ###############################################

ifeq ($(strip $(USE_MCSTL)),yes)

OPENMPFLAG	?= -fopenmp

ifeq (,$(strip $(wildcard $(strip $(MCSTL_ROOT))/c++/mcstl.h)))
$(error ERROR: could not find a MCSTL installation in MCSTL_ROOT=$(MCSTL_ROOT))
endif

MCSTL_CPPFLAGS		+= $(OPENMPFLAG) -D__MCSTL__ $(MCSTL_INCLUDES_PREPEND) -I$(MCSTL_ROOT)/c++
MCSTL_LDFLAGS		+= $(OPENMPFLAG)

MCSTL_INCLUDES_PREPEND	+= $(if $(findstring 4.3,$(COMPILER)),-I$(MCSTL_ROOT)/c++/mod_stl/gcc-4.3)

endif

##################################################################

#### BOOST OPTIONS ###############################################

BOOST_COMPILER_OPTIONS	 = \
	-DSTXXL_BOOST_TIMESTAMP \
	-DSTXXL_BOOST_CONFIG \
	-DSTXXL_BOOST_FILESYSTEM \
	-DSTXXL_BOOST_THREADS \
	-DSTXXL_BOOST_RANDOM \
	$(if $(strip $(BOOST_ROOT)),-I$(strip $(BOOST_ROOT)))

BOOST_LIB_COMPILER_SUFFIX	?=
BOOST_LIB_MT_SUFFIX		?= -mt
BOOST_LINKER_OPTIONS		 = \
	-lboost_thread$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_date_time$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_iostreams$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_filesystem$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX)

##################################################################

#### CPPUNIT OPTIONS ############################################

CPPUNIT_COMPILER_OPTIONS	+=

CPPUNIT_LINKER_OPTIONS		+= -lcppunit -ldl

##################################################################

#### DEPENDENCIES ################################################

HEADER_FILES_BITS	+= namespace.h noncopyable.h version.h
HEADER_FILES_BITS	+= compat_hash_map.h compat_hash_set.h

HEADER_FILES_COMMON	+= aligned_alloc.h mutex.h rand.h semaphore.h state.h
HEADER_FILES_COMMON	+= timer.h utils.h gprof.h simple_vector.h
HEADER_FILES_COMMON	+= switch.h tmeta.h log.h exceptions.h debug.h tuple.h
HEADER_FILES_COMMON	+= types.h utils_ledasm.h settings.h seed.h

HEADER_FILES_IO		+= completion_handler.h io.h iobase.h iostats.h
HEADER_FILES_IO		+= mmap_file.h simdisk_file.h syscall_file.h
HEADER_FILES_IO		+= ufs_file.h wincall_file.h wfs_file.h boostfd_file.h

HEADER_FILES_MNG	+= adaptor.h async_schedule.h block_prefetcher.h
HEADER_FILES_MNG	+= buf_istream.h buf_ostream.h buf_writer.h mng.h
HEADER_FILES_MNG	+= write_pool.h prefetch_pool.h

HEADER_FILES_CONTAINERS	+= pager.h stack.h vector.h priority_queue.h queue.h
HEADER_FILES_CONTAINERS	+= map.h deque.h

HEADER_FILES_CONTAINERS_BTREE	+= btree.h iterator_map.h leaf.h node_cache.h
HEADER_FILES_CONTAINERS_BTREE	+= root_node.h node.h btree_pager.h iterator.h

HEADER_FILES_ALGO	+= adaptor.h inmemsort.h intksort.h run_cursor.h sort.h
HEADER_FILES_ALGO	+= async_schedule.h interleaved_alloc.h ksort.h
HEADER_FILES_ALGO	+= losertree.h scan.h stable_ksort.h random_shuffle.h

HEADER_FILES_STREAM	+= stream.h sort_stream.h

HEADER_FILES_UTILS	+= malloc.h

###################################################################

#### MISC #########################################################

DEPEXT	 = $(LIBNAME).d # extension of dependency files
OBJEXT	 = $(LIBNAME).o	# extension of object files
IIEXT	 = $(LIBNAME).ii
LIBEXT	 = a		# static library file extension
EXEEXT	 = $(LIBNAME).bin # executable file extension
RM	 = rm -f	# remove file command
LIBGEN	 = ar cr	# library generation
OUT	 = -o		# output file option for the compiler and linker

d	?= $(strip $(DEPEXT))
o	?= $(strip $(OBJEXT))
ii	?= $(strip $(IIEXT))
bin	?= $(strip $(EXEEXT))

###################################################################

#### COMPILE/LINK RULES ###########################################

DEPS_MAKEFILES	:= $(wildcard ../Makefile.subdir.gnu ../make.settings ../make.settings.local GNUmakefile Makefile.local)
%.$o: %.cpp $(DEPS_MAKEFILES)
	@$(RM) $@ $*.$d
	$(COMPILER) $(STXXL_COMPILER_OPTIONS) -MD -MF $*.$dT -c $(OUTPUT_OPTION) $< && mv $*.$dT $*.$d

%.$(ii): %.cpp $(DEPS_MAKEFILES)
	$(COMPILER) $(STXXL_COMPILER_OPTIONS) -E $(OUTPUT_OPTION) $<

LINK_STXXL	 = $(LINKER) $1 $(STXXL_LINKER_OPTIONS) -o $@

%.$(bin): %.$o $(STXXL_LIBDEPS)
	$(call LINK_STXXL, $<)

###################################################################

ifeq ($(strip $(USE_ICPC)),yes)
STXXL_CPPFLAGS_CXX	+= $(ICPC_CPPFLAGS)
STXXL_LDLIBS_CXX	+= $(ICPC_LDFLAGS)
endif

STXXL_COMPILER_OPTIONS	+= $(STXXL_CPPFLAGS_CXX)
STXXL_COMPILER_OPTIONS	+= $(STXXL_SPECIFIC)
STXXL_COMPILER_OPTIONS	+= $(OPT) $(DEBUG) $(WARNINGS)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDLIBS_CXX)
STXXL_LINKER_OPTIONS	+= $(DEBUG)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDFLAGS)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDLIBS)

ifeq ($(strip $(USE_MCSTL)),yes)
STXXL_COMPILER_OPTIONS	+= $(MCSTL_CPPFLAGS)
STXXL_LINKER_OPTIONS	+= $(MCSTL_LDFLAGS)
endif

ifeq ($(strip $(USE_BOOST)),yes)
STXXL_COMPILER_OPTIONS	+= $(BOOST_COMPILER_OPTIONS)
STXXL_LINKER_OPTIONS	+= $(BOOST_LINKER_OPTIONS)
endif

STXXL_COMPILER_OPTIONS	+= $(CPPFLAGS)

# vim: syn=make


Switch to 1ns runs, more realistic for our purposes

set terminal png font 'Arial, 24' size 1600,900 background rgb "#ffffff"

set style line 100 lt -1 lw 2 lc rgb '#000000'

set border 3 front ls 100

set datafile separator ','

set grid back lw 2 x y
set xrange [0:24]
set x2range [0:768]
set yrange [0:210]
set xtics nomirror 4
set x2tics nomirror 128
set ytics nomirror 30

####################################

set output 'laptop_cmp.png'

set key off autotitle columnheader
set title 'Gromacs on a cluster node'
set autoscale x
# disable x2 label and tics, but reserve space to preserve alignment
set x2label ' '
set x2tics 10000,10000
set yrange [0:30]
set ytics 5
set ylabel 'Simulation speed (ns/day)'

set boxwidth 0.5
set style fill solid

barcolor(x) = (x == 0) ? (65536 * 64 + 128) : (256 * 174 + 239)

plot 'gpu_cmp_clean.csv' using 0:14:(barcolor($0)):xtic(18) every ::0::1 with boxes lc rgb variable notitle

####################################

set output 'cpus.png'

set key off autotitle columnheader
set title 'Gromacs on many CPUs'
set xlabel 'Cluster nodes'
set xrange [0:24]
set xtics nomirror 4
set x2label 'Threads'
set x2tics nomirror 128
set ylabel 'Simulation speed (ns/day)'
set ytics nomirror 30
set yrange [0:210]

plot \
	'data_clean.csv' using (($4 == 0 && $5 == 0 && stringcolumn(6) eq 'infiniband') ? $2 : 0/0):20 \
		with points notitle lc rgb '#00aeef' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):15 \
		with lines notitle lc rgb '#00aeef' lw 3 \
	, 'laptop.csv' using 1:3 with points notitle lc rgb '#400080' pt 7 ps 3

####################################

set output 'cpus_timespent.png'

set yrange [0:100]
set ytics 25
set ylabel '% Time spent'
set key inside left center invert opaque

plot \
	'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):9 with filledcurves above x1 title 'Decomposition' \
	, '' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):9:($9+$10) with filledcurves title 'Comm.Coord.' \
	, '' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):($9+$10):($9+$10+$11) with filledcurves title 'Calc. Force' \
	, '' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):($9+$10+$11):($9+$10+$11+$12) with filledcurves title 'Comm. Force' \
	, '' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):($9+$10+$11+$12):($9+$10+$11+$12+$14) with filledcurves title 'Constraints'

####################################

set output 'cpus_corehours.png'

set key off autotitle columnheader
set title 'Core hours for 1ns run'
set ylabel 'Core hours'
set autoscale y
set ytics autofreq

plot \
	'data_clean.csv' using (($4 == 0 && $5 == 0 && stringcolumn(6) eq 'infiniband') ? $2 : 0/0):($21 * 10 / 3600) \
		with points notitle lc rgb '#00aeef' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):($16 * 10 / 3600) \
		with lines notitle lc rgb '#00aeef' lw 3 \
	, 'laptop.csv' using 1:($4 * 10 / 3600) with points notitle lc rgb '#400080' pt 7 ps 3

####################################

set output 'cpus_wallclock.png'

set title 'Wallclock time for 1ns run'
set ylabel 'Wallclock time (min)'

plot \
	'data_clean.csv' using (($4 == 0 && $5 == 0 && stringcolumn(6) eq 'infiniband') ? $2 : 0/0):($22 * 10 / 60) \
		with points notitle lc rgb '#00aeef' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):($17 * 10 / 60) \
		with lines notitle lc rgb '#00aeef' lw 3

####################################

set output 'cpus_ethernet.png'

set key on inside right bottom autotitle columnheader box height 0.5
set title 'Influence of network'
set yrange [0:210]
set ytics nomirror 30
set ylabel 'Simulation speed (ns/day)'

plot \
	'data_clean.csv' using (($4 == 0 && $5 == 0 && stringcolumn(6) eq 'infiniband') ? $2 : 0/0):20 \
		with points notitle lc rgb '#00aeef' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):15 \
		with lines title 'Infiniband' lc rgb '#00aeef' lw 3 \
	, 'data_clean.csv' using (($4 == 0 && $5 == 0 && stringcolumn(6) eq 'ethernet') ? $2 : 0/0):20 \
		with points notitle lc rgb '#ef6e00' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'ethernet') ? $4 : 0/0):15 \
		with lines title 'Ethernet' lc rgb '#ef6e00' lw 3 \
	, 'laptop.csv' using 1:($4 * 100 / 3600) with points notitle lc rgb '#400080' pt 7 ps 3

####################################

set output 'gpu_cmp.png'

set key off autotitle columnheader
set title 'Gromacs on many GPUs'
set autoscale x
# disable x2 label and tics, but reserve space to preserve alignment
set x2label ' '
set x2tics 10000,10000

set boxwidth 0.5
set style fill solid

plot 'gpu_cmp_clean.csv' using 0:14:(barcolor($0)):xtic(18) with boxes lc rgb variable notitle

set xtics nomirror 128

####################################

set output 'cpus_gpu.png'

set key off autotitle columnheader
set title 'Gromacs on many CPUs, with 1 GPU per node'
set xrange [0:24]
set xtics nomirror 4
set x2label 'Threads'
set x2tics nomirror 128

plot \
	'data_clean.csv' using (($4 == 0 && $5 == 0 && stringcolumn(6) eq 'infiniband') ? $2 : 0/0):20 \
		with points notitle lc rgb '#00aeef' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):15 \
		with lines notitle lc rgb '#00aeef' lw 3 \
	, 'data_clean.csv' using (($4 == 1 && $5 == 0 && stringcolumn(6) eq 'infiniband') ? $2 : 0/0):20 \
		with points notitle lc rgb '#009f00' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 1 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):15 \
		with lines notitle lc rgb '#009f00' lw 3 \
	, 'laptop.csv' using 1:($4 * 100 / 3600) with points notitle lc rgb '#400080' pt 7 ps 3

####################################

set output 'practice.png'

set key on inside right bottom autotitle columnheader box height 0.5
set title 'Gromacs on Cartesius vs. Lisa (approximately)'

plot \
	'data_clean.csv' using (($4 == 0 && $5 == 0 && stringcolumn(6) eq 'infiniband') ? $2 : 0/0):20 \
		with points notitle lc rgb '#00aeef' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):15 \
		with lines title 'Cartesius CPU' lc rgb '#00aeef' lw 3 \
	, 'data_clean.csv' using (($4 == 0 && $5 == 0 && stringcolumn(6) eq 'ethernet') ? $2 : 0/0):20 \
		with points notitle lc rgb '#ef6e00' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'ethernet') ? $4 : 0/0):15 \
		with lines title 'Lisa CPU' lc rgb '#ef6e00' lw 3 \
	, 'data_clean.csv' using (($4 == 0 && $5 == 2 && stringcolumn(6) eq 'infiniband') ? $2 : 0/0):20 \
		with points notitle lc rgb '#ae00ef' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 2 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):15 \
		with lines title 'Cartesius GPU' lc rgb '#ae00ef' lw 3 \
	, 'laptop.csv' using 1:($4 * 100 / 3600) with points notitle lc rgb '#400080' pt 7 ps 3

set terminal png font 'Arial, 24' size 1600,900 background rgb "#ffffff"

set style line 100 lt -1 lw 2 lc rgb '#000000'

set border 3 front ls 100

set datafile separator ','

set grid back lw 2 x y
set xrange [0:24]
set x2range [0:768]
set yrange [0:210]
set xtics nomirror 4
set x2tics nomirror 128
set ytics nomirror 30

####################################

set output 'laptop_cmp.png'

set key off autotitle columnheader
set title 'Gromacs on a cluster node'
set autoscale x
# disable x2 label and tics, but reserve space to preserve alignment
set x2label ' '
set x2tics 10000,10000
set yrange [0:30]
set ytics 5
set ylabel 'Simulation speed (ns/day)'

set boxwidth 0.5
set style fill solid

barcolor(x) = (x == 0) ? (65536 * 64 + 128) : (256 * 174 + 239)

plot 'gpu_cmp_clean.csv' using 0:14:(barcolor($0)):xtic(18) every ::0::1 with boxes lc rgb variable notitle

####################################

set output 'cpus.png'

set key off autotitle columnheader
set title 'Gromacs on many CPUs'
set xlabel 'Cluster nodes'
set xrange [0:24]
set xtics nomirror 4
set x2label 'Threads'
set x2tics nomirror 128
set ylabel 'Simulation speed (ns/day)'
set ytics nomirror 30
set yrange [0:210]

plot \
	'data_clean.csv' using (($4 == 0 && $5 == 0 && stringcolumn(6) eq 'infiniband') ? $2 : 0/0):20 \
		with points notitle lc rgb '#00aeef' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):15 \
		with lines notitle lc rgb '#00aeef' lw 3 \
	, 'laptop.csv' using 1:3 with points notitle lc rgb '#400080' pt 7 ps 3

####################################

set output 'cpus_timespent.png'

set yrange [0:100]
set ytics 25
set ylabel '% Time spent'
set key inside left center invert opaque

plot \
	'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):9 with filledcurves above x1 title 'Decomposition' \
	, '' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):9:($9+$10) with filledcurves title 'Comm.Coord.' \
	, '' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):($9+$10):($9+$10+$11) with filledcurves title 'Calc. Force' \
	, '' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):($9+$10+$11):($9+$10+$11+$12) with filledcurves title 'Comm. Force' \
	, '' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):($9+$10+$11+$12):($9+$10+$11+$12+$14) with filledcurves title 'Constraints'

####################################

set output 'cpus_corehours.png'

set title 'Core hours for 10ns run'
set ylabel 'Core hours'
set autoscale y
set ytics autofreq

plot \
	'data_clean.csv' using (($4 == 0 && $5 == 0 && stringcolumn(6) eq 'infiniband') ? $2 : 0/0):($21 * 100 / 3600) \
		with points notitle lc rgb '#00aeef' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):($16 * 100 / 3600) \
		with lines notitle lc rgb '#00aeef' lw 3 \
	, 'laptop.csv' using 1:($4 * 100 / 3600) with points notitle lc rgb '#400080' pt 7 ps 3

####################################

set output 'cpus_wallclock.png'

set title 'Wallclock time for 10ns run'
set ylabel 'Wallclock time (h)'

plot \
	'data_clean.csv' using (($4 == 0 && $5 == 0 && stringcolumn(6) eq 'infiniband') ? $2 : 0/0):($22 * 100 / 3600) \
		with points notitle lc rgb '#00aeef' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):($17 * 100 / 3600) \
		with lines notitle lc rgb '#00aeef' lw 3

####################################

set output 'cpus_ethernet.png'

set key on inside right bottom autotitle columnheader box height 0.5
set title 'Influence of network'
set yrange [0:210]
set ytics nomirror 30
set ylabel 'Simulation speed (ns/day)'

plot \
	'data_clean.csv' using (($4 == 0 && $5 == 0 && stringcolumn(6) eq 'infiniband') ? $2 : 0/0):20 \
		with points notitle lc rgb '#00aeef' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):15 \
		with lines title 'Infiniband' lc rgb '#00aeef' lw 3 \
	, 'data_clean.csv' using (($4 == 0 && $5 == 0 && stringcolumn(6) eq 'ethernet') ? $2 : 0/0):20 \
		with points notitle lc rgb '#ef6e00' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'ethernet') ? $4 : 0/0):15 \
		with lines title 'Ethernet' lc rgb '#ef6e00' lw 3 \
	, 'laptop.csv' using 1:($4 * 100 / 3600) with points notitle lc rgb '#400080' pt 7 ps 3

####################################

set output 'gpu_cmp.png'

set key off autotitle columnheader
set title 'Gromacs on many GPUs'
set autoscale x
# disable x2 label and tics, but reserve space to preserve alignment
set x2label ' '
set x2tics 10000,10000

set boxwidth 0.5
set style fill solid

plot 'gpu_cmp_clean.csv' using 0:14:(barcolor($0)):xtic(18) with boxes lc rgb variable notitle

set xtics nomirror 128

####################################

set output 'cpus_gpu.png'

set key off autotitle columnheader
set title 'Gromacs on many CPUs, with 1 GPU per node'
set xrange [0:24]
set xtics nomirror 4
set x2label 'Threads'
set x2tics nomirror 128

plot \
	'data_clean.csv' using (($4 == 0 && $5 == 0 && stringcolumn(6) eq 'infiniband') ? $2 : 0/0):20 \
		with points notitle lc rgb '#00aeef' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):15 \
		with lines notitle lc rgb '#00aeef' lw 3 \
	, 'data_clean.csv' using (($4 == 1 && $5 == 0 && stringcolumn(6) eq 'infiniband') ? $2 : 0/0):20 \
		with points notitle lc rgb '#009f00' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 1 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):15 \
		with lines notitle lc rgb '#009f00' lw 3 \
	, 'laptop.csv' using 1:($4 * 100 / 3600) with points notitle lc rgb '#400080' pt 7 ps 3

####################################

set output 'practice.png'

set key on inside right bottom autotitle columnheader box height 0.5
set title 'Gromacs on Cartesius vs. Lisa (approximately)'

plot \
	'data_clean.csv' using (($4 == 0 && $5 == 0 && stringcolumn(6) eq 'infiniband') ? $2 : 0/0):20 \
		with points notitle lc rgb '#00aeef' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):15 \
		with lines title 'Cartesius CPU' lc rgb '#00aeef' lw 3 \
	, 'data_clean.csv' using (($4 == 0 && $5 == 0 && stringcolumn(6) eq 'ethernet') ? $2 : 0/0):20 \
		with points notitle lc rgb '#ef6e00' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 0 && stringcolumn(1) eq 'ethernet') ? $4 : 0/0):15 \
		with lines title 'Lisa CPU' lc rgb '#ef6e00' lw 3 \
	, 'data_clean.csv' using (($4 == 0 && $5 == 2 && stringcolumn(6) eq 'infiniband') ? $2 : 0/0):20 \
		with points notitle lc rgb '#ae00ef' pt 7 ps 3 \
	, 'means_clean.csv' using (($2 == 0 && $3 == 2 && stringcolumn(1) eq 'infiniband') ? $4 : 0/0):15 \
		with lines title 'Cartesius GPU' lc rgb '#ae00ef' lw 3 \
	, 'laptop.csv' using 1:($4 * 100 / 3600) with points notitle lc rgb '#400080' pt 7 ps 3


updates

updates

## ======================================================================== ##
## Copyright 2009-2015 Intel Corporation                                    ##
##                                                                          ##
## Licensed under the Apache License, Version 2.0 (the "License");          ##
## you may not use this file except in compliance with the License.         ##
## You may obtain a copy of the License at                                  ##
##                                                                          ##
##     http://www.apache.org/licenses/LICENSE-2.0                           ##
##                                                                          ##
## Unless required by applicable law or agreed to in writing, software      ##
## distributed under the License is distributed on an "AS IS" BASIS,        ##
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ##
## See the License for the specific language governing permissions and      ##
## limitations under the License.                                           ##
## ======================================================================== ##

set style line 101 lc rgb "green" lt 1
set style line 102 lc rgb "green" lt 1
set style line 103 lc rgb "#008800" lt 1
set style line 104 lc rgb "grey" lt 1
set style line 105 lc rgb "yellow" lt 1
set style line 106 lc rgb "orange" lt 1
set style line 107 lc rgb "red" lt 1
set style line 108 lc rgb "blue" lt 1
set style line 109 lc rgb "#000088" lt 1

#set term postscript enhanced color
set term png

set xtics rotate 90
set xlabel 'Items'
set logscale x
set xrange [1000:100000000]

#set yrange [0:23]
set ylabel 'Performance in M/s'

set output "benchmark_reduce.png"
set title "benchmark_reduce Single Socket HSW"
plot 'benchmark_reduce_sequential.csv' using ($1):($6) t "single threaded" with lines ls 108, \
     'benchmark_reduce_lockstep.csv' using ($1):($6) t "lockstep taskscheduler" with lines ls 102, \
     'benchmark_reduce_tbb.csv' using ($1):($6) t "threading building blocks" with lines ls 107

set output "benchmark_sort.png"
set title "benchmark_sort Single Socket HSW"
plot 'benchmark_sort_sequential.csv' using ($1):($6) t "single threaded" with lines ls 108, \
     'benchmark_sort_lockstep.csv' using ($1):($6) t "lockstep taskscheduler" with lines ls 102, \
     'benchmark_sort_tbb.csv' using ($1):($6) t "threading building blocks" with lines ls 107

## ======================================================================== ##
## Copyright 2009-2015 Intel Corporation                                    ##
##                                                                          ##
## Licensed under the Apache License, Version 2.0 (the "License");          ##
## you may not use this file except in compliance with the License.         ##
## You may obtain a copy of the License at                                  ##
##                                                                          ##
##     http://www.apache.org/licenses/LICENSE-2.0                           ##
##                                                                          ##
## Unless required by applicable law or agreed to in writing, software      ##
## distributed under the License is distributed on an "AS IS" BASIS,        ##
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ##
## See the License for the specific language governing permissions and      ##
## limitations under the License.                                           ##
## ======================================================================== ##

set style line 101 lc rgb "green" lt 1
set style line 102 lc rgb "green" lt 1
set style line 103 lc rgb "#008800" lt 1
set style line 104 lc rgb "grey" lt 1
set style line 105 lc rgb "yellow" lt 1
set style line 106 lc rgb "orange" lt 1
set style line 107 lc rgb "red" lt 1
set style line 108 lc rgb "blue" lt 1
set style line 109 lc rgb "#000088" lt 1

#set term postscript enhanced color
set term png

set xtics rotate 90
set xlabel 'Items'
set logscale x
set xrange [1000:100000000]

#set yrange [0:23]
set ylabel 'Performance in M/s'

set output "benchmark_reduce.png"
set title "benchmark_reduce Dual Socket SNB"
plot 'benchmark_reduce_sequential.csv' using ($1):($6) t "single threaded" with lines ls 108, \
     'benchmark_reduce_lockstep.csv' using ($1):($6) t "lockstep taskscheduler" with lines ls 102, \
     'benchmark_reduce_tbb.csv' using ($1):($6) t "threading building blocks" with lines ls 107

set output "benchmark_sort.png"
set title "benchmark_sort Dual Socket SNB"
plot 'benchmark_sort_sequential.csv' using ($1):($6) t "single threaded" with lines ls 108, \
     'benchmark_sort_lockstep.csv' using ($1):($6) t "lockstep taskscheduler" with lines ls 102, \
     'benchmark_sort_tbb.csv' using ($1):($6) t "threading building blocks" with lines ls 107


Changed to use every 5 data points

Changed to use every 5 data points

#!/usr/bin/env gnuplot

set terminal png
set datafile separator ","
set output "cache_readhitrate.png"
plot "cache.data" using 1:2 every 5 title "Read Hit Rate"

set output "cache_writehitrate.png"
plot "cache.data" using 1:3 every 5 title "Write Hit Rate"

set output "cache_reads.png"
plot "cache.data" using 1:7 every 5 title "Reads", \
	 "cache.data" using 1:4 every 5 title "Read Hits"

set output "cache_writes.png"
plot "cache.data" using 1:8 every 5 title "Writes", \
     "cache.data" using 1:5 every 5 title "Write Hits"

set output "cache_deletes.png"
plot "cache.data" using 1:9 every 5 title "Deletions", \
     "cache.data" using 1:6 every 5 title "Deletion Hits"

set output "cache_evictions.png"
plot "cache.data" using 1:11 every 5 title "Evictions"

set output "cache_readlatency.png"
plot "cache.data" using 1:13 every 5 title "Mean Read Latency (usecs)"

set output "cache_writelatency.png"
plot "cache.data" using 1:14 every 5 title "Mean Write Latency (usecs)"

set output "cache_deletelatency.png"
plot "cache.data" using 1:15 every 5 title "Mean Delete Latency (usecs)"

#!/usr/bin/env gnuplot

set terminal png
set datafile separator ","
set output "cache_readhitrate.png"
plot "cache.data" using 1:2 every 5 title "Read Hit Rate"

set output "cache_writehitrate.png"
plot "cache.data" using 1:3 every 5 title "Write Hit Rate"

set output "cache_reads.png"
plot "cache.data" using 1:7 every 5 title "Reads", \
	 "cache.data" using 1:4 every 5 title "Read Hits"

set output "cache_writes.png"
plot "cache.data" using 1:8 every 5 title "Writes", \
     "cache.data" using 1:5 every 5 title "Write Hits"

set output "cache_deletes.png"
plot "cache.data" using 1:9 every 5 title "Deletions", \
     "cache.data" using 1:6 every 5 title "Deletion Hits"

set output "cache_evictions.png"
plot "cache.data" using 1:11 every 5 title "Evictions"

set output "cache_readlatency.png"
plot "cache.data" using 1:13 every 1 title "Mean Read Latency (usecs)"

set output "cache_writelatency.png"
plot "cache.data" using 1:14 every 1 title "Mean Write Latency (usecs)"

set output "cache_deletelatency.png"
plot "cache.data" using 1:15 every 1 title "Mean Delete Latency (usecs)"