Changeset 1466 for trunk/libIGCM


Ignore:
Timestamp:
07/13/18 09:38:15 (6 years ago)
Author:
aclsce
Message:
  • On curie, allow to run with mpirun command on MPI-MPMD mode by defining ExecutionModeOnCurie?=mpirun in config.card.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/libIGCM_sys/libIGCM_sys_curie.ksh

    r1459 r1466  
    11401140 
    11411141  if [ ${executionType} -eq 1 ] ; then 
    1142     # MPMD + MPI 
    1143     sed -e "/::openMPthreads::/d"                  \ 
    1144         -e "s/::JobNumProcTot::/${coreNumber}/"    \ 
    1145         -e "/#MSUB -x/d"                           \ 
    1146         -e "/--cpu_bind=none/d"                    \ 
    1147       ${file} > ${file}.tmp 
    1148  
     1142    # MPMD + MPI : mpirun 
     1143    if [ "X${config_UserChoices_ExecutionModeOnCurie}" = "Xmpirun" ] ; then 
     1144        sed -e "/::openMPthreads::/d"                  \ 
     1145            -e "s/::JobNumProcTot::/${coreNumber}/"    \ 
     1146             ${file} > ${file}.tmp 
     1147    else 
     1148        # MPMD + MPI : ccc_mprun 
     1149        sed -e "/::openMPthreads::/d"                  \ 
     1150            -e "s/::JobNumProcTot::/${coreNumber}/"    \ 
     1151            -e "/#MSUB -x/d"                           \ 
     1152            -e "/--cpu_bind=none/d"                    \ 
     1153            ${file} > ${file}.tmp 
     1154    fi 
    11491155  elif [ ${executionType} -eq 2 ] ; then 
    11501156    # MPMD + MPI + OMP : mpirun/ccc_mprun/error 
     
    12451251    if  ( ! ${OK_PARA_OMP} ) ; then 
    12461252 
     1253        if ( [ "X${config_UserChoices_ExecutionModeOnCurie}" = "X" ] || [ "X${config_UserChoices_ExecutionModeOnCurie}" = "Xccc_mprun" ] ) ; then  
     1254      # use of ccc_mprun (default mode)  
    12471255      # Build run_file 
    12481256 
    12491257      # First loop on the components for the coupler ie oasis (only if oasis3) 
    12501258      # the coupler ie oasis3 must be the first one 
    1251       for comp in ${config_ListOfComponents[*]} ; do 
    1252  
    1253         eval ExeNameIn=\${config_Executable_${comp}[0]} 
    1254         eval ExeNameOut=\${config_Executable_${comp}[1]} 
     1259            for comp in ${config_ListOfComponents[*]} ; do 
     1260 
     1261                eval ExeNameIn=\${config_Executable_${comp}[0]} 
     1262                eval ExeNameOut=\${config_Executable_${comp}[1]} 
    12551263 
    12561264        # for CPL component only 
    1257         if [ "X${comp}" = "XCPL" ] && [ "X${ExeNameOut}" != X\"\" ] ; then 
    1258  
    1259           eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} 
    1260           eval comp_proc_omp_loc=\${${comp}_PROC_OMP} 
    1261           echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file 
    1262         fi 
    1263       done 
     1265                if [ "X${comp}" = "XCPL" ] && [ "X${ExeNameOut}" != X\"\" ] ; then 
     1266 
     1267                    eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} 
     1268                    eval comp_proc_omp_loc=\${${comp}_PROC_OMP} 
     1269                    echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file 
     1270                fi 
     1271            done 
    12641272 
    12651273      # Then second loop on the components 
    1266       for comp in ${config_ListOfComponents[*]} ; do 
    1267  
    1268         eval ExeNameIn=\${config_Executable_${comp}[0]} 
    1269         eval ExeNameOut=\${config_Executable_${comp}[1]} 
     1274            for comp in ${config_ListOfComponents[*]} ; do 
     1275 
     1276                eval ExeNameIn=\${config_Executable_${comp}[0]} 
     1277                eval ExeNameOut=\${config_Executable_${comp}[1]} 
    12701278 
    12711279        # Only if we really have an executable for the component and not the coupler ie oasis: 
    1272         if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then 
    1273  
    1274           eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} 
    1275           eval comp_proc_omp_loc=\${${comp}_PROC_OMP} 
    1276           echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file 
    1277         fi 
    1278       done 
    1279  
    1280       EXECUTION="${HOST_MPIRUN_COMMAND} -f ./run_file" 
    1281  
    1282       IGCM_sys_Chmod u+x run_file 
    1283       if ( $DEBUG_sys ) ; then 
    1284         echo "run_file contains : " 
    1285         cat run_file 
    1286       fi 
     1280                if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then 
     1281 
     1282                    eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} 
     1283                    eval comp_proc_omp_loc=\${${comp}_PROC_OMP} 
     1284                    echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file 
     1285                fi 
     1286            done 
     1287 
     1288            EXECUTION="${HOST_MPIRUN_COMMAND} -f ./run_file" 
     1289 
     1290            IGCM_sys_Chmod u+x run_file 
     1291            if ( $DEBUG_sys ) ; then 
     1292                echo "run_file contains : " 
     1293                cat run_file 
     1294            fi 
     1295 
     1296        elif [ "X${config_UserChoices_ExecutionModeOnCurie}" = "Xmpirun" ] ; then 
     1297            # use of mpirun  
     1298 
     1299                  # Use of mpirun instead of ccc_mprun 
     1300            EXECUTION="time mpirun" 
     1301 
     1302      #  Hosts treatment 
     1303            ${EXECUTION} hostname | sort | uniq > hosts.tmp 
     1304 
     1305            i=0 
     1306            rm -f hosts rankfile 
     1307            IGCM_debug_Print 1 "sys Curie, Hosts available :" 
     1308            for nodes in `cat hosts.tmp` 
     1309            do 
     1310                host[$i]=$nodes 
     1311                echo "${host[$i]}" >> hosts 
     1312                IGCM_debug_Print 1 ${host[$i]} 
     1313                i=$((i+1)) 
     1314            done 
     1315            rm -f hosts.tmp 
     1316 
     1317            listnodes=${host[*]} 
     1318 
     1319            EXECUTION="${EXECUTION} -hostfile hosts -rankfile rankfile" 
     1320 
     1321      # Initialisation 
     1322            rank=0 
     1323            current_core=0 
     1324            init_exec=n 
     1325 
     1326      # Loop on the components 
     1327            for comp in ${config_ListOfComponents[*]} ; do 
     1328 
     1329                eval ExeNameIn=\${config_Executable_${comp}[0]} 
     1330                eval ExeNameOut=\${config_Executable_${comp}[1]} 
     1331 
     1332        # Not possible if oasis has an executable (i.e old version of oasis3) 
     1333                if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" = "XCPL" ] ) ; then 
     1334                    IGCM_debug_Exit "ERROR MPMD with hybrid MPI-OpenMP is not available with oasis3 version" 
     1335                    IGCM_debug_Print 2 "Only available with oasis3-MCT version coupler" 
     1336                    IGCM_debug_Verif_Exit 
     1337                fi 
     1338 
     1339        # Only if we really have an executable for the component : 
     1340                if [ "X${ExeNameOut}" != X\"\" ] ; then 
     1341 
     1342                    eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} 
     1343                    eval comp_proc_omp_loc=\${${comp}_PROC_OMP} 
     1344                    eval comp_proc_nod_loc=\${${comp}_PROC_NOD} 
     1345 
     1346                    echo "#!/bin/ksh" > script_${ExeNameOut}.ksh 
     1347                    echo ""  >> script_${ExeNameOut}.ksh 
     1348                    if [ ${comp_proc_omp_loc} -gt 1 ] ; then 
     1349 
     1350            # Check if the number of threads is correct 
     1351                        case ${comp_proc_omp_loc} in 
     1352                            2|4|8|16) 
     1353                                IGCM_debug_Print 1 "You run ${ExeNameOut} on ${comp_proc_omp_loc} OMP threads" 
     1354                                ;; 
     1355                            *) 
     1356                                IGCM_debug_Exit "ERROR with OMP parameters !" 
     1357                                IGCM_debug_Print 2 "${comp_proc_omp_loc} is not possible as number of OMP threads" 
     1358                                IGCM_debug_Print 2 "Only 2,4,8,16 as number of OMP threads are possible " 
     1359                                IGCM_debug_Verif_Exit 
     1360                                ;; 
     1361                        esac 
     1362                        echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh 
     1363                        echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh 
     1364                        echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh 
     1365                        echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh 
     1366                    fi 
     1367 
     1368          #echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh 
     1369                    echo "(( MYMPIRANK = OMPI_COMM_WORLD_RANK )) " >> script_${ExeNameOut}.ksh 
     1370                    echo "MYMPIRANK=\$(printf '%3.3d\n' \${MYMPIRANK})" >> script_${ExeNameOut}.ksh 
     1371                    echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${MYMPIRANK} 2>out_${ExeNameOut}.err.\${MYMPIRANK}" >> script_${ExeNameOut}.ksh 
     1372                    IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh 
     1373 
     1374                    if [ ${init_exec} = y ] ; then 
     1375                        EXECUTION="${EXECUTION} : -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh" 
     1376                    else 
     1377                        EXECUTION="${EXECUTION} -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh" 
     1378                        init_exec=y 
     1379                    fi 
     1380 
     1381          # Build rankfile : method used to assign cores and nodes for the MPI process 
     1382          # Ex : 
     1383          #rank 0=curie5296 slot=0,1,2,3 
     1384          #rank 1=curie5296 slot=4,5,6,7 
     1385          # Example of final command : 
     1386          # mpirun -hostfile hosts -rankfile rankfile -np 27 ./script_lmdz.x.ksh : -np 5 ./script_opa.xx.ksh 
     1387          # with script_lmdz.x.ksh : 
     1388          # #!/bin/ksh 
     1389          #export KMP_STACKSIZE=3g 
     1390          #export KMP_LIBRARY=turnaround 
     1391          #export MKL_SERIAL=YES 
     1392          #OMP_NUM_THREADS=4 
     1393          #./lmdz.x 
     1394                    if [ ${comp_proc_nod_loc} -gt 1 ] ; then 
     1395                        (( offset_comp_proc_loc =  NB_CORE_PER_NODE / (comp_proc_mpi_loc / comp_proc_nod_loc) )) 
     1396                    else 
     1397                        (( offset_comp_proc_loc =  comp_proc_omp_loc )) 
     1398                    fi 
     1399                    for nb_proc_mpi in `seq 0 $(($comp_proc_mpi_loc-1))`; do 
     1400                        (( index_host = current_core / NB_CORE_PER_NODE )) 
     1401                        host_value=${host[${index_host}]} 
     1402                        (( slot =  current_core % NB_CORE_PER_NODE )) 
     1403                        virg="," 
     1404                        string_final="" 
     1405                        for index in `seq $slot $(($slot+$comp_proc_omp_loc-1))`; do 
     1406                            string=$index$virg 
     1407                            string_final=$string_final$string 
     1408                        done 
     1409                        string_final=$( echo $string_final | sed "s/.$//" ) 
     1410                        echo "rank $rank=$host_value slot=$string_final" >> rankfile 
     1411                        (( rank = rank + 1 )) 
     1412                        (( current_core = current_core + offset_comp_proc_loc )) 
     1413                    done 
     1414                fi 
     1415            done 
     1416 
     1417        fi 
    12871418 
    12881419    elif ( [ "X${config_UserChoices_ExecutionModeOnCurie}" = "X" ] || [ "X${config_UserChoices_ExecutionModeOnCurie}" = "Xmpirun" ] ) ; then 
Note: See TracChangeset for help on using the changeset viewer.