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 <bbruce@ucdavis.edu> Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
This commit is contained in:
committed by
Bobby Bruce
parent
4ad1150372
commit
5d0dd10cfa
@@ -31,7 +31,7 @@ from m5.util import warn, fatal
|
||||
|
||||
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 @@ class LooppointCsvResource(FileResource, LooppointCsvLoader):
|
||||
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 @@ _get_resource_json_type_map = {
|
||||
"simpoint-directory": SimpointDirectoryResource,
|
||||
"resource": Resource,
|
||||
"looppoint-pinpoint-csv": LooppointCsvResource,
|
||||
"looppoint-json": LooppointJsonResource,
|
||||
}
|
||||
|
||||
@@ -29,7 +29,12 @@ import unittest
|
||||
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 @@ class ResourceSpecializationSuite(unittest.TestCase):
|
||||
"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())
|
||||
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user