Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/grnydawn/fortlab
Browse files Browse the repository at this point in the history
  • Loading branch information
Youngsung Kim committed Oct 4, 2022
2 parents e16d654 + b894308 commit 5ead819
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 1,129 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
44 changes: 15 additions & 29 deletions fortlab/kernel/kernelgen.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# uncompyle6 version 3.7.2
# Python bytecode 2.7 (62211)
# Decompiled from: Python 3.6.9 (default, Apr 18 2020, 01:56:04)
# [GCC 8.4.0]
# Embedded file name: /home/grnydawn/repos/github/fortlab/fortlab/kernel/kernelgen.py
# Compiled at: 2020-07-13 10:26:24
import os, io, locale, math, random, datetime

from collections import OrderedDict
Expand Down Expand Up @@ -133,10 +127,6 @@ def _process_repr_flags(self, opts):
else:
raise UserException('Unknown code-coverage flag option: %s' % copt)

# enable coverage feature at extractor
#if self.config['model']['types']['code']['enabled']:
# self.config['plugin']['priority']['ext.coverage'] = '%s/plugins/coverage'%KGEN_EXT

def perform(self, args):

self.config = args.analysis["_"]
Expand Down Expand Up @@ -187,6 +177,8 @@ def perform(self, args):
(("0", "0"), ("0", "0"), ("1", "1"))
)

print("==== Generating kernel files (%s) ====" % kernel_realpath)

plugins = (
("ext.gencore", gencore_plugindir),
("ext.verification", verify_plugindir),
Expand Down Expand Up @@ -274,6 +266,7 @@ def perform(self, args):
if klines is not None:
klines = remove_multiblanklines(klines)
kernel_files.append(filename)
print(filename)
with io.open(
os.path.join(kernel_realpath, filename), "w", encoding=enc
) as (fd):
Expand All @@ -289,24 +282,25 @@ def perform(self, args):
) as (fd):
fd.write(tounicode(slines))

with io.open(
os.path.join(
kernel_realpath, "%s.f90" % self.config["kernel_driver"]["name"]
),
"w",
encoding=enc,
) as (fd):
kdriver = "%s.f90" % self.config["kernel_driver"]["name"]
with io.open(os.path.join(kernel_realpath, kdriver), "w", encoding=enc,) as (fd):
set_indent("")
lines = driver.tostring()
if lines is not None:
lines = remove_multiblanklines(lines)
fd.write(tounicode(lines))

print(kdriver)

kernel_files.append(self.config["kernel"]["name"])
kernel_files.append(KGUTIL)
print(KGUTIL)

self.generate_kgen_utils(kernel_realpath, enc)
self.generate_kernel_makefile(kernel_realpath, enc)
kernel_files.append("Makefile")
print("Makefile")

self.generate_state_makefile(state_realpath, enc)
state_files.append("Makefile")

Expand All @@ -316,10 +310,9 @@ def perform(self, args):
if self.config["state_switch"]["clean"]:
run_shcmd(self.config["state_switch"]["clean"])

out, err, retcode = run_shcmd("make", cwd=state_realpath)
print("==== Generating state data files (%s) ====" % kernel_realpath)

if retcode != 0:
print("ERROR: state make error")
out, err, retcode = run_shcmd("make", cwd=state_realpath)

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

Expand Down Expand Up @@ -438,9 +431,6 @@ def generate_kernel_makefile(self, kernelpath, enc):
opts + " " + self.config["include"]["compiler"]["compiler_options"]
)

#if "compiler_options" in kfile and kfile["compiler_options"]:
# opts = opts + " " + kfile["compiler_options"]

if "options" in kfile and kfile["options"]:
opts = opts + " " + " ".join(kfile["options"])

Expand Down Expand Up @@ -880,6 +870,8 @@ def generate_state_makefile(self, statepath, enc):

def read_model(self, modeljson, config):

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

if "etime" not in modeljson:
raise UserException("'etime' is not in model json file")

Expand Down Expand Up @@ -908,9 +900,6 @@ def read_model(self, modeljson, config):
for threadnum, d2 in d1.items():
for invokenum, (start, stop) in d2.items():

#for opt in cfg.options("elapsedtime.elapsedtime"):
# ranknum, threadnum, invokenum = tuple(num for num in opt.split())
# start, stop = cfg.get("elapsedtime.elapsedtime", opt).split(",")
estart = float(start)
eend = float(stop)
etimeval = eend - estart
Expand Down Expand Up @@ -1021,6 +1010,3 @@ def read_model(self, modeljson, config):
)

return


# okay decompiling kernelgen.pyc

0 comments on commit 5ead819

Please sign in to comment.