Skip to content

Commit

Permalink
updated screen output; improved callsite argument detection; version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Youngsung Kim committed Sep 30, 2022
1 parent 2015c53 commit 7eea1a0
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 13 deletions.
3 changes: 2 additions & 1 deletion examples/miniWeather/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ FC := ftn

INCLUDES := -I${OLCF_PARALLEL_NETCDF_ROOT}/include
LIBS := -L${OLCF_PARALLEL_NETCDF_ROOT}/lib -lpnetcdf
MACROS := -D_NX=${NX} -D_NZ=${NZ} -D_SIM_TIME=${SIM_TIME} -D_OUT_FREQ=${OUT_FREQ} -D_DATA_SPEC=${DATA_SPEC}
MACROS := -D_NX=${NX} -D_NZ=${NZ} -D_SIM_TIME=${SIM_TIME} \
-D_OUT_FREQ=${OUT_FREQ} -D_DATA_SPEC=${DATA_SPEC}

F_FLAGS := ${INCLUDES} ${LIBS} ${MACROS} -h noacc,noomp

Expand Down
5 changes: 5 additions & 0 deletions examples/miniWeather/miniWeather_mpi.F90
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ subroutine compute_tendencies_z(state,flux,tend,dt)
real(rp) :: r,u,w,t,p, stencil(4), d3_vals(NUM_VARS), vals(NUM_VARS), hv_coef
!Compute the hyperviscosity coeficient
hv_coef = -hv_beta * dz / (16*dt)

!$kgen begin_callsite tend_z

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! TODO: THREAD ME
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down Expand Up @@ -373,6 +376,8 @@ subroutine compute_tendencies_z(state,flux,tend,dt)
enddo
enddo

!$kgen end_callsite

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! TODO: THREAD ME
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down
10 changes: 8 additions & 2 deletions fortlab/kernel/kernelgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ def perform(self, args):
state_realpath = os.path.realpath(os.path.join(args.outdir, "state"))
kernel_realpath = os.path.realpath(os.path.join(args.outdir, "kernel"))

print("==== Generating state data files ====")

self.config["path"]["kernel_output"] = kernel_realpath
self.config["path"]["state_output"] = state_realpath

Expand Down Expand Up @@ -187,6 +189,8 @@ def perform(self, args):
(("0", "0"), ("0", "0"), ("1", "1"))
)

print("==== Generating kernel files ====")

plugins = (
("ext.gencore", gencore_plugindir),
("ext.verification", verify_plugindir),
Expand Down Expand Up @@ -316,10 +320,12 @@ def perform(self, args):
if self.config["state_switch"]["clean"]:
run_shcmd(self.config["state_switch"]["clean"])

print("==== Generating state data files ====")

out, err, retcode = run_shcmd("make", cwd=state_realpath)

if retcode != 0:
print("ERROR: state make error")
#if retcode != 0:
# print("ERROR: state make error")

out, err, retcode = run_shcmd("make recover", cwd=state_realpath)

Expand Down
2 changes: 1 addition & 1 deletion fortlab/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class Fortlab(Project):
_name_ = "fortlab"
_version_ = "0.1.18"
_version_ = "1.0.0"
_description_ = "Fortran Kernel and Analysis Framework"
_long_description_ = "Tools for Analysis of Fortran Application and Source code"
_author_ = "Youngsung Kim"
Expand Down
10 changes: 6 additions & 4 deletions fortlab/resolver/kganalyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

from fortlab.kgutils import KGName, ProgramException, UserException, traverse
from fortlab.resolver.kgparse import KGGenType, SrcFile, ResState
from fortlab.resolver.Fortran2003 import Name, Call_Stmt, Function_Reference, Part_Ref, Interface_Stmt, Actual_Arg_Spec_List, \
Section_Subscript_List, Actual_Arg_Spec, Structure_Constructor_2, Proc_Component_Ref, Add_Operand
from fortlab.resolver.Fortran2003 import Name, Call_Stmt, Function_Reference, Part_Ref, Interface_Stmt, \
Actual_Arg_Spec_List, Section_Subscript_List, Actual_Arg_Spec, Structure_Constructor_2, \
Proc_Component_Ref, Add_Operand, Array_Section
from collections import OrderedDict
from fortlab.resolver.typedecl_statements import TypeDeclarationStatement
from fortlab.resolver.block_statements import SubProgramStatement, Associate
Expand Down Expand Up @@ -89,7 +90,7 @@ def get_nodes(node, bag, depth):
argidx = subpobj.args.index(kword)

elif isinstance(argobj, (Name, Proc_Component_Ref,
Add_Operand, Part_Ref)):
Add_Operand, Part_Ref, Array_Section)):
argidx = arglist.items.index(argobj)

