4 # This is an interactive script that knows
5 # common ways to build Charm++ and AMPI.
7 # Authors: dooley, becker
10 # Turn off I/O buffering
15 # A subroutine that reads from input and returns a yes/no/default
19 if(lc($line) eq "y" || lc($line) eq "yes" ){
21 } elsif(lc($line) eq "n" || lc($line) eq "no" ){
23 } elsif( $line eq "" ){
30 # The beginning of the good stuff:
31 print "\n============================================================\n";
32 print "\nBegin interactive charm configuration ...\n";
33 print "If you are a poweruser expecting a list of options, please use ./build --help\n";
34 print "\n============================================================\n\n\n";
37 # Use uname to get the cpu type and OS information
41 #Variables to hold the portions of the configuration:
47 #remove newlines from these strings:
55 } elsif ($os eq "Darwin") {
57 } elsif ($os =~ m/BSD/ ) {
59 } elsif ($os =~ m/OSF1/ ) {
61 } elsif ($os =~ m/AIX/ ) {
63 } elsif ($os =~ m/CYGWIN/ ) {
64 print "Detected a Cygwin system\n";
65 print "This uses the gnu compiler by default,\n";
66 print "To build with Microsoft Visual C++ compiler, use net-win32. Please refer to README.win32 for the details on setting up VC++ under cygwin.\n\n";
72 # Determine architecture (x86, ppc, ...)
73 if($cpu =~ m/i[0-9]86/){
75 } elsif($cpu =~ m/x86\_64/){
77 } elsif($cpu =~ m/ia64/){
79 $nobs = "--no-build-shared";
80 } elsif($cpu =~ m/powerpc/){
82 } elsif($cpu =~ m/Power Mac/){
84 } elsif($cpu =~ m/ppc*/){
86 } elsif($cpu =~ m/alpha/){
93 $converse_network_type = "net";
98 $skip_choosing = "false";
100 $mpi_found = "false";
101 $m = system("which mpicc mpiCC > /dev/null 2>/dev/null") / 256;
106 $m = system("which mpicc mpicxx > /dev/null 2>/dev/null") / 256;
109 $mpioption = "mpicxx";
112 # Give option of just using the mpi version if mpicc and mpiCC are found
113 if($mpi_found eq "true"){
114 print "\nI found that you have an mpicc available in your path.\nDo you want to build Charm++ on this MPI? [y/N]: ";
117 $converse_network_type = "mpi";
118 $skip_choosing = "true";
119 $options = "$options $mpioption";
123 if($skip_choosing eq "false") {
125 print "\nDo you have a special network interconnect? [y/N]: ";
130 Choose an interconnect from below
: [1-11]
132 2) Infiniband
(native ibverbs alpha version
)
138 8) Bluegene
/L Native
(only at T
. J
. Watson
)
140 10) Bluegene
/P Native
149 $converse_network_type = "mpi";
151 } elsif($line eq "2"){
152 $converse_network_type = "net";
153 $options = "$options ibverbs ";
155 } elsif($line eq "3"){
156 $converse_network_type = "net";
157 $options = $options . "gm ";
159 } elsif($line eq "4"){
160 $converse_network_type = "net";
161 $options = $options . "mx ";
163 } elsif($line eq "5"){
166 } elsif($line eq "6"){
167 $arch = "mpi-crayxt3";
169 } elsif($line eq "7"){
170 $arch = "mpi-crayxt";
172 } elsif($line eq "8"){
175 $nobs = "--no-build-shared";
177 } elsif($line eq "9"){
178 $arch = "mpi-bluegenel";
180 $nobs = "--no-build-shared";
182 } elsif($line eq "10"){
186 } elsif($line eq "11"){
187 $arch = "mpi-bluegenep";
190 } elsif($line eq "12"){
191 $converse_network_type = "vmi";
194 print "Invalid option, please try again :P\n"
201 # construct an $arch string if we did not explicitly set one above
203 $arch = "${converse_network_type}-${arch_os}";
205 $arch = $arch . "-x86_64";
207 $arch = $arch . "-ia64";
209 $arch = $arch . "-ppc";
211 $arch = $arch . "-axp";
215 # Fixup $arch to match the inconsistent directories in src/archs
217 if($arch eq "net-darwin"){
218 $arch = "net-darwin-x86";
219 } elsif($arch eq "net-ppc-darwin"){
220 $arch = "net-darwin-ppc";
221 } elsif($arch eq "mpi-ppc-darwin"){
222 $arch = "mpi-darwin-ppc";
223 } elsif($arch eq "multicore-linux-x86_64"){
224 $arch = "multicore-linux64";
231 #================ Choose SMP/PXSHM =================================
233 # find what options are available
234 $opts = `./build charm++ $arch help 2>&1 | grep "Supported options"`;
235 $opts =~ m/Supported options: (.*)/;
239 #always provide multicore and single-threaded versions
241 How
do you want to handle SMP
/Multicore
: [1-4]
242 1) single
-threaded
[default]
243 2) multicore
(single node only
)
246 # only add the smp or pxshm options if they are available
247 $counter = 3; # the next index used in the list
251 print " $counter) SMP\n";
252 $smpIndex = $counter;
257 if($opts =~ m/pxshm/){
258 print " $counter) POSIX Shared Memory\n";
259 $pxshmIndex = $counter;
265 if($line eq "1" || $line eq ""){
267 } elsif($line eq "2"){
268 $converse_network_type = "multicore";
270 } elsif($line eq $smpIndex){
271 $options = "$options smp ";
273 } elsif($line eq $pxshmIndex){
274 $options = "$options pxshm ";
285 #================ Choose Compiler =================================
287 # Lookup list of compilers
288 $cs = `./build charm++ $arch help 2>&1 | grep "Supported compilers"`;
289 # prune away beginning of the line
290 $cs =~ m/Supported compilers: (.*)/;
292 # split the line into an array
293 @c_list = split(" ", $cs);
295 # print list of compilers
299 print "\nDo you want to specify a compiler? [y/N]";
302 print "Choose a compiler: [1-$numc] \n";
305 foreach $c (@c_list){
313 if($line =~ m/([0-9]*)/ && $1 > 0 && $1 <= $numc){
314 $compilers = $c_list[$1-1];
317 print "Invalid option, please try again :P\n"
326 #================ Choose Options =================================
328 #Create a hash table containing descriptions of various options
330 $explanations{"ooc"} = "Out-of-core execution support in Charm++";
331 $explanations{"tcp"} = "Charm++ over TCP instead of UDP for net versions. TCP is slower";
332 $explanations{"ifort"} = "Use Intel's ifort fortran compiler";
333 $explanations{"gfortran"} = "Use gfortran compiler for fortran";
334 $explanations{"g95"} = "Use g95 compiler";
335 $explanations{"ifort"} = "Use Intel's ifort fortran compiler";
336 $explanations{"pgf90"} = "Use Portland Group's pgf90 fortran compiler";
337 $explanations{"ifc"} = "Use Intel's ifc compiler";
338 $explanations{"ammasso"} = "Use native RDMA support on Ammasso interconnect";
339 $explanations{"syncft"} = "Use initial fault tolerance support";
340 $explanations{"mlogft"} = "Use message logging fault tolerance support";
341 $explanations{"causalft"} = "Use causal message logging fault tolerance support";
347 # Produce list of options
349 $opts = `./build charm++ $arch help 2>&1 | grep "Supported options"`;
350 # prune away beginning of line
351 $opts =~ m/Supported options: (.*)/;
354 @option_list = split(" ", $opts);
357 # Prune out entries that would already have been chosen above, such as smp
358 @option_list_pruned = ();
359 foreach $o (@option_list){
360 if($o ne "smp" && $o ne "ibverbs" && $o ne "gm" && $o ne "mx"){
361 @option_list_pruned = (@option_list_pruned , $o);
366 @option_list_pruned = sort @option_list_pruned;
367 if (@option_list_pruned > 0) {
369 print "\nDo you want to specify any Charm++ build options, such as fortran compilers? [y/N]";
370 $special_options = promptUserYN
();
372 if($special_options eq "yes"){
374 # print out list for user to select from
375 print "Please enter one or more numbers separated by spaces\n";
378 foreach $o (@option_list_pruned){
379 $exp = $explanations{$o};
381 # pad whitespace before options
382 for($j=0;$j<20-length($o);$j++){
389 print "\t$i)\tNone Of The Above\n";
391 $num_options = @option_list_pruned;
395 $line =~ m/([0-9 ]*)/;
396 @entries = split(" ",$1);
397 @entries = sort(@entries);
399 $additional_options = "";
400 foreach $e (@entries) {
401 if($e>=1 && $e<= $num_options){
402 $estring = $option_list_pruned[$e-1];
403 $additional_options = "$additional_options $estring";
404 } elsif ($e == $num_options+1){
405 # user chose "None of the above"
406 # clear the options we may have seen before
407 $additional_options = " ";
411 # if the user input something reasonable, we can break out of this loop
412 if($additional_options ne ""){
413 $options = "$options ${additional_options} ";
429 # Choose compiler flags
432 Choose a set of compiler flags
[1-5]
435 3) production build
[default] --with
-production
436 4) production build w
/ projections
--with
-production
--enable
-tracing
441 $compiler_flags = "";
447 } elsif($line eq "2"){
448 $compiler_flags = "-g -O0";
450 } elsif($line eq "4" ){
451 $compiler_flags = "--with-production --enable-tracing";
453 } elsif($line eq "3" || $line eq ""){
454 $compiler_flags = "--with-production";
456 } elsif($line eq "5"){
458 print "Enter compiler options: ";
461 $compiler_flags = $input_line;
465 print "Invalid option, please try again :P\n"
472 # Determine the target to build.
473 # We want this simple so we just give 2 options
478 What
do you want to build?
479 1) Charm
++ [default] (choose this
if you are building NAMD
)
480 2) Charm
++, AMPI
, ParFUM
, FEM
and other libraries
486 if($line eq "1" || $line eq ""){
489 } elsif($line eq "2"){
493 print "Invalid option, please try again :P\n"
498 # Determine whether to use a -j flag for faster building
502 Do you want to compile
in parallel?
507 5) Build with
-j16
[default]
518 } elsif($line eq "2") {
521 } elsif($line eq "3") {
524 } elsif($line eq "4") {
527 } elsif($line eq "5" || $line eq "") {
530 } elsif($line eq "6") {
533 } elsif($line eq "7") {
537 print "Invalid option, please try again :P\n";
542 # Compose the build line
543 $build_line = "./build $target $arch $compilers $options $smp $j $nobs ${compiler_flags}\n";
546 # Save the build line in the log
547 open(BUILDLINE
, ">>smart-build.log");
548 print BUILDLINE
`date`;
549 print BUILDLINE
"Using the following build command:\n";
550 print BUILDLINE
"$build_line\n";
554 print "We have determined a suitable build line is:\n";
555 print "\t$build_line\n\n";
558 # Execute the build line if the appropriate architecture directory exists
559 print "Do you want to start the build now? [Y/n]";
561 if($p eq "yes" || $p eq "default"){
562 if(-e
"src/arch/$arch"){
563 print "Building with: ${build_line}\n";
564 # Execute the build line
567 print "We could not figure out how to build charm with those options on this platform, please manually build\n";
568 print "Try something similar to: ${build_line}\n";