Skip to content

Commit

Permalink
Merge branch 'master' into 83-fix-cg-kit-upstream-to-pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
ylee88 committed Aug 21, 2024
2 parents 2a4e717 + f6e9258 commit 9ecf9eb
Show file tree
Hide file tree
Showing 45 changed files with 274 additions and 282 deletions.
7 changes: 2 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,10 @@ test_gnu:
- pip install seaborn
- pip install yt
- cd $MILHOJA_CODE_REPO/tools/sedov_pypkg
- python setup.py test
- python setup.py sdist && cd dist
- pip install $(ls sedov-*.tar.gz)
- pip install .
- python -c 'import sedov ; sedov.print_versions()'
- cd $MILHOJA_CODE_REPO/tools/milhoja_pypkg
- python setup.py sdist && cd dist
- pip install $(ls milhoja-*.tar.gz)
- pip install .
##-- Check python virtual environment
- pip list
- $MILHOJA_CODE_REPO/tools/test_milhoja_installation.py -v 2
Expand Down
2 changes: 1 addition & 1 deletion src/Milhoja_TileFlashxr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ TileFlashxr::TileFlashxr(const FlashxrTileRawPtrs tP,
const FlashxTileRawInts tI,
const FlashxTileRawReals tR)
: Tile{},
level_{static_cast<unsigned int>(tI.level)},
level_{static_cast<unsigned int>(tI.level - 1)}, // 1-based Flash-X convention -> 0-based
gridIdxOrBlkId_{tI.gridIdxOrBlkId},
tileIdx_{tI.tileIdx},
lo_{LIST_NDIM(tI.loX,tI.loY,tI.loZ)},
Expand Down
2 changes: 1 addition & 1 deletion test/Base/code_generation/Analysis_op1.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"hi": "tile_hi"},
"U": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"R": [1, 2]},
"r": [1, 2]},
"idx": {"source": "tile_gridIndex"}
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/Base/code_generation/Math_op1.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"hi": {"source": "tile_hi"},
"U": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"RW": [1]},
"rw": [1]},
"scratch": {"source": "scratch",
"name": "_scratch3D"},
"deltas": {"source": "tile_deltas"}
Expand All @@ -32,7 +32,7 @@
"hi": {"source": "tile_hi"},
"U": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"RW": [2]},
"rw": [2]},
"scratch": {"source": "scratch",
"name": "_scratch3D"},
"deltas": {"source": "tile_deltas"}
Expand All @@ -46,7 +46,7 @@
"hi": {"source": "tile_hi"},
"U": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"RW": [1, 2]},
"rw": [1, 2]},
"scratch": {"source": "scratch",
"name": "_scratch4D"},
"deltas": {"source": "tile_deltas"}
Expand Down
2 changes: 1 addition & 1 deletion test/Base/code_generation/Simulation_op1.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"hi": "tile_ubound"},
"U": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"W": [1, 2]}
"w": [1, 2]}
}
}
}
2 changes: 1 addition & 1 deletion test/Grid/general/code_generation/Simulation_op1.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"hi": "tile_ubound"},
"U": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"W": [1, 2]}
"w": [1, 2]}
}
}
}
38 changes: 19 additions & 19 deletions test/Sedov/code_generation/Hydro_op1.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
"deltas": {"source": "tile_deltas"},
"Uin": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"R": [1, 2, 3, 4, 5, 6, 9]},
"r": [1, 2, 3, 4, 5, 6, 9]},
"flX": {"source": "grid_data",
"structure_index": ["FLUXX", 1],
"W": [1, 2, 3, 4, 5]},
"w": [1, 2, 3, 4, 5]},
"flY": {"source": "grid_data",
"structure_index": ["FLUXY", 1],
"W": [1, 2, 3, 4, 5]},
"w": [1, 2, 3, 4, 5]},
"flZ": {"source": "grid_data",
"structure_index": ["FLUXZ", 1],
"W": [1, 2, 3, 4, 5]},
"w": [1, 2, 3, 4, 5]},
"auxC": {"source": "scratch",
"name": "_auxC"}
}
Expand All @@ -53,17 +53,17 @@
"hi": {"source": "tile_hi"},
"U": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"RW": [1, 2, 3, 4, 6],
"W": [8]},
"rw": [1, 2, 3, 4, 6],
"w": [8]},
"flX": {"source": "grid_data",
"structure_index": ["FLUXX", 1],
"R": [1, 2, 3, 4, 5]},
"r": [1, 2, 3, 4, 5]},
"flY": {"source": "grid_data",
"structure_index": ["FLUXY", 1],
"R": [1, 2, 3, 4, 5]},
"r": [1, 2, 3, 4, 5]},
"flZ": {"source": "grid_data",
"structure_index": ["FLUXZ", 1],
"R": [1, 2, 3, 4, 5]}
"r": [1, 2, 3, 4, 5]}
}
},
"Eos::idealGammaDensIe": {
Expand All @@ -74,8 +74,8 @@
"hi": {"source": "tile_hi"},
"U": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"R": [1, 8],
"W": [5, 7]}
"r": [1, 8],
"w": [5, 7]}
}
},
"hy::computeSoundSpeedHll_oacc_summit": {
Expand All @@ -86,7 +86,7 @@
"hi": {"source": "tile_hi"},
"U": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"R": [1, 5, 9]},
"r": [1, 5, 9]},
"auxC": {"source": "scratch",
"name": "_auxC"}
}
Expand All @@ -102,7 +102,7 @@
"deltas": {"source": "tile_deltas"},
"U": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"R": [1, 2, 3, 4, 5, 6]},
"r": [1, 2, 3, 4, 5, 6]},
"flX": {"source": "scratch",
"name": "_flX"},
"auxC": {"source": "scratch",
Expand All @@ -120,7 +120,7 @@
"deltas": {"source": "tile_deltas"},
"U": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"R": [1, 2, 3, 4, 5, 6]},
"r": [1, 2, 3, 4, 5, 6]},
"flY": {"source": "scratch",
"name": "_flY"},
"auxC": {"source": "scratch",
Expand All @@ -138,7 +138,7 @@
"deltas": {"source": "tile_deltas"},
"U": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"R": [1, 2, 3, 4, 5, 6]},
"r": [1, 2, 3, 4, 5, 6]},
"flZ": {"source": "scratch",
"name": "_flZ"},
"auxC": {"source": "scratch",
Expand All @@ -153,8 +153,8 @@
"hi": {"source": "tile_hi"},
"U": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"RW": [1, 2, 3, 4, 6],
"W": [8]},
"rw": [1, 2, 3, 4, 6],
"w": [8]},
"flX": {"source": "scratch",
"name": "_flX"},
"flY": {"source": "scratch",
Expand All @@ -171,8 +171,8 @@
"hi": {"source": "tile_hi"},
"U": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"R": [1, 8],
"W": [5, 7]}
"r": [1, 8],
"w": [5, 7]}
}
}
}
2 changes: 1 addition & 1 deletion test/Sedov/code_generation/Io_op1.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"hi": "tile_hi"},
"solnData": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"R": [1, 2, 3, 4, 6, 8]}
"r": [1, 2, 3, 4, 6, 8]}
}
}
}
6 changes: 3 additions & 3 deletions test/Sedov/code_generation/Simulation_op1.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"deltas": {"source": "tile_deltas"},
"solnData": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"W": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}
"w": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}
}
},
"Eos::idealGammaDensIe": {
Expand All @@ -40,8 +40,8 @@
"hi": {"source": "tile_ubound"},
"U": {"source": "grid_data",
"structure_index": ["CENTER", 1],
"R": [1, 8],
"W": [5, 7]}
"r": [1, 8],
"w": [5, 7]}
}
}
}
2 changes: 1 addition & 1 deletion tools/milhoja_pypkg/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.4
0.0.5
36 changes: 34 additions & 2 deletions tools/milhoja_pypkg/docs/source/developers_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,35 @@ name of the item, followed by the suffix '_d'.