else:
Expand Down Expand Up @@ -118,7 +119,8 @@ def get_nodes(node, bag, depth):
# get intent
if argidx>=0:
if argidx >= len(subpobj.args):
raise Exception("argument index exceeds the length of arg. list: %d >= %d",
#import pdb; pdb.set_trace()
raise Exception("argument index exceeds the length of arg. list: %d >= %d" ,
argidx, len(subpobj.args))
argname = subpobj.args[argidx]
var = subpobj.a.variables[subpobj.args[argidx]]
Expand Down
6 changes: 5 additions & 1 deletion fortlab/resolver/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def read_compile_info(self, cinfo, config):
else:
realpath = os.path.realpath(key)

if not os.path.exists(realpath):
if not os.path.exists(realpath) and "CMakeFortranCompilerId.F" not in realpath:
print("WARNING: '%s' does not exist. It may cause failure of KGen analysis." % realpath)

if realpath not in self.config["include"]['file']:
Expand Down Expand Up @@ -387,6 +387,8 @@ def perform(self, args):
from fortlab.resolver.kgsearch import f2003_search_unknowns
import fortlab.resolver.kganalyze as kganalyze

print("==== Analyzing source codes ====")

if args.compile_info:
cinfo = args.compile_info["_"]

Expand Down Expand Up @@ -463,6 +465,8 @@ def perform(self, args):
else:
logger.warn('Stmt does not have "unknowns" attribute: %s'%str(cs_stmt))

print("==== Updating state information ====")

# update state info of callsite and its upper blocks
kganalyze.update_state_info(self.config["parentblock"]['stmt'], self.config)

Expand Down
8 changes: 6 additions & 2 deletions fortlab/scanner/compile/option.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ def __init__(self, mgr):

def perform(self, args):


buildcmd = args.buildcmd["_"]

print("==== Collecting compiler flags (%s) ====" % buildcmd)

cwd = orgcwd = os.getcwd()

Expand All @@ -61,6 +63,8 @@ def perform(self, args):
if not os.path.exists(backupdir):
os.makedirs(backupdir)

print("[Source backup directory] = %s" % backupdir)

inq = multiprocessing.Queue()
outq = multiprocessing.Queue()
proc = multiprocessing.Process(target=self.get_includes, args=(backupdir, inq, outq))
Expand Down Expand Up @@ -122,8 +126,8 @@ def perform(self, args):
if os.path.isfile(src):
inq.put((src, incs))

else:
print("Warning: %s is not backuped" % src)
elif "CMakeFortranCompilerId.F" not in src:
print("Info: %s is not saved in backup directory." % src)

if args.verbose:
print("Compiled: %s by %s" % (src, exepath))
Expand Down
4 changes: 4 additions & 0 deletions fortlab/scanner/timing/timinggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def perform(self, args):
model_realpath = os.path.realpath(os.path.join(args.outdir, "model"))
etime_realpath = os.path.realpath(os.path.join(args.outdir, "etime"))

print("==== Generating timing raw data ====")
print("[timing instrumentation directory] = %s" % etime_realpath)
print("[timing output directory] = %s" % model_realpath)

self.add_forward(etimedir=etime_realpath, modeldir=model_realpath)

data_etime_path = os.path.join(model_realpath, "__data__",
Expand Down
7 changes: 5 additions & 2 deletions fortlab/scanner/timing/timingmodel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Microapp compiler inspector"""

import os, shutil
import os, shutil, multiprocessing

from collections import Mapping

Expand Down Expand Up @@ -38,6 +38,8 @@ def perform(self, args):

datadir = args.datadir["_"]

print("==== Collecting timing data ====")

# collect data
etimes = {} # mpirank:omptid:invoke=[(fileid, linenum, numvisits), ... ]
etimemin = 1.0E100
Expand All @@ -56,7 +58,8 @@ def perform(self, args):
except:
pass

nprocs = 1
nprocs = max(int(multiprocessing.cpu_count()/2), 1)

fwds = {"data": mpipaths}
group_opts = ["--multiproc", "%d" % nprocs, "--assigned-input",
"data:@data", "--clone", "%d" % len(mpipaths), "--data-join", "accumulate"]
Expand Down

0 comments on commit 7eea1a0

Please sign in to comment.