4 # This is an interactive script that knows
5 # common ways to build Charm++ and AMPI.
7 # Authors: dooley, becker
12 # Get location of script
14 my $dirname = dirname
(__FILE__
);
16 # Turn off I/O buffering
21 # A subroutine that reads from input and returns a yes/no/default
25 if(lc($line) eq "y" || lc($line) eq "yes" ){
27 } elsif(lc($line) eq "n" || lc($line) eq "no" ){
29 } elsif( $line eq "" ){
36 # The beginning of the good stuff:
37 print "\n============================================================\n";
38 print "\nBegin interactive charm configuration ...\n";
39 print "If you are a poweruser expecting a list of options, please use ./build --help\n";
40 print "\n============================================================\n\n\n";
43 # Use uname to get the cpu type and OS information
47 #Variables to hold the portions of the configuration:
53 #remove newlines from these strings:
61 } elsif ($os eq "Darwin") {
63 } elsif ($os =~ m/BSD/ ) {
65 } elsif ($os =~ m/OSF1/ ) {
74 # Determine architecture (x86, ppc, ...)
75 if($cpu =~ m/i[0-9]86/){
77 } elsif($cpu =~ m/x86\_64/){
79 } elsif($cpu =~ m/powerpc/){
81 } elsif($cpu =~ m/ppc*/){
83 } elsif($cpu =~ m/arm7/){
89 my $converse_network_type = "netlrts";
90 my $skip_choosing = "false";
92 print "Are you building to run just on the local machine, and not across multiple nodes? [";
93 if($arch_os eq "darwin") {
99 my $p = promptUserYN
();
100 if($p eq "yes" || ($arch_os eq "darwin" && $p eq "default")){
101 $converse_network_type = "multicore";
102 $skip_choosing = "true";
108 my $mpi_found = "false";
109 my $m = system("which mpicc mpiCC > /dev/null 2>/dev/null") / 256;
115 $m = system("which mpicc mpicxx > /dev/null 2>/dev/null") / 256;
118 $mpioption = "mpicxx";
121 # Give option of just using the mpi version if mpicc and mpiCC are found
122 if($skip_choosing eq "false" && $mpi_found eq "true"){
123 print "\nI found that you have an mpicc available in your path.\nDo you want to build Charm++ on this MPI? [y/N]: ";
124 my $p = promptUserYN
();
126 $converse_network_type = "mpi";
127 $skip_choosing = "true";
128 $options = "$options $mpioption";
132 if($skip_choosing eq "false") {
134 print "\nDo you have a special network interconnect? [y/N]: ";
135 my $p = promptUserYN
();
139 Choose an interconnect from below
: [1-10]
141 2) Infiniband
(ibverbs
)
145 6) Intel Omni
-Path
(ofi
)
149 while(my $line = <>){
152 $converse_network_type = "mpi";
154 } elsif($line eq "2"){
155 $converse_network_type = "verbs";
157 } elsif($line eq "3"){
158 $arch = "gni-crayxe";
160 } elsif($line eq "4"){
161 $arch = "gni-crayxc";
163 } elsif($line eq "5"){
164 $arch = "pamilrts-bluegeneq";
166 } elsif($line eq "6"){
167 $converse_network_type = "ofi";
170 print "Invalid option, please try again :P\n"
177 # construct an $arch string if we did not explicitly set one above
179 $arch = "${converse_network_type}-${arch_os}";
181 $arch = $arch . "-x86_64";
183 $arch = $arch . "-ppc";
185 $arch = $arch . "-arm7";
189 # Fixup $arch to match the inconsistent directories in src/archs
191 if($arch eq "netlrts-darwin"){
192 $arch = "netlrts-darwin-x86_64";
193 } elsif($arch eq "multicore-linux-arm7"){
194 $arch = "multicore-arm7";
198 #================ Choose SMP/PXSHM =================================
200 # find what options are available
201 my $opts = `$dirname/build charm++ $arch help 2>&1 | grep "Supported options"`;
202 $opts =~ m/Supported options: (.*)/;
205 my $smp_opts = <<EOF;
206 1) single-threaded [default]
209 # only add the smp or pxshm options if they are available
210 my $counter = 1; # the last index used in the list
215 $smp_opts = $smp_opts . " $counter) SMP\n";
216 $smpIndex = $counter;
220 if($opts =~ m/pxshm/){
222 $smp_opts = $smp_opts . " $counter) POSIX Shared Memory\n";
223 $pxshmIndex = $counter;
227 print "How do you want to handle SMP/Multicore: [1-$counter]\n";
230 while(my $line = <>){
232 if($line eq "" || $line eq "1"){
234 } elsif($line eq $smpIndex){
235 $options = "$options smp ";
237 } elsif($line eq $pxshmIndex){
238 $options = "$options pxshm ";
245 #================ Choose Compiler =================================
247 # Lookup list of compilers
248 my $cs = `$dirname/build charm++ $arch help 2>&1 | grep "Supported compilers"`;
249 # prune away beginning of the line
250 $cs =~ m/Supported compilers: (.*)/;
252 # split the line into an array
253 my @c_list = split(" ", $cs);
255 # print list of compilers
259 print "\nDo you want to specify a compiler? [y/N]";
260 my $p = promptUserYN
();
262 print "Choose a compiler: [1-$numc] \n";
265 foreach my $c (@c_list){
271 while(my $line = <>){
273 if($line =~ m/([0-9]*)/ && $1 > 0 && $1 <= $numc){
274 $compilers = $c_list[$1-1];
277 print "Invalid option, please try again :P\n"
286 #================ Choose Options =================================
288 #Create a hash table containing descriptions of various options
289 my %explanations = ();
290 $explanations{"ooc"} = "Out-of-core execution support in Charm++";
291 $explanations{"tcp"} = "Charm++ over TCP instead of UDP for net versions. TCP is slower";
292 $explanations{"gfortran"} = "Use gfortran compiler for fortran";
293 $explanations{"flang"} = "Use flang compiler for fortran";
294 $explanations{"ifort"} = "Use Intel's ifort fortran compiler";
295 $explanations{"pgf90"} = "Use Portland Group's pgf90 fortran compiler";
296 $explanations{"syncft"} = "Use fault tolerance support";
297 $explanations{"mlogft"} = "Use message logging fault tolerance support";
298 $explanations{"causalft"} = "Use causal message logging fault tolerance support";
304 # Produce list of options
306 $opts = `$dirname/build charm++ $arch help 2>&1 | grep "Supported options"`;
307 # prune away beginning of line
308 $opts =~ m/Supported options: (.*)/;
311 my @option_list = split(" ", $opts);
314 # Prune out entries that would already have been chosen above, such as smp
315 my @option_list_pruned = ();
316 foreach my $o (@option_list){
317 if($o ne "smp" && $o ne "ibverbs" && $o ne "gm" && $o ne "mx"){
318 @option_list_pruned = (@option_list_pruned , $o);
323 @option_list_pruned = sort @option_list_pruned;
324 if (@option_list_pruned > 0) {
326 print "\nDo you want to specify any Charm++ build options, such as fortran compilers? [y/N]";
327 my $special_options = promptUserYN
();
329 if($special_options eq "yes"){
331 # print out list for user to select from
332 print "Please enter one or more numbers separated by spaces\n";
335 foreach my $o (@option_list_pruned){
336 my $exp = $explanations{$o};
338 # pad whitespace before options
339 for(my $j=0;$j<20-length($o);$j++){
346 print "\t$i)\tNone Of The Above\n";
348 my $num_options = @option_list_pruned;
350 while(my $line = <>){
352 $line =~ m/([0-9 ]*)/;
353 my @entries = split(" ",$1);
354 @entries = sort(@entries);
356 my $additional_options = "";
357 foreach my $e (@entries) {
358 if($e>=1 && $e<= $num_options){
359 my $estring = $option_list_pruned[$e-1];
360 $additional_options = "$additional_options $estring";
361 } elsif ($e == $num_options+1){
362 # user chose "None of the above"
363 # clear the options we may have seen before
364 $additional_options = " ";
368 # if the user input something reasonable, we can break out of this loop
369 if($additional_options ne ""){
370 $options = "$options ${additional_options} ";
379 # Choose compiler flags
382 Choose a set of compiler flags
[1-5]
385 3) production build
[default] --with
-production
386 4) production build w
/ projections
--with
-production
--enable
-tracing
391 my $compiler_flags = "";
393 while(my $line = <>){
397 } elsif($line eq "2"){
398 $compiler_flags = "-g -O0";
400 } elsif($line eq "4" ){
401 $compiler_flags = "--with-production --enable-tracing";
403 } elsif($line eq "3" || $line eq ""){
404 $compiler_flags = "--with-production";
406 } elsif($line eq "5"){
408 print "Enter compiler options: ";
411 $compiler_flags = $input_line;
415 print "Invalid option, please try again :P\n"
422 # Determine the target to build.
423 # We want this simple so we just give 2 options
428 What
do you want to build?
429 1) Charm
++ [default] (choose this
if you are building NAMD
)
431 3) Charm
++, AMPI
, ParFUM
, FEM
and other libraries
435 while(my $line = <>){
437 if($line eq "1" || $line eq ""){
440 } elsif($line eq "2"){
443 } elsif($line eq "3"){
447 print "Invalid option, please try again :P\n"
452 # Determine whether to use a -j flag for faster building
456 Do you want to compile
in parallel?
461 5) Build with
-j16
[default]
467 while(my $line = <>) {
472 } elsif($line eq "2") {
475 } elsif($line eq "3") {
478 } elsif($line eq "4") {
481 } elsif($line eq "5" || $line eq "") {
484 } elsif($line eq "6") {
487 } elsif($line eq "7") {
491 print "Invalid option, please try again :P\n";
496 # Compose the build line
497 my $build_line = "$dirname/build $target $arch $compilers $options $j $nobs ${compiler_flags}\n";
500 # Save the build line in the log
501 open(BUILDLINE
, ">>smart-build.log");
502 print BUILDLINE
`date`;
503 print BUILDLINE
"Using the following build command:\n";
504 print BUILDLINE
"$build_line\n";
508 print "We have determined a suitable build line is:\n";
509 print "\t$build_line\n\n";
512 # Execute the build line if the appropriate architecture directory exists
513 print "Do you want to start the build now? [Y/n]";
514 my $p = promptUserYN
();
515 if($p eq "yes" || $p eq "default"){
516 if(-e
"$dirname/src/arch/$arch"){
517 print "Building with: ${build_line}\n";
518 # Execute the build line
521 print "We could not figure out how to build charm with those options on this platform, please manually build\n";
522 print "Try something similar to: ${build_line}\n";