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

[llvm] Add utility functions to split and merge benchmarks. #772

Conversation

ChrisCummins
Copy link
Contributor

@ChrisCummins ChrisCummins commented Oct 31, 2022

This adds three new utility functions for constructing LLVM benchmarks:

def make_benchmark_from_source(
    source: str,
    copt: Optional[List[str]] = None,
    lang: str = "c++",
    system_includes: bool = True,
    timeout: int = 600,
) -> Benchmark:
    ...

def split_benchmark_by_function(
    benchmark: Benchmark, timeout: float = 300
) -> List[Benchmark]:
    ...

def merge_benchmarks(
    benchmarks: List[Benchmark], timeout: float = 300
) -> Benchmark:
   ...

Credit to @hughleat for llvm-extract-one, an extension of LLVM's llvm-extract that enables functions to be extracted by an integer index rather than by name. This enables extracting anonymous functions.

Todo before land

  • Merge CompilerGym v0.2.5 #767 and rebase on v0.2.5 (no conflicts).
  • Confirm CMake + bazel builds succeed.
  • Add test coverage for the two new functions.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 31, 2022
@ChrisCummins ChrisCummins added this to the v0.2.6 milestone Oct 31, 2022
@ChrisCummins ChrisCummins added the LLVM LLVM-specific environment issue label Oct 31, 2022
@ChrisCummins ChrisCummins force-pushed the feature/llvm-extract-one branch 2 times, most recently from e1bea2d to edc5348 Compare November 2, 2022 06:05
@ChrisCummins ChrisCummins marked this pull request as ready for review November 2, 2022 06:05
@ChrisCummins ChrisCummins force-pushed the feature/llvm-extract-one branch from edc5348 to f0a8170 Compare November 2, 2022 06:33
@codecov-commenter
Copy link

codecov-commenter commented Nov 2, 2022

Codecov Report

Merging #772 (19da5e6) into development (b017c81) will increase coverage by 0.32%.
The diff coverage is 94.91%.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##           development     #772      +/-   ##
===============================================
+ Coverage        88.56%   88.88%   +0.32%     
===============================================
  Files              131      131              
  Lines             8008     8063      +55     
===============================================
+ Hits              7092     7167      +75     
+ Misses             916      896      -20     
Impacted Files Coverage Δ
compiler_gym/envs/llvm/__init__.py 100.00% <ø> (ø)
compiler_gym/envs/llvm/llvm_benchmark.py 93.43% <94.54%> (+0.37%) ⬆️
compiler_gym/datasets/benchmark.py 99.04% <100.00%> (-0.01%) ⬇️
compiler_gym/third_party/llvm/__init__.py 93.54% <100.00%> (+0.21%) ⬆️
...loop_tool/service/loop_tool_compilation_session.py 89.86% <0.00%> (-0.68%) ⬇️
compiler_gym/envs/gcc/service/gcc_service.py 95.97% <0.00%> (+0.36%) ⬆️
compiler_gym/envs/llvm/datasets/poj104.py 76.81% <0.00%> (+1.44%) ⬆️
compiler_gym/service/connection.py 79.28% <0.00%> (+1.94%) ⬆️
compiler_gym/views/observation_space_spec.py 85.71% <0.00%> (+2.85%) ⬆️
...ompiler_gym/service/client_service_compiler_env.py 90.98% <0.00%> (+2.93%) ⬆️
... and 1 more

This adds three utility functions:

    def make_benchmark_from_source(
        source: str,
        copt: Optional[List[str]] = None,
        lang: str = "c++",
        system_includes: bool = True,
        timeout: int = 600,
    ) -> Benchmark:
        ...

    def split_benchmark_by_function(
        benchmark: Benchmark, timeout: float = 300
    ) -> List[Benchmark]:
        ...

    def merge_benchmarks(
        benchmarks: List[Benchmark], timeout: float = 300
    ) -> Benchmark:
       ...

Credit to @hughleat for llvm-extract-one, an extension of LLVM's
llvm-extract that enables functions to be extracted by an integer
index rather than by name. This enables extracting anonymous
functions.
@ChrisCummins ChrisCummins force-pushed the feature/llvm-extract-one branch from c033465 to 19da5e6 Compare November 2, 2022 18:59
Copy link

@kevinleestone kevinleestone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your work on this. This LGTM.

@ChrisCummins ChrisCummins merged commit 06f81e1 into facebookresearch:development Nov 3, 2022
@ChrisCummins ChrisCummins deleted the feature/llvm-extract-one branch November 3, 2022 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. LLVM LLVM-specific environment issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants