Ignore:
Timestamp:
06/16/11 12:31:47 (13 years ago)
Author:
mmaipsl
Message:

First version for MPI/OpenMP integration in libIGCM.
Work only on titane for instance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_titane.ksh

    r468 r490  
    167167#- Max number of arguments passed to nco operator or demigration command 
    168168UNIX_MAX_LIMIT=360 
     169 
     170NUM_COREPERNODE=8 
     171         
    169172 
    170173#D-#================================================== 
     
    12661269        echo "IGCM_sys_activ_variables" 
    12671270    fi 
    1268     ulimit -s 2097152 
     1271#    ulimit -s 2097152 
     1272 
     1273    typeset max_omp 
     1274 
     1275    ulimit -s unlimited 
     1276 
     1277    (( max_omp = 0 )) 
     1278    for comp in ${config_ListOfComponents[*]} ; do 
     1279         
     1280        eval ExeNameIn=\${config_Executable_${comp}[0]} 
     1281        eval ExeNameOut=\${config_Executable_${comp}[1]} 
     1282         
     1283     
     1284        # Only if we really have an executable for the component : 
     1285        if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" != "XCPL" ] ) ; then 
     1286            eval comp_proc_omp_loc=\${${comp}_PROC_OMP} 
     1287 
     1288            if [ ${comp_proc_omp_loc} -gt ${max_omp} ] ; then 
     1289 
     1290                (( max_omp = comp_proc_omp_loc )) 
     1291            fi 
     1292        fi 
     1293    done 
     1294    if [ ${max_omp} -gt 1 ] ; then 
     1295        module load openmp/${max_omp}thds 
     1296    fi 
     1297 
    12691298    IGCM_debug_PopStack "IGCM_sys_activ_variables" 
    12701299} 
     
    12811310} 
    12821311 
     1312 
     1313# function IGCM_sys_build_run_file { 
    12831314############################################################ 
    12841315# Build run file 
    12851316 
    1286 function IGCM_sys_build_run_file { 
    1287     IGCM_debug_PushStack "IGCM_sys_build_run_file" $@ 
    1288     if ( $DEBUG_sys ) ; then 
    1289         echo "IGCM_sys_build_run_file " $@ 
    1290     fi 
    1291  
    1292     # set Number of processors for OCE here 
    1293     NUM_PROC_OCE=5 
    1294  
    1295     (( NUM_PROC_ATM = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE - 1)) 
    1296     (( nb_tot_m1    = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE )) 
    1297     if [ $1 = MPI1 ]; then 
    1298         cat <<EOF > run_file 
    1299 -np 1 ./oasis 
    1300 -np ${NUM_PROC_ATM} ./lmdz.x 
    1301 -np ${NUM_PROC_OCE} ./opa.xx 
    1302 EOF 
    1303         config_UserChoices_JobRunOptions='"--app"' 
    1304         IGCM_sys_Chmod u+x run_file 
    1305     fi 
    1306     IGCM_debug_PopStack "IGCM_sys_build_run_file" 
     1317#     IGCM_debug_PushStack "IGCM_sys_build_run_file" $@ 
     1318#     if ( $DEBUG_sys ) ; then 
     1319#       echo "IGCM_sys_build_run_file " $@ 
     1320#     fi 
     1321 
     1322#     # set Number of processors for OCE here 
     1323#     NUM_PROC_OCE=5 
     1324 
     1325#     (( NUM_PROC_ATM = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE - 1)) 
     1326#     (( nb_tot_m1    = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE )) 
     1327#     if [ $1 = MPI1 ]; then 
     1328#       cat <<EOF > run_file 
     1329# -np 1 ./oasis 
     1330# -np ${NUM_PROC_ATM} ./lmdz.x 
     1331# -np ${NUM_PROC_OCE} ./opa.xx 
     1332# EOF 
     1333#       config_UserChoices_JobRunOptions='"--app"' 
     1334#       IGCM_sys_Chmod u+x run_file 
     1335#     fi 
     1336#     IGCM_debug_PopStack "IGCM_sys_build_run_file" 
    13071337   
    1308 } 
     1338# } 
     1339 
     1340############################################################ 
     1341# Build MPI/OMP scripts 
     1342function IGCM_sys_build_execution_scripts  
     1343{ 
     1344    IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@ 
     1345    if ( $DEBUG_sys ) ; then 
     1346        echo "IGCM_sys_build_execution_scripts " $@ 
     1347    fi 
     1348 
     1349    # Verification with PBS parameter 
     1350    if [ X${BATCH_NUM_PROC_TOT} != X ] ; then 
     1351 
     1352        if ( ${OK_PARA_MPI} ) ; then 
     1353            EXECUTION=${HOST_MPIRUN_COMMAND} 
     1354        else 
     1355            if [ ${BATCH_NUM_PROC_TOT} -eq 1 ] ; then 
     1356                EXECUTION=${MPIRUN_COMMAND:="time "} 
     1357            fi 
     1358        fi 
     1359    else 
     1360        if ( ! ${OK_PARA_MPI} ) ; then 
     1361            EXECUTION=${MPIRUN_COMMAND:="time "} 
     1362        fi 
     1363    fi 
     1364 
     1365    if [ ${PROCESSUS_NUMBER} -gt 1 ] ; then 
     1366 
     1367    #  Hosts treatment 
     1368 
     1369        ${EXECUTION} hostname | sort | uniq > hosts.tmp 
     1370         
     1371        i=0 
     1372        rm -f hosts 
     1373        IGCM_debug_Print 1 "sys Titane, Hosts avaible :" 
     1374        for nodes in `cat hosts.tmp` 
     1375        do 
     1376            host[$i]=$nodes 
     1377            echo "${host[$i]} slots=8 max_slots=8" >> hosts 
     1378            IGCM_debug_Print 1 ${host[$i]} 
     1379            i=$((i+1)) 
     1380        done 
     1381        rm -f hosts.tmp 
     1382 
     1383        listnodes=${host[*]} 
     1384     
     1385        EXECUTION="${EXECUTION} -hostfile hosts"  
     1386    fi 
     1387 
     1388# Initialisation 
     1389 
     1390    init_node=y 
     1391    node_num_current=0 
     1392    start_num=0 
     1393    init_exec=n 
     1394 
     1395 
     1396# Test : if oasis is there, we put it at the first position 
     1397                 
     1398    for comp in ${config_ListOfComponents[*]} ; do 
     1399         
     1400        if [ "X${comp}" = "XCPL" ]  ; then 
     1401             
     1402            eval ExeNameIn=\${config_Executable_${comp}[0]} 
     1403            eval ExeNameOut=\${config_Executable_${comp}[1]} 
     1404             
     1405            echo "#!/bin/ksh" > script_${ExeNameOut}.ksh 
     1406            echo ""  >> script_${ExeNameOut}.ksh 
     1407            echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh 
     1408            echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh 
     1409            echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh 
     1410            echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err"  >> script_${ExeNameOut}.ksh 
     1411            IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh 
     1412             
     1413            init_node=n 
     1414             
     1415            (( nombre_restant_node = NUM_COREPERNODE - 1 )) 
     1416            node_num_current=0 
     1417            node_current=${host[${node_num_current}]} 
     1418             
     1419            EXECUTION="${EXECUTION} -H ${node_current} -np 1 ./script_${ExeNameOut}.ksh"  
     1420             
     1421            init_exec=y 
     1422            start_num=1 
     1423             
     1424        fi 
     1425         
     1426    done 
     1427     
     1428# Then loop on the components (except for oasis) 
     1429 
     1430    for comp in ${config_ListOfComponents[*]} ; do 
     1431         
     1432        eval ExeNameIn=\${config_Executable_${comp}[0]} 
     1433        eval ExeNameOut=\${config_Executable_${comp}[1]} 
     1434         
     1435     
     1436        # Only if we really have an executable for the component : 
     1437        if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" != "XCPL" ] ) ; then 
     1438 
     1439            eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} 
     1440            eval comp_proc_omp_loc=\${${comp}_PROC_OMP} 
     1441             
     1442            if ( ${OK_PARA_MPI} ) ; then  
     1443                 
     1444                echo "#!/bin/ksh" > script_${ExeNameOut}.ksh 
     1445#               echo "set -vx" >> script_${ExeNameOut}.ksh 
     1446                echo ""  >> script_${ExeNameOut}.ksh 
     1447                echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh 
     1448                echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh 
     1449                echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh 
     1450                echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh 
     1451                echo "(( MYMPIRANK = OMPI_COMM_WORLD_RANK - ${start_num})) " >>  script_${ExeNameOut}.ksh 
     1452                echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${MYMPIRANK} 2>out_${ExeNameOut}.err.\${MYMPIRANK}"  >> script_${ExeNameOut}.ksh 
     1453                IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh 
     1454                 
     1455                node_num=0 
     1456                 
     1457# We define the number of MPI process to be assigned for the component  
     1458 
     1459                nombre_restant_comp=${comp_proc_mpi_loc} 
     1460                 
     1461# Loop on the allocated nodes 
     1462 
     1463                for node in ${listnodes} ; do 
     1464 
     1465# We go to the current node 
     1466 
     1467                    if [ ${node_num} = ${node_num_current} ] ; then 
     1468 
     1469                        node_current=${host[${node_num_current}]} 
     1470 
     1471# If first time on the node : initialisation  
     1472 
     1473                        if [ ${init_node} = y ] ; then 
     1474                            nombre_restant_node=${NUM_COREPERNODE} 
     1475                        fi 
     1476         
     1477# Test on the number of OMP threads 
     1478 
     1479                        if [ ${comp_proc_omp_loc} -gt ${nombre_restant_node} ] ; then 
     1480                            (( node_num = node_num + 1 )) 
     1481                            node_num_current=${node_num} 
     1482                            init_node=y 
     1483                            continue 
     1484                        fi 
     1485 
     1486# Number of MPI process to assign 
     1487 
     1488                        (( num_corempi = nombre_restant_node / comp_proc_omp_loc )) 
     1489  
     1490                        if [ ${num_corempi} -gt ${nombre_restant_comp} ] ; then 
     1491                            num_corempi=${nombre_restant_comp} 
     1492                        fi 
     1493 
     1494                        (( nombre_restant_node = nombre_restant_node - num_corempi * comp_proc_omp_loc )) 
     1495                        (( nombre_restant_comp = nombre_restant_comp - num_corempi )) 
     1496                     
     1497                        if [ ${init_exec} = y ] ; then 
     1498                            EXECUTION="${EXECUTION} : -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh" 
     1499                        else     
     1500                            EXECUTION="${EXECUTION} -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh" 
     1501                            init_exec=y 
     1502                        fi 
     1503 
     1504                        ((  start_num = num_corempi + start_num )) 
     1505         
     1506                    else 
     1507                         
     1508                        (( node_num = node_num + 1 ))  
     1509                        continue 
     1510                    fi 
     1511                 
     1512# Test on the number of core/process remaining on the node/component  
     1513                 
     1514                    if [ ${nombre_restant_node} = 0 ] ; then 
     1515                        (( node_num = node_num + 1 )) 
     1516                        node_num_current=${node_num} 
     1517                        init_node=y 
     1518 
     1519                        if [ ${nombre_restant_comp} = 0 ] ; then 
     1520                            break 1 
     1521                        fi 
     1522                    else 
     1523 
     1524                        node_num_current=${node_num} 
     1525                        init_node=n 
     1526                         
     1527                        if [ ${nombre_restant_comp} = 0 ] ; then 
     1528                            break 1 
     1529                        fi 
     1530                    fi 
     1531                done 
     1532            else 
     1533                EXECUTION="${EXECUTION} ./${ExeNameOut}" 
     1534            fi 
     1535        fi 
     1536    done 
     1537 
     1538    IGCM_debug_Print 1 "sys Titane : La commande d execution est " 
     1539    IGCM_debug_Print 1 $EXECUTION 
     1540 
     1541    IGCM_debug_PopStack "IGCM_sys_build_execution_scripts" 
     1542} 
     1543 
     1544 
    13091545 
    13101546############################################################## 
Note: See TracChangeset for help on using the changeset viewer.