Skip to content

Commit

Permalink
Test check
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesouza committed Jan 11, 2024
2 parents 4e30ae5 + 004d69d commit 049f5c5
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test-n-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ jobs:
python -m pip install "git+https://github.com/RRZE-HPC/OSACA.git@InstrucForm"
python -m pip install codecov requests sympy
python -m pip install -e .
<<<<<<< HEAD
#iaca_get --I-accept-the-Intel-What-If-Pre-Release-License-Agreement-and-please-take-my-soul
=======
>>>>>>> master
- name: Test
run: |
coverage run -p tests/all_tests.py
Expand Down
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ kerncraft

Loop Kernel Analysis and Performance Modeling Toolkit

This tool allows automatic analysis of loop kernels using the Execution Cache Memory (ECM) model,
This tool allows automatic analysis of loop kernels using the `Execution Cache Memory (ECM) model <https://hpc.fau.de/research/ecm/>`_,
the Roofline model and actual benchmarks. kerncraft provides a framework to investigate the
data reuse and cache requirements by static code analysis. In combination with the Intel IACA tool
kerncraft can give a good overview of both in-core and memory bottlenecks and use that data to
Expand All @@ -30,6 +30,9 @@ for the latest release. In order to get the `Intel Achitecture Code Analyzer (IA

``iaca_get --I-accept-the-Intel-What-If-Pre-Release-License-Agreement-and-please-take-my-soul``

.. warning::
As for 2023, Intel removed the download link for any IACA version. If you have any IACA version existing on your system, you can still use it with kerncraft by putting it in ``~/.kerncraft/iaca/vX.Y`` in your home directory.

Additional requirements are:
* `likwid <https://github.com/RRZE-HPC/likwid>`_ (used in Benchmark model and by ``likwid_bench_auto``)

Expand Down
2 changes: 1 addition & 1 deletion examples/machine-files/HaswellEP_E5-2695v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ compiler: !!omap
- gcc: -O3 -march=core-avx2 -D_POSIX_C_SOURCE=200809L -fopenmp -lm -ffreestanding

in-core model: !!omap
- IACA: HSW
- OSACA: HSW
- IACA: HSW
- LLVM-MCA: -mcpu=haswell
isa: x86

Expand Down
2 changes: 1 addition & 1 deletion examples/machine-files/SandyBridgeEP_E5-2680.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ cores per NUMA domain: 8
transparent hugepage: always

in-core model: !!omap
- IACA: SNB
- OSACA: SNB
- IACA: SNB
- LLVM-MCA: -mcpu=sandybridge
isa: x86

Expand Down
5 changes: 4 additions & 1 deletion kerncraft/cachetile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import sys

import sympy
from ruamel import yaml
import ruamel.yaml

from . import models
from .kernel import KernelDescription
from .machinemodel import MachineModel
from .prefixedunit import PrefixedUnit


def create_parser():
Expand Down Expand Up @@ -49,6 +50,8 @@ def run(parser, args):

# process kernel description
description = str(args.description_file.read())
yaml = ruamel.yaml.YAML(typ='unsafe')
yaml.register_class(PrefixedUnit)
kernel = KernelDescription(yaml.load(description))

# Add constants from define arguments
Expand Down
7 changes: 5 additions & 2 deletions kerncraft/kerncraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
import io
from collections import OrderedDict

from ruamel import yaml
import ruamel.yaml

from . import models
from . import __version__
from .prefixedunit import PrefixedUnit
from .kernel import KernelCode, KernelDescription, symbol_pos_int
from .machinemodel import MachineModel
from .pycparser_utils import clean_code
Expand Down Expand Up @@ -327,7 +328,9 @@ def run(parser, args, output_file=sys.stdout):
else:
description = str(args.code_file.read())
args.code_file.close()
kernel = KernelDescription(yaml.load(description, Loader=yaml.Loader), machine=machine)
yaml = ruamel.yaml.YAML(typ='unsafe')
yaml.register_class(PrefixedUnit)
kernel = KernelDescription(yaml.load(description), machine=machine)

loop_indices = set([symbol_pos_int(l['index']) for l in kernel.get_loop_stack()])
# define constants
Expand Down
10 changes: 6 additions & 4 deletions kerncraft/machinemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
from functools import lru_cache

import psutil
from ruamel import yaml
from ruamel.yaml.comments import CommentedMap
import ruamel.yaml
import cachesim
from sympy.parsing.sympy_parser import parse_expr

