Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPI kernel #86

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2a4ce7d
Pull in diffs from kgen_extra.py into base/kgen_extra.py and kgen/par…
Nov 29, 2017
ea20ea8
pull in changes to base/kgen_genfile.py and kgen/kggenfile.py
Nov 29, 2017
1cced99
bring in changes from genmake.py into kgen/extractor/main.py and kgen…
Nov 29, 2017
f2b2467
pull in changes from kgenapps/kernel_extractor/kext_tool.py into kgen…
Nov 29, 2017
0eeadc5
pull in changes from kgenapps/kernel_extractor/plugins/gencore/gen_dr…
Nov 30, 2017
945ae62
pull in changes from kgenapps/kernel_extractor/plugins/gencore/gen_ke…
Nov 30, 2017
60e970c
pull in changes from kgenapps/kernel_extractor/plugins/gencore/gen_st…
Nov 30, 2017
8b25bd7
pull in changes from kgenapps/kernel_extractor/plugins/gencore/gen_ty…
Nov 30, 2017
68d14af
pull in changes from kgenapps/kernel_extractor/plugins/gencore/gen_ty…
Nov 30, 2017
56e5d87
pull in changes from kgenapps/kernel_extractor/plugins/gencore/gen_ty…
Nov 30, 2017
0999400
pull in changes from kgenapps/kernel_extractor/plugins/gencore/gen_ty…
Nov 30, 2017
6ba392c
pull in changes from kgenapps/kernel_extractor/plugins/gencore/gencor…
Nov 30, 2017
d3034da
pull in changes from kgenapps/kernel_extractor/plugins/gencore/simple…
Nov 30, 2017
c8b0bb6
pull in changes from kgenapps/kernel_extractor/plugins/gencore/verify…
Dec 1, 2017
e8e19be
pull in changes from kgenapps/kernel_extractor/plugins/gencore/verify…
Dec 1, 2017
e6aa9e2
pull in changes from kgenapps/kernel_extractor/plugins/gencore/verify…
Dec 1, 2017
9a72b4a
pull in changes from kgenapps/kernel_extractor/plugins/gencore/verify…
Dec 1, 2017
577af99
pull in changes from kgenapps/kernel_extractor/plugins/gencore/verify…
Dec 1, 2017
5f76a19
pull in changes from kgenapps/kernel_extractor/plugins/verification/v…
Dec 1, 2017
74c769a
fix bug in verbose mode.
Dec 1, 2017
6508cbf
remove some spaces that were introduced by copy/paste.
Dec 1, 2017
0a210c3
change inital values of kgen_invoke and kgen_last_invoke
Dec 1, 2017
182cf63
remove some carriage returns introduced by copy paste.
Dec 1, 2017
a67b6d3
fix verbose level parsing error
Dec 1, 2017
7d6498a
Add some example results under examples/MPI_kernel
Dec 1, 2017
af54e0d
comment out warning
Mar 14, 2018
f912990
Add another forced "use mpi" in the generated kernel files.
Apr 4, 2018
2a29061
add trim to kgen_util.f90 kgen_mpifile subroutine to make it work wit…
Apr 10, 2018
3c33701
make the change also to the base/kgen_extra.py file even though it is…
Apr 10, 2018
9260f87
add some code to generated files and Makefile to enable use of intels…
Apr 19, 2018
04b2a5a
fix bug with cray ftn
Apr 24, 2018
b8a1416
Remove evalstage and warmupstage from kernel driver and callsite file.
Aug 29, 2018
6fd2d0e
update intel path to update 3.
Oct 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 63 additions & 1 deletion base/kgen_extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@
subroutine kgen_array_sumcheck(varname, sum1, sum2, finish)
character(*), intent(in) :: varname
real(kind=8), intent(in) :: sum1, sum2
real(kind=8), parameter :: max_rel_diff = 1.E-10
!real(kind=8), parameter :: max_rel_diff = 1.E-10
real(kind=8), parameter :: max_rel_diff = 1.E-9
real(kind=8) :: diff, rel_diff
logical, intent(in), optional :: finish
logical checkresult
Expand Down Expand Up @@ -550,6 +551,67 @@
END SUBROUTINE
"""

kgen_mpifile = \
"""
SUBROUTINE kgen_mpifile( str, rank, thread, cycle )
CHARACTER(*), INTENT(INOUT) :: str
INTEGER, INTENT(IN) :: rank, thread, cycle

