4 # This is an interactive script that knows
5 # common ways to build Charm++ and AMPI.
7 # Authors: dooley, becker
12 # Turn off I/O buffering
17 # A subroutine that reads from input and returns a yes/no/default
21 if(lc($line) eq "y" || lc($line) eq "yes" ){
23 } elsif(lc($line) eq "n" || lc($line) eq "no" ){
25 } elsif( $line eq "" ){
32 # The beginning of the good stuff:
33 print "\n============================================================\n";
34 print "\nBegin interactive charm configuration ...\n";
35 print "If you are a poweruser expecting a list of options, please use ./build --help\n";
36 print "\n============================================================\n\n\n";
39 # Use uname to get the cpu type and OS information
43 #Variables to hold the portions of the configuration:
49 #remove newlines from these strings:
57 } elsif ($os eq "Darwin") {
59 } elsif ($os =~ m/BSD/ ) {
61 } elsif ($os =~ m/OSF1/ ) {
63 } elsif ($os =~ m/AIX/ ) {
65 } elsif ($os =~ m/CYGWIN/ ) {
66 print "Detected a Cygwin system\n";
67 print "This uses the gnu compiler by default,\n";
68 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";
78 # Determine architecture (x86, ppc, ...)
79 if($cpu =~ m/i[0-9]86/){
81 } elsif($cpu =~ m/x86\_64/){
83 } elsif($cpu =~ m/ia64/){
85 $nobs = "--no-build-shared";
86 } elsif($cpu =~ m/powerpc/){
88 } elsif($cpu =~ m/Power Mac/){
90 } elsif($cpu =~ m/ppc*/){
92 } elsif($cpu =~ m/alpha/){
99 my $converse_network_type = "netlrts";
100 my $skip_choosing = "false";
102 print "Are you building to run just on the local machine, and not across multiple nodes? [";
103 if($arch_os eq "darwin") {
109 my $p = promptUserYN
();
110 if($p eq "yes" || ($arch_os eq "darwin" && $p eq "default")){
111 $converse_network_type = "multicore";
112 $skip_choosing = "true";
118 my $mpi_found = "false";
119 my $m = system("which mpicc mpiCC > /dev/null 2>/dev/null") / 256;
125 $m = system("which mpicc mpicxx > /dev/null 2>/dev/null") / 256;
128 $mpioption = "mpicxx";
131 # Give option of just using the mpi version if mpicc and mpiCC are found
132 if($skip_choosing eq "false" && $mpi_found eq "true"){
133 print "\nI found that you have an mpicc available in your path.\nDo you want to build Charm++ on this MPI? [y/N]: ";
134 my $p = promptUserYN
();
136 $converse_network_type = "mpi";
137 $skip_choosing = "true";
138 $options = "$options $mpioption";
142 if($skip_choosing eq "false") {
144 print "\nDo you have a special network interconnect? [y/N]: ";
145 my $p = promptUserYN
();
149 Choose an interconnect from below
: [1-10]
151 2) Infiniband
(ibverbs
)
154 5) Blue Gene
/P Native
160 while(my $line = <>){
163 $converse_network_type = "mpi";
165 } elsif($line eq "2"){
166 $converse_network_type = "verbs";
168 } elsif($line eq "3"){
169 $arch = "gni-crayxe";
171 } elsif($line eq "4"){
172 $arch = "gni-crayxc";
174 } elsif($line eq "5"){
178 } elsif($line eq "6"){
179 $arch = "mpi-bluegenep";
182 } elsif($line eq "7"){
183 $arch = "pamilrts-bluegeneq";
186 print "Invalid option, please try again :P\n"
193 # construct an $arch string if we did not explicitly set one above
195 $arch = "${converse_network_type}-${arch_os}";
197 $arch = $arch . "-x86_64";
199 $arch = $arch . "-ia64";
201 $arch = $arch . "-ppc";
203 $arch = $arch . "-axp";
207 # Fixup $arch to match the inconsistent directories in src/archs
209 if($arch eq "net-darwin"){
210 $arch = "net-darwin-x86";
211 } elsif($arch eq "net-ppc-darwin"){
212 $arch = "net-darwin-ppc";
213 } elsif($arch eq "mpi-ppc-darwin"){
214 $arch = "mpi-darwin-ppc";
215 } elsif($arch eq "multicore-linux-x86_64"){
216 $arch = "multicore-linux64";
220 #================ Choose SMP/PXSHM =================================
222 # find what options are available
223 my $opts = `./build charm++ $arch help 2>&1 | grep "Supported options"`;
224 $opts =~ m/Supported options: (.*)/;
227 my $smp_opts = <<EOF;
228 1) single-threaded [default]
231 # only add the smp or pxshm options if they are available
232 my $counter = 1; # the last index used in the list
237 $smp_opts = $smp_opts . " $counter) SMP\n";
238 $smpIndex = $counter;
242 if($opts =~ m/pxshm/){
244 $smp_opts = $smp_opts . " $counter) POSIX Shared Memory\n";
245 $pxshmIndex = $counter;
249 print "How do you want to handle SMP/Multicore: [1-$counter]\n";
252 while(my $line = <>){
254 if($line eq "" || $line eq "1"){
256 } elsif($line eq $smpIndex){
257 $options = "$options smp ";
259 } elsif($line eq $pxshmIndex){
260 $options = "$options pxshm ";
267 #================ Choose Compiler =================================
269 # Lookup list of compilers
270 my $cs = `./build charm++ $arch help 2>&1 | grep "Supported compilers"`;
271 # prune away beginning of the line
272 $cs =~ m/Supported compilers: (.*)/;
274 # split the line into an array
275 my @c_list = split(" ", $cs);
277 # print list of compilers
281 print "\nDo you want to specify a compiler? [y/N]";
282 my $p = promptUserYN
();
284 print "Choose a compiler: [1-$numc] \n";
287 foreach my $c (@c_list){
293 while(my $line = <>){
295 if($line =~ m/([0-9]*)/ && $1 > 0 && $1 <= $numc){
296 $compilers = $c_list[$1-1];
299 print "Invalid option, please try again :P\n"
308 #================ Choose Options =================================
310 #Create a hash table containing descriptions of various options
311 my %explanations = ();
312 $explanations{"ooc"} = "Out-of-core execution support in Charm++";
313 $explanations{"tcp"} = "Charm++ over TCP instead of UDP for net versions. TCP is slower";
314 $explanations{"ifort"} = "Use Intel's ifort fortran compiler";
315 $explanations{"gfortran"} = "Use gfortran compiler for fortran";
316 $explanations{"g95"} = "Use g95 compiler";
317 $explanations{"ifort"} = "Use Intel's ifort fortran compiler";
318 $explanations{"pgf90"} = "Use Portland Group's pgf90 fortran compiler";
319 $explanations{"ifc"} = "Use Intel's ifc compiler";
320 $explanations{"ammasso"} = "Use native RDMA support on Ammasso interconnect";
321 $explanations{"syncft"} = "Use initial fault tolerance support";
322 $explanations{"mlogft"} = "Use message logging fault tolerance support";
323 $explanations{"causalft"} = "Use causal message logging fault tolerance support";
329 # Produce list of options
331 $opts = `./build charm++ $arch help 2>&1 | grep "Supported options"`;
332 # prune away beginning of line
333 $opts =~ m/Supported options: (.*)/;
336 my @option_list = split(" ", $opts);
339 # Prune out entries that would already have been chosen above, such as smp
340 my @option_list_pruned = ();
341 foreach my $o (@option_list){
342 if($o ne "smp" && $o ne "ibverbs" && $o ne "gm" && $o ne "mx"){
343 @option_list_pruned = (@option_list_pruned , $o);
348 @option_list_pruned = sort @option_list_pruned;
349 if (@option_list_pruned > 0) {
351 print "\nDo you want to specify any Charm++ build options, such as fortran compilers? [y/N]";
352 my $special_options = promptUserYN
();
354 if($special_options eq "yes"){
356 # print out list for user to select from
357 print "Please enter one or more numbers separated by spaces\n";
360 foreach my $o (@option_list_pruned){
361 my $exp = $explanations{$o};
363 # pad whitespace before options
364 for(my $j=0;$j<20-length($o);$j++){
371 print "\t$i)\tNone Of The Above\n";
373 my $num_options = @option_list_pruned;
375 while(my $line = <>){
377 $line =~ m/([0-9 ]*)/;
378 my @entries = split(" ",$1);
379 @entries = sort(@entries);
381 my $additional_options = "";
382 foreach my $e (@entries) {
383 if($e>=1 && $e<= $num_options){
384 my $estring = $option_list_pruned[$e-1];
385 $additional_options = "$additional_options $estring";
386 } elsif ($e == $num_options+1){
387 # user chose "None of the above"
388 # clear the options we may have seen before
389 $additional_options = " ";
393 # if the user input something reasonable, we can break out of this loop
394 if($additional_options ne ""){
395 $options = "$options ${additional_options} ";
404 # Choose compiler flags
407 Choose a set of compiler flags
[1-5]
410 3) production build
[default] --with
-production
411 4) production build w
/ projections
--with
-production
--enable
-tracing
416 my $compiler_flags = "";
418 while(my $line = <>){
422 } elsif($line eq "2"){
423 $compiler_flags = "-g -O0";
425 } elsif($line eq "4" ){
426 $compiler_flags = "--with-production --enable-tracing";
428 } elsif($line eq "3" || $line eq ""){
429 $compiler_flags = "--with-production";
431 } elsif($line eq "5"){
433 print "Enter compiler options: ";
436 $compiler_flags = $input_line;
440 print "Invalid option, please try again :P\n"
447 # Determine the target to build.
448 # We want this simple so we just give 2 options
453 What
do you want to build?
454 1) Charm
++ [default] (choose this
if you are building NAMD
)
455 2) Charm
++, AMPI
, ParFUM
, FEM
and other libraries
459 while(my $line = <>){
461 if($line eq "1" || $line eq ""){
464 } elsif($line eq "2"){
468 print "Invalid option, please try again :P\n"
473 # Determine whether to use a -j flag for faster building
477 Do you want to compile
in parallel?
482 5) Build with
-j16
[default]
488 while(my $line = <>) {
493 } elsif($line eq "2") {
496 } elsif($line eq "3") {
499 } elsif($line eq "4") {
502 } elsif($line eq "5" || $line eq "") {
505 } elsif($line eq "6") {
508 } elsif($line eq "7") {
512 print "Invalid option, please try again :P\n";
517 # Compose the build line
518 my $build_line = "./build $target $arch $compilers $options $j $nobs ${compiler_flags}\n";
521 # Save the build line in the log
522 open(BUILDLINE
, ">>smart-build.log");
523 print BUILDLINE
`date`;
524 print BUILDLINE
"Using the following build command:\n";
525 print BUILDLINE
"$build_line\n";
529 print "We have determined a suitable build line is:\n";
530 print "\t$build_line\n\n";
533 # Execute the build line if the appropriate architecture directory exists
534 print "Do you want to start the build now? [Y/n]";
535 my $p = promptUserYN
();
536 if($p eq "yes" || $p eq "default"){
537 if(-e
"src/arch/$arch"){
538 print "Building with: ${build_line}\n";
539 # Execute the build line
542 print "We could not figure out how to build charm with those options on this platform, please manually build\n";
543 print "Try something similar to: ${build_line}\n";