Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic benchmark scheduler #270

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ new_git_repository(
# The pinned version of LLVM, and its SHA256 hash. The `LLVM_COMMIT` variable in
# `.github/workflows/main.yaml` must be updated to match this everytime it is
# changed.
LLVM_COMMIT = "842fd1537521d38913aec5c9a081afedf97d88fe"
LLVM_COMMIT = "cd66c9b6a04689659348c0a3ff4c1205b1133fe9"

LLVM_SHA256 = "21a1d434b4dbbafee65c2a9fc8e64ac3e3210eab9c5d67affd8d6d36bbf979b3"
LLVM_SHA256 = "8d2a8b2e0accdf072a3897aec6a3e68d522dfc1b40416b3c4215bb5af36a36e1"

http_archive(
name = "llvm-raw",
Expand Down
14 changes: 14 additions & 0 deletions gematria/datasets/pipelines/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,17 @@ gematria_py_test(
"//gematria/proto:execution_annotation_py_pb2",
],
)

gematria_py_library(
name = "benchmark_cpu_scheduler",
srcs = ["benchmark_cpu_scheduler.py"],
)

gematria_py_test(
name = "benchmark_cpu_scheduler_test",
size = "small",
srcs = ["benchmark_cpu_scheduler_test.py"],
deps = [
":benchmark_cpu_scheduler",
],
)
35 changes: 35 additions & 0 deletions gematria/datasets/pipelines/benchmark_cpu_scheduler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2024 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from abc import ABC, abstractmethod
boomanaiden154 marked this conversation as resolved.
Show resolved Hide resolved


class BenchmarkScheduler(ABC):
boomanaiden154 marked this conversation as resolved.
Show resolved Hide resolved
boomanaiden154 marked this conversation as resolved.
Show resolved Hide resolved

@abstractmethod
def setup_and_get_benchmark_core(self) -> int | None:
pass
boomanaiden154 marked this conversation as resolved.
Show resolved Hide resolved

@abstractmethod
def verify(self):
pass


class NoSchedulingBenchmarkScheduler(BenchmarkScheduler):
boomanaiden154 marked this conversation as resolved.
Show resolved Hide resolved

def setup_and_get_benchmark_core(self) -> int | None:
return None

def verify(self):
pass
29 changes: 29 additions & 0 deletions gematria/datasets/pipelines/benchmark_cpu_scheduler_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2024 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from absl.testing import absltest

from gematria.datasets.pipelines import benchmark_cpu_scheduler


class BenchmarkSchedulerTests(absltest.TestCase):

def test_no_scheduling(self):
scheduler = benchmark_cpu_scheduler.NoSchedulingBenchmarkScheduler()
self.assertIsNone(scheduler.setup_and_get_benchmark_core())
scheduler.verify()


if __name__ == '__main__':
absltest.main()
Loading