From 33e3bc4ff15e9b1c40cf287c41b87dd3ced661f6 Mon Sep 17 00:00:00 2001 From: MMysore2 <61029417+MMysore2@users.noreply.github.com> Date: Thu, 8 Aug 2024 12:46:10 -0700 Subject: [PATCH] Updating Traffic Generators (#1416) Added documentation for `strided_generator.py` and `strided_generator_core.py.` Updated clarity of documentation for `linear_generator.py`, `linear_generator_core.py`, `random_generator.py`, and `random_generator_core.py`. Made `max_addr` exclusive instead of inclusive for strided and linear traffic generation in `strided_gen.cc` and `linear_gen.cc`. --- src/cpu/testers/traffic_gen/linear_gen.cc | 2 +- src/cpu/testers/traffic_gen/strided_gen.cc | 2 +- .../components/processors/linear_generator.py | 8 +++-- .../processors/linear_generator_core.py | 8 +++-- .../components/processors/random_generator.py | 8 +++-- .../processors/random_generator_core.py | 8 +++-- .../processors/strided_generator.py | 29 ++++++++++++++++++ .../processors/strided_generator_core.py | 30 +++++++++++++++++++ 8 files changed, 81 insertions(+), 14 deletions(-) diff --git a/src/cpu/testers/traffic_gen/linear_gen.cc b/src/cpu/testers/traffic_gen/linear_gen.cc index 8b5c52d0c3..ac31254bea 100644 --- a/src/cpu/testers/traffic_gen/linear_gen.cc +++ b/src/cpu/testers/traffic_gen/linear_gen.cc @@ -78,7 +78,7 @@ LinearGen::getNextPacket() // If we have reached the end of the address space, reset the // address to the start of the range - if (nextAddr > endAddr) { + if (nextAddr >= endAddr) { DPRINTF(TrafficGen, "Wrapping address to the start of " "the range\n"); nextAddr = startAddr; diff --git a/src/cpu/testers/traffic_gen/strided_gen.cc b/src/cpu/testers/traffic_gen/strided_gen.cc index 0115cf3686..a7c31256a6 100644 --- a/src/cpu/testers/traffic_gen/strided_gen.cc +++ b/src/cpu/testers/traffic_gen/strided_gen.cc @@ -101,7 +101,7 @@ StridedGen::getNextPacket() // If we have reached the end of the address space, reset the // address to the start of the range - if (nextAddr > endAddr) { + if (nextAddr >= endAddr) { DPRINTF(TrafficGen, "Wrapping address to the start of " "the range\n"); nextAddr = startAddr + offset; diff --git a/src/python/gem5/components/processors/linear_generator.py b/src/python/gem5/components/processors/linear_generator.py index 0e847614c7..b239d490cd 100644 --- a/src/python/gem5/components/processors/linear_generator.py +++ b/src/python/gem5/components/processors/linear_generator.py @@ -64,8 +64,9 @@ class LinearGenerator(AbstractGenerator): generator cores that could replace the processing cores in a board. :param num_cores: The number of linear generator cores to create. - :param duration: The number of ticks for the generator to generate - traffic. + :param duration: The duration of time for which the generator generates + traffic. Must be a string containing a positive number + and some unit. For example, "1ms". :param rate: The rate at which the synthetic data is read/written. :param block_size: The number of bytes to be read/written with each request. @@ -77,7 +78,8 @@ class LinearGenerator(AbstractGenerator): requests. The write percentage would be equal to ``100 - rd_perc``. :param data_limit: The amount of data in bytes to read/write by the - generator before stopping generation. + generator before stopping generation. If set to 0, + there will be no data limit. """ def _create_cores( diff --git a/src/python/gem5/components/processors/linear_generator_core.py b/src/python/gem5/components/processors/linear_generator_core.py index 449d90a98a..f35939895a 100644 --- a/src/python/gem5/components/processors/linear_generator_core.py +++ b/src/python/gem5/components/processors/linear_generator_core.py @@ -60,8 +60,9 @@ class LinearGeneratorCore(AbstractGeneratorCore): a linear (stream) traffic specific to the parameters below. This core uses PyTrafficGen to create and inject the synthetic traffic. - :param duration: The number of ticks for the generator core to generate - traffic. + :param duration: The duration of time for which the generator core generates + traffic. Must be a string containing a positive number + and some unit. For example, "1ms". :param rate: The rate at which the synthetic data is read/written. :param block_size: The number of bytes to be read/written with each request. @@ -73,7 +74,8 @@ class LinearGeneratorCore(AbstractGeneratorCore): requests. The write percentage would be equal to ``100 - rd_perc``. :param data_limit: The amount of data in bytes to read/write by the - generator before stopping generation. + generator before stopping generation. If set to 0, + there will be no data limit. """ self.generator = PyTrafficGen() self._duration = duration diff --git a/src/python/gem5/components/processors/random_generator.py b/src/python/gem5/components/processors/random_generator.py index affe37cf80..5345bb6c5c 100644 --- a/src/python/gem5/components/processors/random_generator.py +++ b/src/python/gem5/components/processors/random_generator.py @@ -63,8 +63,9 @@ class RandomGenerator(AbstractGenerator): generator cores that could replace the processing cores in a board. :param num_cores: The number of linear generator cores to create. - :param duration: The number of ticks for the generator to generate - traffic. + :param duration: The duration of time for which the generator generates + traffic. Must be a string containing a positive number + and some unit. For example, "1ms". :param rate: The rate at which the synthetic data is read/written. :param block_size: The number of bytes to be read/written with each request. @@ -76,7 +77,8 @@ class RandomGenerator(AbstractGenerator): requests. The write percentage would be equal to ``100 - rd_perc``. :param data_limit: The amount of data in bytes to read/write by the - generator before stopping generation. + generator before stopping generation. If set to 0, + there will be no data limit. """ def _create_cores( diff --git a/src/python/gem5/components/processors/random_generator_core.py b/src/python/gem5/components/processors/random_generator_core.py index 67f3f5e4ac..e2f7cb2749 100644 --- a/src/python/gem5/components/processors/random_generator_core.py +++ b/src/python/gem5/components/processors/random_generator_core.py @@ -60,8 +60,9 @@ class RandomGeneratorCore(AbstractGeneratorCore): a random traffic specific to the parameters below. This core uses PyTrafficGen to create and inject the synthetic traffic. - :param duration: The number of ticks for the generator core to generate - traffic. + :param duration: The duration of time for which the generator core generates + traffic. Must be a string containing a positive number + and some unit. For example, "1ms". :param rate: The rate at which the synthetic data is read/written. :param block_size: The number of bytes to be read/written with each request. @@ -73,7 +74,8 @@ class RandomGeneratorCore(AbstractGeneratorCore): requests. The write percentage would be equal to ``100 - rd_perc``. :param data_limit: The amount of data in bytes to read/write by the - generator before stopping generation. + generator before stopping generation. If set to 0, + there will be no data limit. """ self.generator = PyTrafficGen() self._duration = duration diff --git a/src/python/gem5/components/processors/strided_generator.py b/src/python/gem5/components/processors/strided_generator.py index e14d4f5e0d..e91eaee12d 100644 --- a/src/python/gem5/components/processors/strided_generator.py +++ b/src/python/gem5/components/processors/strided_generator.py @@ -65,6 +65,35 @@ class StridedGenerator(AbstractGenerator): data_limit=data_limit, ) ) + """The strided generator + + This class defines an external interface to create a list of strided + generator cores that could replace the processing cores in a board. + + :param duration: The duration of time for which the generator generates + traffic. Must be a string containing a positive number + and some unit. For example, "1ms". + :param rate: The rate at which the data accesses are demanded. + :param block_size: The number of bytes to be read/written with each + request. + :param superblock_size: The number of bytes to read/write contiguously + per stride. Must be a multiple of block_size. + :param stride_size: The number of bytes from the beginning of one superblock + to the beginning of the next superblock. + Must be a multiple of superblock_size. + :param min_addr: The lower bound of the address range the generator + will read/write from/to. + :param max_addr: The upper bound of the address range the generator + will read/write from/to. + :param offset: The starting offset in bytes from min_addr at which + the generator reads/writes. Must be a multiple of superblock_size. + :param rd_perc: The percentage of read requests among all the generated + requests. The write percentage would be equal to + ``100 - rd_perc``. + :param data_limit: The amount of data in bytes to read/write by the + generator before stopping generation. If set to 0, + there will be no data limit. + """ def _create_cores( self, diff --git a/src/python/gem5/components/processors/strided_generator_core.py b/src/python/gem5/components/processors/strided_generator_core.py index debc945957..9efa89184b 100644 --- a/src/python/gem5/components/processors/strided_generator_core.py +++ b/src/python/gem5/components/processors/strided_generator_core.py @@ -59,6 +59,36 @@ class StridedGeneratorCore(AbstractGeneratorCore): data_limit: int, ) -> None: super().__init__() + """ The strided generator core interface. + + This class defines the interface for a generator core that will create + a strided traffic specific to the parameters below. This core + uses PyTrafficGen to create and inject the synthetic traffic. + + :param duration: The duration of time for which the generator core generates + traffic. Must be a string containing a positive number + and some unit. For example, "1ms". + :param rate: The rate at which the data accesses are demanded. + :param block_size: The number of bytes to be read/written with each + request. + :param superblock_size: The number of bytes to read/write contiguously + per stride. Must be a multiple of block_size. + :param stride_size: The number of bytes from the beginning of one superblock + to the beginning of the next superblock. + Must be a multiple of superblock_size. + :param min_addr: The lower bound of the address range the generator + will read/write from/to. + :param max_addr: The upper bound of the address range the generator + will read/write from/to. + :param offset: The starting offset in bytes from min_addr at which + the generator reads/writes. Must be a multiple of superblock_size. + :param rd_perc: The percentage of read requests among all the generated + requests. The write percentage would be equal to + ``100 - rd_perc``. + :param data_limit: The amount of data in bytes to read/write by the + generator before stopping generation. If set to 0, + there will be no data limit. + """ self.generator = PyTrafficGen() self._duration = duration