Bobby Bruce has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/67858?usp=email )

 (

15 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
 )Change subject: stdlib: Add LooppointJsonResource resource
......................................................................

stdlib: Add LooppointJsonResource resource

This resource wraps the LooppointJsonLoader class for use with gem5
resources.

Change-Id: Ic00d689c289330bab8564abc4c68a9047d5096e0
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67858
Reviewed-by: Bobby Bruce <bbr...@ucdavis.edu>
Tested-by: kokoro <noreply+kok...@google.com>
Maintainer: Bobby Bruce <bbr...@ucdavis.edu>
---
M src/python/gem5/resources/resource.py
M tests/pyunit/stdlib/resources/pyunit_resource_specialization.py
M tests/pyunit/stdlib/resources/refs/resource-specialization.json
3 files changed, 74 insertions(+), 2 deletions(-)

Approvals:
  Bobby Bruce: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/python/gem5/resources/resource.py b/src/python/gem5/resources/resource.py
index 0cf5880..9cba9cf 100644
--- a/src/python/gem5/resources/resource.py
+++ b/src/python/gem5/resources/resource.py
@@ -31,7 +31,7 @@

 from .downloader import get_resource, get_resources_json_obj

-from .looppoint import LooppointCsvLoader
+from .looppoint import LooppointCsvLoader, LooppointJsonLoader
 from ..isas import ISA, get_isa_from_str

 from typing import Optional, Dict, Union, Type, Tuple, List
@@ -415,6 +415,26 @@
         LooppointCsvLoader.__init__(self, pinpoints_file=Path(local_path))


+class LooppointJsonResource(FileResource, LooppointJsonLoader):
+    def __init__(
+        self,
+        local_path: str,
+        region_id: Optional[Union[str, int]] = None,
+        documentation: Optional[str] = None,
+        source: Optional[str] = None,
+        **kwargs,
+    ):
+        FileResource.__init__(
+            self,
+            local_path=local_path,
+            documentation=documentation,
+            source=source,
+        )
+        LooppointJsonLoader.__init__(
+            self, looppoint_file=local_path, region_id=region_id
+        )
+
+
 class SimpointDirectoryResource(SimpointResource):
     """A Simpoint diretory resource. This Simpoint Resource assumes the
existance of a directory containing a simpoint file and a weight file."""
@@ -736,4 +756,5 @@
     "simpoint-directory": SimpointDirectoryResource,
     "resource": Resource,
     "looppoint-pinpoint-csv": LooppointCsvResource,
+    "looppoint-json": LooppointJsonResource,
 }
diff --git a/tests/pyunit/stdlib/resources/pyunit_resource_specialization.py b/tests/pyunit/stdlib/resources/pyunit_resource_specialization.py
index 5c60eb5..660bf5f 100644
--- a/tests/pyunit/stdlib/resources/pyunit_resource_specialization.py
+++ b/tests/pyunit/stdlib/resources/pyunit_resource_specialization.py
@@ -29,7 +29,12 @@
 from pathlib import Path

 from gem5.resources.resource import *
-from gem5.resources.looppoint import LooppointCsvLoader
+
+from gem5.resources.looppoint import (
+    LooppointCsvLoader,
+    LooppointJsonLoader,
+)
+
 from gem5.isas import ISA


@@ -256,3 +261,23 @@
             "A looppoint pinpoints csv file.", resource.get_documentation()
         )
         self.assertIsNone(resource.get_source())
+
+    def test_looppoint_json_restore_resource(self) -> None:
+        """Tests the creation of LooppointJsonResource via a
+        Looppoint JSON file."""
+
+        resource = obtain_resource(
+            resource_name="looppoint-json-restore-resource-region-1",
+            resource_directory=self.get_resource_dir(),
+        )
+
+        self.assertIsInstance(resource, LooppointJsonResource)
+        self.assertIsInstance(resource, LooppointJsonLoader)
+
+        self.assertEquals(1, len(resource.get_regions()))
+        self.assertTrue("1" in resource.get_regions())
+
+        self.assertEquals(
+            "A looppoint json file resource.", resource.get_documentation()
+        )
+        self.assertIsNone(resource.get_source())
diff --git a/tests/pyunit/stdlib/resources/refs/resource-specialization.json b/tests/pyunit/stdlib/resources/refs/resource-specialization.json
index bfe0d4a..c4d5eb4 100644
--- a/tests/pyunit/stdlib/resources/refs/resource-specialization.json
+++ b/tests/pyunit/stdlib/resources/refs/resource-specialization.json
@@ -117,6 +117,16 @@
             "md5sum" : "199ab22dd463dc70ee2d034bfe045082",
             "url": 
"http://dist.gem5.org/dist/develop/pinpoints/x86-matrix-multiply-omp-100-8-global-pinpoints-20230127";,
             "source" : null
+        },
+        {
+            "type": "looppoint-json",
+            "name": "looppoint-json-restore-resource-region-1",
+            "documentation" : "A looppoint json file resource.",
+            "is_zipped" :  false,
+            "region_id" : "1",
+            "md5sum" : "a71ed64908b082ea619b26b940a643c1",
+            "url": 
"http://dist.gem5.org/dist/develop/looppoints/x86-matrix-multiply-omp-100-8-looppoint-json-20230128";,
+            "source" : null
         }
     ]
 }

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/67858?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ic00d689c289330bab8564abc4c68a9047d5096e0
Gerrit-Change-Number: 67858
Gerrit-PatchSet: 17
Gerrit-Owner: Bobby Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Bobby Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org

Reply via email to