Code Generation Interface
-------------------------
.. autoclass:: milhoja.TileWrapperGenerator_cpp

Code Generation classes contained inside of the code generation interface follow
a loose naming pattern that determines what language and device the code is generated
for. The general format is as follows:

`[object][_device][_language]`

Where the `[object]` is the type of object being generated, either `DataPacket`
or `TileWrapper`. The `[_device]` is the device that the generated code will run
on, either `cpu` for running on the cpu, or the tpye of offloading to use if the
gpu is being used. Finally, the `[_language]` is the language that the code is
generated for. For example, `TaskFunctionC2FGenerator_OpenACC_F` is a class
for generating the C2F layer for TaskFunctions, with code that runs on the GPU
with OpenACC offloading, generated for fortran code.

Since this is just a 'loose' rule, there are a few exceptions to this. The
TileWrapperGenerator class and the DataPacketGenerator class hide any language specific
generation rules inside of themselves, so there are no separate generators for language
or device specific data items. Generally, TileWrappers are only used on CPUs, so
there is no need to specify the device. TileWrappers are also compatible with both
Fortran & C++ Task Functions without extra modifications. DataPackets are designed
in a similar way, however, the generated code is not necessarily compatible with
both C++ and Fortran Task Functions (this will likely change in the future), and
DataPackets are primarily used for offloading purposes. The last exceptions are the
`DataPacketModGenerator` and the `TileWrapperModGenerator`, which exist to generate
fortran module interface files for use with the TaskFunction, therefore there is
no need to specify the language or device/offloading inside of the file name.

