Commit 3d5c6e96 authored by Tharrington, Arnold's avatar Tharrington, Arnold
Browse files

Implementing charm++ path functionality.

parent c6eadc4f
Loading
Loading
Loading
Loading
+41 −67
Original line number Diff line number Diff line
@@ -30,24 +30,50 @@ from loggerutils.logger import create_logger_description
from loggerutils.logger import create_logger
import pathoption

def __create_path_description():
    frmt_header = "{0:20s} {1:50.50s}\n"
    frmt_items = frmt_header
    header1 =  frmt_header.format("Option Values", "Path Returned" )  
    header1_len = len(header1)
    log_option_desc = "The permitted options values and returned paths are the following:\n\n"
    log_option_desc += header1
    log_option_desc += "-"*header1_len  + "\n"
    log_option_desc += frmt_items.format("prefix", "The top-level installation directory for charm++.\n")  
    return log_option_desc

def __parse_arguments():
def main():

    # Instantiate a Charm++ pathoption object.
    charm_pathoption = pathoption.create_pathoption()

    # Register all path functions with object charm_pathoption. Each
    # valid option value, <pathkey>, for the option --path <pathkey>
    # need the following:
    #   <pathkey>
    #   A function reference that when invoked will return the installation path for <pathkey>
    #   A description of <pathkey>
    
    # Registering path function for --path prefix
    pathkey = "prefix"
    function_reference = __prefix_path
    pathkey_description = "The top-level installation directory for Charm++."  
    pathoption.register_pathoption(charm_pathoption,pathkey,function_reference,pathkey_description)

    # Parse the command line arugments of this script.
    args = __parse_arguments(charm_pathoption)

    logger.info("Start of main program")

    # Print the installation path. The arguments to the function reference 
    # is collected in values. Note the aruguments in values must match the
    # parameters of the function reference.
    values = (args.ncp_prefix,
              args.machine_name,
              args.software_name,
              args.software_version,
              args.ncp_pe_key)
    pathoption.print_path(charm_pathoption,
                          args.path,
                          *values)

    logger.info("End of main program")

