-
Notifications
You must be signed in to change notification settings - Fork 2
/
runcnc
executable file
·158 lines (133 loc) · 5.5 KB
/
runcnc
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
# ---------------------------------------------------------------------------
# Intel Concurrent Collections for Haskell
# Copyright (c) 2010, Intel Corporation.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms and conditions of the GNU Lesser General Public License,
# version 2.1, as published by the Free Software Foundation.
#
# This program is distributed in the hope it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
# more details.
#
# You should have received a copy of the GNU Lesser General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
# ---------------------------------------------------------------------------
# This is a script used for running an CnC Haskell program.
# It responds to a bunch of environment variables that choose configuration to use.
# This script responds to a number of ENVIRONMENT VARIABLES:
# --------------------------------------------------------------------------------
# NUMTHREADS -- if this is "0" the program is compiled without threading
# NORUN -- compile but do not run
# CNC_VARIANT -- which implementation? "pure" or "io"
# CNC_SCHEDULER -- which (numbered) scheduler, 1-N?
# GHC_DEFAULT_FLAGS -- flags for ghc
# GHC_DEFAULT_RTS -- flags for ghc
# GHC -- command to call ghc compiler
# INTERACTIVE -- set to non-empty value to call ghci instead of ghc
# CNCOPT -- set to -O0 -O2 -to control optimization level [default -O2]
# --------------------------------------------------------------------------------
if [ "$GHC" == "" ]; then
GHC=ghc
fi
#source "$HASKELLCNC/default_opt_settings.sh"
DEFAULT_SETTINGS_FILE=`dirname $0`/default_opt_settings.sh
source $DEFAULT_SETTINGS_FILE
# if [ -z ]
FILE=$1
BIN=`echo $1 | sed 's/\.hs//'`.exe
shift
if [ "$INTERACTIVE" == "" ];
then CMD="$GHC --make";
else CMD=ghci
fi
# [2010.02.16] Strangely enabling -fglasgow-exts causes CncPure.hs to NOT compile correctly. Parse error.
#EXTENSIONS="-fglasgow-exts"
# -feager-blackholing
# glasgow-exts actually CAUSES problems (cncpure wont build):
#TEMPEXT="-XFlexibleContexts -XTypeSynonymInstances -XRankNTypes -fglasgow-exts "
TEMPEXT="-XFlexibleContexts -XTypeSynonymInstances -XRankNTypes "
EXTENSIONS=" -XExistentialQuantification -XScopedTypeVariables -XBangPatterns -XNamedFieldPuns -XRecordWildCards -XFlexibleInstances -XDeriveDataTypeable -XTypeFamilies -XUndecidableInstances -XOverlappingInstances -XMultiParamTypeClasses -XFunctionalDependencies $TEMPEXT"
# MagicHash
# If the user has not set $HASKELLCNC we try the current directory.
if [ "$HASKELLCNC" == "" ]; then
if [ -e "./Intel/Cnc.hs" ]; then
echo ' *** WARNING: Guessing $HASKELLCNC is current directory.'
export HASKELLCNC=`pwd`
else
echo "ERROR: Environment variable HASKELLCNC must be set to installation directory!"
exit 1
fi
fi
# We need to include the install dir in the search path for GHC and
# for the C preprocessor.
FLAGS="$GHC_DEFAULT_FLAGS $EXTENSIONS -I""$HASKELLCNC -i""$HASKELLCNC"
# This is an undocumented environment variable dependence -- NORUN
# disables execution and causes this script to compile-only.
if [ "$NORUN" == "" ]; then
EXTRAGHCARGS=
else
# In NORUN mode extra arguments are meant for GHC, not the final application.
EXTRAGHCARGS=$*
fi
# && [ "$NUMTHREADS" != "" ];
if [ "$NUMTHREADS" != "0" ]
then
FLAGS="$FLAGS -threaded"
EXTRA_RUN_ARGS=" +RTS $GHC_DEFAULT_RTS -N$NUMTHREADS -RTS"
else
# This is annoying, the thread-related flags must be removed from
# the defaults if we're not in threaded mode:
FILTERED_RTS=`echo $GHC_DEFAULT_RTS | sed 's/-qa//'`
EXTRA_RUN_ARGS=" +RTS $FILTERED_RTS -RTS "
fi
# CnC implementation variant. Translate string setting to numeric one.
if [ "$CNC_VARIANT" == "pure" ]; then
echo "Using CNC_VARIANT='pure'"
FLAGS="$FLAGS -DCNC_VARIANT=1"
elif [ "$CNC_VARIANT" == "io" ] || [ "$CNC_VARIANT" == "normal" ] ; then
echo "Using CNC_VARIANT='io'"
FLAGS="$FLAGS -DCNC_VARIANT=2"
elif [ "$CNC_VARIANT" == "" ]; then
echo " *** "
echo " *** \$CNC_VARIANT unset (should be 'pure' or 'io')!"
echo " *** Defaulting to 'io'..."
echo " *** "
CNC_VARIANT="io"
FLAGS="$FLAGS -DCNC_VARIANT=2"
elif [ "$CNC_VARIANT" == "separatemodule_io" ]; then
FLAGS="$FLAGS -DCNC_VARIANT=0"
else
echo "ERROR: unknown CNC_VARIANT: $CNC_VARIANT"
exit 2
fi
# Scheduler:
if [ "$CNC_SCHEDULER" == "" ];
then echo
# [2010.05.19] For cabal builds its easier if the default is set in the code itself.
#
# if [ "$CNC_VARIANT" == "pure" ]; then
# FLAGS="$FLAGS -DCNC_SCHEDULER=2"
# echo " *** WARNING - defaulting CNC_SCHEDULER to '2' (pure)"
# else
# FLAGS="$FLAGS -DCNC_SCHEDULER=6"
# echo " *** WARNING - defaulting CNC_SCHEDULER to '6' (io)"
# fi
else FLAGS="$FLAGS -DCNC_SCHEDULER=$CNC_SCHEDULER"
fi
echo " [Compiling $FILE to $BIN, $CNC_VARIANT $CNC_SCHEDULER ]"
echo $CMD $FLAGS -cpp "$FILE" -o "$BIN" -fforce-recomp $EXTRAGHCARGS
if $CMD $FLAGS -cpp "$FILE" -o "$BIN" -fforce-recomp $EXTRAGHCARGS
#if ghc -cpp -O2 $FILE -o
then
if [ "$NORUN" == "" ]; then
echo; echo " [Executing: time ./$BIN $* $EXTRA_RUN_ARGS;]"
echo "----------------------------------------"
exec time ./$BIN $* $EXTRA_RUN_ARGS;
# exec time memprof ./$BIN $*
fi
else exit 33
fi