.. autoclass:: milhoja.TileWrapperGenerator
:members:
.. autoclass:: milhoja.TileWrapperModGenerator
:members:
Expand All @@ -392,5 +420,9 @@ Code Generation Interface
:members:
.. autoclass:: milhoja.TaskFunctionC2FGenerator_cpu_F
:members:
.. autoclass:: milhoja.TaskFunctionC2FGenerator_OpenACC_F
:members:
.. autoclass:: milhoja.TaskFunctionCpp2CGenerator_cpu_F
:members:
:members:
.. autoclass:: milhoja.TaskFunctionCpp2CGenerator_OpenACC_F
:members:
28 changes: 0 additions & 28 deletions tools/milhoja_pypkg/src/milhoja/DataPacketGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

from .parse_helpers import parse_extents
from .generate_packet_file import generate_packet_file
from .Cpp2CLayerGenerator import Cpp2CLayerGenerator
from .C2FortranLayerGenerator import C2FortranLayerGenerator
from .DataPacketC2FModuleGenerator import DataPacketC2FModuleGenerator
from .FortranTemplateUtility import FortranTemplateUtility
from .CppTemplateUtility import CppTemplateUtility
from .AbcCodeGenerator import AbcCodeGenerator
Expand All @@ -35,9 +32,6 @@ def __init__(
self, tf_spec: TaskFunction, indent: int, logger: BasicLogger,
sizes: dict
):
if not isinstance(tf_spec, TaskFunction):
raise TypeError("TF Spec was not derived from task function.")

self._TOOL_NAME = "Milhoja DataPacket"
self._sizes = deepcopy(sizes)
self._indent = indent
Expand Down Expand Up @@ -230,28 +224,6 @@ def generate_source_code(self, destination, overwrite):
)
self._log("Done", LOG_LEVEL_BASIC_DEBUG)

if self._tf_spec.language.lower() == "fortran":
# dirty hack for fixing the test suite. In reality, this code
# should be moved outside of the data packet generator and into
# the task function generator.
self.cpp2c_layer = Cpp2CLayerGenerator(
self._tf_spec, self._indent, self._logger
)
self.cpp2c_layer.generate_source_code(destination, overwrite)

# generate fortran to c layer if necessary
self.c2f_layer = C2FortranLayerGenerator(
self._tf_spec, self._indent, self._logger
)
# c2f layer does not use cgkit so no need
# to call generate_packet_file
self.c2f_layer.generate_source_code(destination, overwrite)

self.dp_module = DataPacketC2FModuleGenerator(
self._tf_spec, self._indent, self._logger
)
self.dp_module.generate_source_code(destination, overwrite)

@property
def language(self):
return self._tf_spec.language.lower()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
from . import LOG_LEVEL_BASIC


class DataPacketC2FModuleGenerator(AbcCodeGenerator):
class DataPacketModGenerator(AbcCodeGenerator):
"""
Responsible for generating the module interface file for use by the
fortran task function and interoperability layers. Nothing is generated
for C++ based task functions.
"""

# C2F Module generator uses its own specific type mapping for the
# fortran interface.
_TYPE_MAPPING = {
Expand Down
Loading

0 comments on commit 9ecf9eb

Please sign in to comment.