Expand Down Expand Up @@ -156,12 +155,14 @@ def __init__(self, path_to_yaml=None, machine_yaml=None, args=None):
self._path = path_to_yaml
self._args = args
if path_to_yaml:
yaml = ruamel.yaml.YAML(typ='unsafe')
yaml.register_class(PrefixedUnit)
# Load into cache and save to self._data
abspath_to_yaml = os.path.abspath(path_to_yaml)
if abspath_to_yaml not in self._loaded_machine_yaml:
with open(path_to_yaml, 'r') as f:
# Ignore ruamel unsafe loading warning, by supplying Loader parameter
self._loaded_machine_yaml[abspath_to_yaml] = yaml.load(f, Loader=yaml.Loader)
self._loaded_machine_yaml[abspath_to_yaml] = yaml.load(f)
self._data = self._loaded_machine_yaml[abspath_to_yaml]
elif machine_yaml:
self._data = machine_yaml
Expand Down Expand Up @@ -612,7 +613,8 @@ def dump(self, f=None):
"""
Return YAML string to store machine model and store to f (if path or fp passed).
"""
yaml_string = yaml.dump(self._data, Dumper=yaml.Dumper)
yaml = ruamel.yaml.YAML()
yaml_string = yaml.dump(self._data)
if f is None:
f = self._path

Expand Down
9 changes: 4 additions & 5 deletions kerncraft/prefixedunit.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#!/usr/bin/env python3
import re

from ruamel import yaml
import ruamel.yaml


class PrefixedUnit(yaml.YAMLObject):
class PrefixedUnit(ruamel.yaml.YAMLObject):
PREFIXES = {'k': 1e3, 'M': 1e6, 'G': 1e9, 'T': 1e13, 'P': 1e16, 'E': 1e19, 'Z': 1e21, 'Y': 1e24,
'': 1}

yaml_loader = yaml.Loader
yaml_dumper = yaml.Dumper

yaml = ruamel.yaml.YAML()
yaml_tag = u'!prefixed'
yaml_implicit_pattern = re.compile(re.compile(
r'^(?P<value>[0-9]+(?:\.[0-9]+)?) (?P<prefix>[kMGTP])?(?P<unit>.*)$'))
Expand Down Expand Up @@ -204,4 +203,4 @@ def __ne__(self, other):


# Make this tag automatic
yaml.add_implicit_resolver(PrefixedUnit.yaml_tag, PrefixedUnit.yaml_implicit_pattern)
ruamel.yaml.add_implicit_resolver(PrefixedUnit.yaml_tag, PrefixedUnit.yaml_implicit_pattern)
4 changes: 3 additions & 1 deletion kerncraft/roofline-plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pprint import pprint

import matplotlib.pyplot as plt
from ruamel import yaml
import ruamel.yaml

from .prefixedunit import PrefixedUnit

Expand All @@ -27,6 +27,8 @@ def frange(start, stop, step=1.0):
{'performance': PrefixedUnit(11175000000.0, '', 'FLOP/s'),
'bandwidth': PrefixedUnit(22.35, u'G', u'B/s'),
'arithmetic intensity': 0.5, 'bw kernel': 'triad', 'level': 'L3-MEM'}]}
yaml = ruamel.yaml.YAML(typ='unsafe')
yaml.register_class(PrefixedUnit)
machine = yaml.load(open('machine-files/emmy.yaml'))
max_flops = machine['clock']*sum(machine['FLOPs per cycle']['DP'].values())
max_flops.unit = "FLOP/s"
Expand Down
7 changes: 5 additions & 2 deletions tests/test_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
import os
import unittest

from ruamel import yaml
import ruamel.yaml

from kerncraft.kernel import KernelCode, KernelDescription
from kerncraft.prefixedunit import PrefixedUnit


class TestKernel(unittest.TestCase):
def setUp(self):
yaml = ruamel.yaml.YAML(typ='unsafe')
yaml.register_class(PrefixedUnit)
with open(self._find_file('2d-5pt.c')) as f:
self.twod_code = f.read()
with open(self._find_file('3d-7pt.c')) as f:
self.threed_code = f.read()
with open(self._find_file('2d-5pt.yml')) as f:
self.twod_description = yaml.load(f.read(), Loader=yaml.Loader)
self.twod_description = yaml.load(f)
with open(self._find_file('copy-2d-linearized.c')) as f:
self.twod_linear = f.read()

Expand Down

0 comments on commit 049f5c5

Please sign in to comment.