Skip to content

Commit

Permalink
Enables bitwise arithmetic in bindings for cali_attr_properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ilumsden committed Sep 19, 2024
1 parent 28dc0b1 commit ebd48e0
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -C ${{github.workspace}}/cmake/hostconfig/github-actions.cmake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -Dpybind11_DIR=$(pybind11-config --cmakedir) -C ${{github.workspace}}/cmake/hostconfig/github-actions.cmake

- name: Build
# Build your program with the given configuration
Expand Down
2 changes: 1 addition & 1 deletion src/interface/python/annotation.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef CALI_INTERFACE_PYTHON_ANNOTATION_H
#define CALI_INTERFACE_PYTHON_ANNOTATION_H

#include "variant.h"
#include "common.h"

namespace cali {

Expand Down
2 changes: 1 addition & 1 deletion src/interface/python/instrumentation.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "instrumentation.h"
#include "variant.h"

#include <stdexcept>

namespace cali {
Expand Down
2 changes: 0 additions & 2 deletions src/interface/python/instrumentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#include "common.h"

#include "variant.h"

namespace cali {

class PythonAttribute {
Expand Down
4 changes: 2 additions & 2 deletions src/interface/python/mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ PYBIND11_MODULE(__pycaliper_impl, m) {
c_attr_type.value("CALI_TYPE_PTR", CALI_TYPE_PTR);
c_attr_type.export_values();

py::enum_<cali_attr_properties> c_attr_properties(types_mod,
"AttrProperties");
py::enum_<cali_attr_properties> c_attr_properties(types_mod, "AttrProperties",
py::arithmetic());
c_attr_properties.value("CALI_ATTR_DEFAULT", CALI_ATTR_DEFAULT);
c_attr_properties.value("CALI_ATTR_ASVALUE", CALI_ATTR_ASVALUE);
c_attr_properties.value("CALI_ATTR_NOMERGE", CALI_ATTR_NOMERGE);
Expand Down
1 change: 0 additions & 1 deletion src/interface/python/pycaliper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
import pycaliper.instrumentation
import pycaliper.loop
import pycaliper.types
import pycaliper.variant

from pycaliper.high_level import annotate_function
20 changes: 1 addition & 19 deletions test/ci_app_tests/ci_test_py_ann.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
set_byname,
end_byname,
)
from pycaliper.types import CALI_TYPE_INT, CALI_ATTR_ASVALUE, CALI_TYPE_STRING, CALI_ATTR_UNALIGNED
from pycaliper.variant import Variant
from pycaliper.types import CALI_TYPE_INT, CALI_ATTR_ASVALUE
from pycaliper.config_manager import ConfigManager


Expand Down Expand Up @@ -45,23 +44,6 @@ def main():

end_byname("phase")

begin_byname("ci_test_c_ann.meta-attr")

meta_attr = Attribute("meta-attr", CALI_TYPE_INT)
meta_val = Variant(47)

test_attr = Attribute(
"test-attr-with-metadata",
CALI_TYPE_STRING,
CALI_ATTR_UNALIGNED,
[meta_attr],
[meta_val],
)

test_attr.set("abracadabra")

end_byname("ci_test_c_ann.meta-attr")

begin_byname("ci_test_c_ann.setbyname")

set_byname("attr.int", 20)
Expand Down
41 changes: 0 additions & 41 deletions test/ci_app_tests/test_python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ def test_py_ann_trace(self):
snapshots, {"attr.int": "20", "attr.str": "fidibus"}
)
)
self.assertTrue(
cat.has_snapshot_with_attributes(
snapshots, {"test-attr-with-metadata": "abracadabra"}
)
)

def test_py_ann_globals(self):
target_cmd = [sys.executable, "./ci_test_py_ann.py"]
Expand Down Expand Up @@ -96,42 +91,6 @@ def test_py_ann_globals(self):
)
)

def test_py_ann_metadata(self):
target_cmd = [sys.executable, "./ci_test_py_ann.py"]
query_cmd = [
"../../src/tools/cali-query/cali-query",
"-e",
"--list-attributes",
"--print-attributes",
"cali.attribute.name,cali.attribute.type,meta-attr",
]

caliper_config = {
"CALI_CONFIG_PROFILE": "serial-trace",
"CALI_RECORDER_FILENAME": "stdout",
"CALI_LOG_VERBOSITY": "0",
}

query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config)
snapshots = cat.get_snapshots_from_text(query_output)

self.assertTrue(
cat.has_snapshot_with_attributes(
snapshots,
{"cali.attribute.name": "meta-attr", "cali.attribute.type": "int"},
)
)
self.assertTrue(
cat.has_snapshot_with_attributes(
snapshots,
{
"cali.attribute.name": "test-attr-with-metadata",
"cali.attribute.type": "string",
"meta-attr": "47",
},
)
)


if __name__ == "__main__":
unittest.main()

0 comments on commit ebd48e0

Please sign in to comment.