def __parse_arguments(charm_pathoption):

    import logging

    # Create a string of the description of the 
    # program
    program_description = "Returns installation paths for charm++ software."
    program_description = "Returns installation paths for Charm++ software."

    # Create an argument parser.
    my_parser = argparse.ArgumentParser(
@@ -82,12 +108,6 @@ def __parse_arguments():
        type=str,
        metavar='<software version>')

    mandatory_args_group.add_argument("--charmarch",
        help="The target architecture of the charm++ build.",
        required=True,
        type=str,
        metavar='<charm arch>')

    mandatory_args_group.add_argument("--ncp-prefix",
                           help="The top-level directory where all NAMD dependent software is installed under.",
                           required=True,
@@ -101,65 +121,19 @@ def __parse_arguments():
                           metavar='<ncp pe key>')
                           
    mandatory_args_group.add_argument("--path",
                                      help=__create_path_description(),
                                      help=pathoption.create_path_description(charm_pathoption),
                                      required=True,
                                      type=str,
                                      choices=[ _PATH_OPTIONS['prefix'][0], _PATH_OPTIONS['original_charmbase'][0],
                                      choices=pathoption.get_pathoption_keys(charm_pathoption),
                                      metavar="<path key>")
    my_args = my_parser.parse_args()

    return my_args 

def __print_path(path_option_value,
                 ncp_prefix,
                 machine_name,
                 software_name,
                 software_version,
                 ncp_pe_key,
                 charmarch):
    import sys
    fp = _PATH_OPTIONS[path_option_value]
    tmp_path = fp[1](ncp_prefix,machine_name,software_name,software_version,ncp_pe_key,charmarch)
    sys.stdout.write(tmp_path)

def __prefix_path(ncp_prefix,machine_name,software_name,software_version,ncp_pe_key,charmarch):
    import os
    tmp_path = os.path.join(ncp_prefix,machine_name,software_name,software_version,ncp_pe_key,charmarch)
    return tmp_path

def __prefix_original_charmbase():
    import os
    ncp_top_level = os.getenv("NCP_TOP_LEVEL")
    tmp_path = os.path.join(ncp_top_level,sw,sources,charm)
    return tmp_path
    
## @var dict _PATH_OPTIONS
## @brief Stores the option  and a function reference
##
## @details Each installation path is associated with key, and for a given "key" : 
## ""key" : The key associated for the desired installation path.
## _PATH_OPTIONS["key"][0] : A --path option value. 
## _PATH_OPTIONS["key"][1] : A reference to a function that will print the corresponding  path installation.
_PATH_OPTIONS = {"prefix" : [ "prefix", __prefix_path],
                 "original_charmbase" : ["original_charmbase", __prefix_original_charmbase] }
## @fn main ()
## @brief The main function.
def main():
    args = __parse_arguments()
    logger = create_logger(log_id='Default',
                           log_level=args.log_level)

    logger.info("Start of main program")

    __print_path(args.path,
                 args.ncp_prefix,
                 args.machine_name,
                 args.software_name,
                 args.software_version,
                 args.ncp_pe_key,
                 args.charmarch)

    logger.info("End of main program")

if __name__ == "__main__":
    main()
+102 −48
Original line number Diff line number Diff line
@@ -14,15 +14,17 @@ all software and finally run the NAMD binary benchmarks.
Setting Essential Environmental Variables
-----------------------------------------

Setting Scratch, Installation and Results Directories

The following environmental variables must be set to run this package:

- **NCP\_TOP\_LEVEL** Defines the directory path to top level of this package.

- **NCP\_MACHINE\_NAME** Defines the machine to run the benchmarks/tests on.

- **NCP\_PE\_KEY** Defines the programming environment.  
- **NCP\_PE\_KEY** Defines the programming environment. This environmental variable
  is used as a key for the Lua table, i.e. an associative array, hash, dictionary, etc.,
  to set the values of the Lmod modulefiles to load. Examine the file 
  *${NCP\_TOP\_LEVEL}/runtime\_environment/Crusher/Crusher\_core\_runtime\_environment.lua*
  to see an example.

- **NCP\_SCRATCH** Defines the location where the NAMD benchmarks are run.

@@ -33,8 +35,11 @@ The following environmental variables must be set to run this package:
  are stored under.

There are sample convenience scripts that can be used as guides to set the above 
environment. The scripts are located in the directory ${NCP\_TOP\_LEVEL}. Copy
and modify a sample convenience script, then source it.
environment. The scripts are located in the directory ::

    ${NCP_TOP_LEVEL}/etc/essential_environmental_variables.

Copy a script to the top-level, modify it to suite your needs and then source it.


Setting Core Package Environmental Variables
@@ -43,80 +48,129 @@ Setting Core Package Environmental Variables
The next step is to set core path environmental variables by
doing the following command ::

    source ./runtime\_environment/core\_runtime\_environment.sh
    source ${NCP_TOP_LEVEL}/runtime_environment/core_runtime_environment.sh

Note this command must be executed in the top level of this package. This will
modify your **PATH**, **PYTHONPATH**
This command will modify your **PATH**, **PYTHONPATH**
environmental variables, and make available Lmod modules to build and run the
appropriate NAMD benchmarks.<br>
appropriate NAMD benchmarks.

Setting Machine Package Environmental Variables
-----------------------------------------------

The next step is load the module that corresponds to your specific machine.
We shall assume that we are targeting OLCF's Crusher development machine.  
We therefore load OLCF's machine modulefile
*Crusher/Crusher\_core\_runtime\_environment.lua* ::

## Setting Machine Package Environmental Variables.
    module load Crusher/Crusher_core_runtime_environment

The next step is load the module that corresponds to your specific machine. For
example, for the OLCF machine Spock load the module file
*Spock/Spock\_core\_runtime\_environment.lua*
This will set the appropriate programming environment based upon the
environmental variable **NCP\_PE\_KEY** and define the environmental variable
**MACHINE\_NAME**.

**module load Spock/Spock\_core\_runtime\_environment**<br>
Important! All machine modulefiles name must have the format::

This will set the appropriate programming environment, the **MACHINE\_NAME** environmental
variable.<br>
    ${NCP_MACHINE_NAME}_core_runtime_environment.lua

## Downloading the Prerequisite Software Packages and NAMD.
and be located at ::

The next step is to download the software TCL and charm++.<br>
   ${NCP_TOP_LEVEL}/runtime_environment/${NCP_MACHINE_NAME}/${NCP_MACHINE_NAME}_core_runtime_environment.lua

### Downloading TCL

To download TCL run the command<br>
Downloading the Prerequisite Software Packages and NAMD
-------------------------------------------------------

**download\_tcl.sh**<br>
The next step is to download the software TCL and Charm++

Downloading TCL
~~~~~~~~~~~~~~~

To download TCL run the command ::

    download_tcl.sh

This will download the tarball *tcl8.5.9-src.tar.gz* and unpack in directory
*${NCP_TOP_LEVEL}/sw/sources*. One may have to run the script several
times to successfully download TCL.<br>
*${NCP_TOP_LEVEL}/sw/sources*. One may have to run the script several times to
successfully download TCL.

Downloading Charm++
~~~~~~~~~~~~~~~~~~~

To download charm++ run the command ::

    download_charm.sh

This will clone Charm++ to *${NCP_TOP_LEVEL}/sw/sources/charm* and checkout
branch *v7.0.0-rc1*.

Downloading NAMD
~~~~~~~~~~~~~~~~

To download NAMD source one must visit the URL ::

    https://www.ks.uiuc.edu/Research/namd/ 

and hoover over *software*, then hoover over *NAMD*, and finally click on
*Download*. A dialog may ask ask for a username and password. Is so, then
please register and set your username and password.  After downloading the
appropriate NAMD version, unpack the tarball in directory ::

    ${NCP_TOP_LEVEL}/sw/sources 

and rename the extracted directory *namd*. The directory
*${NCP_TOP_LEVEL}/sw/sources* will now contain directories

* namd
* tcl8.5.9
* charm

Building Prerequisite Software and NAMD
---------------------------------------

To build NAMD for a particular architecture and network layer, one must load
the appropriate modulefiles. For demonstration purpose we assume we are on
Crusher and target the default programming environment.

### Downloading charm++
The environmental variable **NCP\_PE\_KEY** is important for it defines the
programming environment through the loading of modulefile ::

To download charm++ run the command<br>
    Crusher/Crusher_core_runtime_environment.lua* 
    
**download_charm.sh**<br>
For this example **NCP\_PE\_KEY** has the value of 'default'. The Crusher
'default' programming environment on Crusher targets an NAMD build for
multicore. If one echos the variables **NCP\_CHARM\_MODULE** and the
**NCP_NAMD_MODULE**, they will show which Charm++ and NAMD architectures are
being targeted.

This will clone charm++ to *${NCP_TOP_LEVEL}/sw/sources/charm*, and checkout
branch *v7.0.0-rc1*.<br>
Load Lmod modulefiles
~~~~~~~~~~~~~~~~~~~~~

### Downloading NAMD
To download NAMD source one must visit the URL
*https://www.ks.uiuc.edu/Research/namd/*, hoover over *software*, then hoover
over *NAMD*, and finally click on *Download*. A dialog will then ask for a
username and password. Please register and set your username and password.
Unpack the tarball in directory *${NCP_TOP_LEVEL}/sw/sources* and rename the
directory from *NAMD\_Git-2021-09-13\_Source* to *namd*.
For the default target on OLCF's Crusher we load the modulefile by the command ::

## Building Prerequisite Software and NAMD
    module load ${NCP_NAMD_MODULE}

### Load Lmod modulefiles
To build the multinode(SMP version of NAMD) we load the Lmod module file 
*Spock/namd/namd-ofi-linux-x86\_64\_\_gnu\_\_cpu.lua*<br>
If one echos the variable **NCP_NAMD_MODULE** one will see it is set to ::

**module load Spock/namd/namd-ofi-linux-x86_64\_\_gnu\_\_cpu**<br>
    Crusher/namd/default/multicore-linux-x86_64-gfortran-gcc

This will load the correct fftw, charm++, and tcl module files.<br>

### Building TCL and charm++
Building TCL and charm++
~~~~~~~~~~~~~~~~~~~~~~~~

At this point TCL and charm++ must be built. To build TCL run the command<br>
At this point TCL and charm++ must be built. To build TCL run the command ::

**build_tcl.sh**<br>
    build_tcl.sh**

TCL will be installed in directory *${NCP_TOP_LEVEL}/sw/Spock/tcl/8.5.9/*.<br>
TCL will be installed in directory *${NCP_TOP_LEVEL}/sw/Crusher/tcl/8.5.9/*.

To build charm++, run the command<br> 
To build charm++, run the command 

**build_charm.sh --help**<br>
    build_charm.sh --help

This will list the available builds for each machine. Then run the command
This will list the available builds for each machine. Then run the command ::

**build_charm.sh --target-machine ${MACHINE\_NAME} --target-build ${CHARM\_TARGET\_BUILD} **<br>
    build_charm.sh --target-machine ${MACHINE_NAME} --target-build ${CHARM_TARGET_BUILD}

This will build the charm++ transport layer and install charm++ within
directory *${CHARMBASE}/${CHARMARCH}*.<br>
+0 −6
Original line number Diff line number Diff line
@@ -29,12 +29,6 @@ export PATH="${NCP_TOP_LEVEL}/bin:${PATH}"
#-----------------------------------------------------
export PYTHONPATH="${NCP_TOP_LEVEL}/bin/lib:${PYTHONPATH}"

#-----------------------------------------------------
# Modify the environmental variable LUA_PATH         -
#                                                    -
#-----------------------------------------------------
export LUA_PATH="${NCP_TOP_LEVEL}/bin/lua;${LUA_PATH};;"

#-----------------------------------------------------
# We need to make available the modules needed       -
# to build and run NAMD.                             -