CHARACTER(LEN=1024) :: format, string_format, string_format_format
CHARACTER(LEN=1024) :: rank_format
CHARACTER(LEN=1024) :: thread_format
CHARACTER(LEN=1024) :: cycle_format
INTEGER :: str_len

str_len = INDEX(str,".")

IF (str_len < 10) THEN
string_format_format = "(A1,I1)"
ELSE IF (str_len < 100) THEN
string_format_format = "(A1,I2)"
ELSE IF (str_len < 1000) THEN
string_format_format = "(A1,I3)"
ELSE IF (str_len < 10000) THEN
string_format_format = "(A1,I4)"
ENDIF
write(string_format,trim(string_format_format)) 'A',str_len

IF (rank < 10) THEN
rank_format = "I1"
ELSE IF (rank < 100) THEN
rank_format = "I2"
ELSE IF (rank < 1000) THEN
rank_format = "I3"
ELSE IF (rank < 10000) THEN
rank_format = "I4"
ENDIF

IF (thread < 10) THEN
thread_format = "I1"
ELSE IF (thread < 100) THEN
thread_format = "I2"
ELSE IF (thread < 1000) THEN
thread_format = "I3"
ELSE IF (thread < 10000) THEN
thread_format = "I4"
ENDIF

IF (cycle < 10) THEN
cycle_format = "I1"
ELSE IF (cycle < 100) THEN
cycle_format = "I2"
ELSE IF (cycle < 1000) THEN
cycle_format = "I3"
ELSE IF (cycle < 10000) THEN
cycle_format = "I4"
ENDIF

format = "("//trim(string_format)//","//trim(rank_format)//",A1,"//trim(thread_format)//",A1,"//trim(cycle_format)//")"
write(str,trim(format)) trim(str(1:str_len)), rank, ".", thread, ".", cycle

END SUBROUTINE
"""

rdtsc = \
""" .file "rdtsc.s"
.text
Expand Down
3 changes: 3 additions & 0 deletions base/kgen_genfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,9 @@ def process_exclude(node, bag, depth):
if isinstance(node, Name):
for namepath, actions in bag['excludes'].iteritems():
if match_namepath(namepath, pack_innamepath(bag['stmt'], node.string)):
#jgw# for a remove_io exclude leave the type in
if actions[0] == 'remove_io':
return False
bag['matched'] = True
return True

Expand Down
3 changes: 2 additions & 1 deletion base/statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,8 @@ def analyze(self):

# start of KGEN addition
def resolve_uname(self, uname, request):
Logger.warn('resolve_uname is not implemented: %s'%self.__class__)
# comment out based on input from Youngsung
#Logger.warn('resolve_uname is not implemented: %s'%self.__class__)
pass

def tokgen(self):
Expand Down
31 changes: 31 additions & 0 deletions examples/MPI_kernel/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#KGEN_HOME := $(HOME)/devel/packages/KGen
KGEN_HOME := $(HOME)/tmp/KGen
KGEN := ${KGEN_HOME}/bin/kgen

SRC_DIR := ${PWD}/../src
SRC := ${SRC_DIR}/radtrans/rad_diffusion.f90

# don't have invocations beyond first cycle if the function is only called 1x!
# there is still a race condition somewhere in the src/Makefile. Change to -j8
# until we can find it.

test:
${KGEN} \
--check tolerance=1.0D-10 \
--cmd-build="cd ${SRC_DIR}; make -j8" \
--cmd-clean="cd ${SRC_DIR}; make clean; cd ${SRC_DIR}/run; ./clean.sh" \
--cmd-run="cd ${SRC_DIR}; make run" \
--exclude-ini=exclude.ini \
--invocation=0-15:0:0 \
--mpi=enable \
--repr-etime=disable \
--verbose=3 \
${SRC}


# --invocation 0-383:0:0 \

clean:
${MAKE} clean -C ../src
$(RM) -rf _kgen_compflag_cmdwrapper.sh elapsedtime kernel kgen.log model state
#$(RM) include.ini strace.log
14 changes: 14 additions & 0 deletions examples/MPI_kernel/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
These are some example files generated by my modified KGen. They are meant
to show the kind of things that are needed to have an MPI extracted kernel.
None of this has been tested with an OpenMP code.

Makefile
- Showing the options that I'm invoking KGen with

state_callsite.f90
- need to set kgen_invoke and kgen_last_invoke to 0 to get the thing to run
- add mpi_comm_rank, mpi_comm_size, mpi_barrier
- write file per rank

verify_callsite.f90
- mpi_allreduce max on numOutTol
Loading