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

workloads/geekbench: Add support for Geekbench command-line build #1278

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eliftopuz
Copy link
Contributor

Geekbench command-line build is added for Android. Geekbench apks allow to user to run the tests altogether. Using the command-line build, a single test or multiple tests can be specified.

@@ -20,10 +20,11 @@
import json
Copy link
Contributor

Choose a reason for hiding this comment

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

Please follow Linux kernel coding guideline regarding the commit message.

Describe your changes in imperative mood, e.g. “make xyzzy do frotz” instead of “[This patch] makes xyzzy do frotz” or “[I] changed xyzzy to do frotz”, as if you are giving orders to the codebase to change its behaviour.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to update copyright year (# Copyright 2013-2018 ARM Limited at the beginning of file) as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like this # Copyright 2024 ARM Limited ? I am not so sure about this, since I didn't create a new page.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd go for 2013-2025 to keep the same format, but yes ideally we should be updating the copyright year each time we update a file (although as you can see we are a little out of date...).

def init_resources(self, context):
# Necessary files to run the benchmark will be retrieved from WA as a tar file.
# WA will look for 'gb_cli_artifacts_<version>.tar' file to deploy them to the
# working directory. If there is no specified version, it will look for version 6.3.0 by default.
Copy link
Contributor

Choose a reason for hiding this comment

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

This line (and few more lines below) is too long (106 chars). Please ensure your changes are PEP-8 compliant. autopep8 command might be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was using maxLineLength=120, I didn't see any rule for max length in the WA documentation. Also in the same file I can see that some lines > 100.

Copy link
Contributor

Choose a reason for hiding this comment

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

https://peps.python.org/pep-0008/#maximum-line-length says 79 & 72, but I think 100 is OK in general.

super(GeekbenchCmdline, self).initialize(context)
# Extract the tar file
self.target.execute("{} tar -xf {} -C {}".format(self.target.busybox,
self.tar_file, self.target_working_directory))
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be easier to maintain since we would not need to match spacing until (.

self.target.execute(
    "{} tar -xf {} -C {}".format(
        self.target.busybox, self.tar_file, self.target_working_directory))

@@ -20,10 +20,11 @@
import json
from collections import defaultdict

from wa import ApkUiautoWorkload, Parameter
from wa import Workload, ApkUiautoWorkload, Parameter
Copy link
Contributor

Choose a reason for hiding this comment

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

Workload is imported, but I'm unsure if it's used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Workload is used from GeekbenchCmdline class


parameters = [
Parameter('cpumask', kind=str,
default=None, override=False, mandatory=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't default value be '' since the type is str?

if self.upload:
self.params += '--upload '
else:
self.params += '--no-upload '
Copy link
Contributor

Choose a reason for hiding this comment

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

self.params += '--upload ' if self.upload else '--no-upload ' would be slightly more Pythonic.

extension = os.path.splitext(self.output_file)[1][1:]
if self.output_file and extension not in self.allowed_extensions:
msg = 'No allowed extension specified. Allowed extensions: {}'
raise ValueError(msg.format(', '.join(self.allowed_extensions)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this be more appropriate to build error message in a single place?

msg = f"No allowed extension specified. Allowed extensions: {', '.join(self.allowed_extensions)}"
raise ValueError(msg)

for match in matches:
scores.append(int(re.search(r'\d+', match).group(0)))
if self.section == 4:
context.add_metric("OpenCL Score " + self.workloads[workload], scores[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

It can also be Vulkan in addition to OpenCL, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OpenCL and Vulkan has different sections. I changed this part a bit. You can check the updated version.


def extract_results(self, context):
super(GeekbenchCmdline, self).extract_results(context)
# Extract results on the target
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment should be swapped with the previous line?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment still pending?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I did change the comment with the previous line.


@once
def finalize(self, context):
# Clean up the working directory
Copy link
Contributor

Choose a reason for hiding this comment

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

You can drop this comment. It does not add much value.

@@ -20,10 +20,11 @@
import json
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd go for 2013-2025 to keep the same format, but yes ideally we should be updating the copyright year each time we update a file (although as you can see we are a little out of date...).


parameters = [
Parameter('cpumask', kind=str,
default='', override=False, mandatory=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless we're setting override or mandatory we don't need to explicitly need to set these values for these Parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will remove those options.

self.deployable_assets = [''.join(['gb_cli_artifacts', '_', self.version, '.tar'])]

# Create a working directory
self.target.working_directory = self.target.path.join(self.target.working_directory, f'gb_cli-{self.version}')
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't be trying to change the working directory of the target from a workload.
Is this meant to be self.target_working_directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will change this part.
But I am still changing the working_directory in the agenda file when I am running the workload. Otherwise it gives me a permission error and cannot execute the binary.

Copy link
Contributor

Choose a reason for hiding this comment

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

Changing the working_directory from the agenda is fine as this would be a conscious decision by the user and would impact all workloads equally.

Otherwise it gives me a permission error and cannot execute the binary.

If these are binaries that require execution permission, is there a reason they need to be in the working directory? Or could we use target.install for this instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Marc,
I did change this part and now I am extracting the assets in the executables_directory. Also there is no need to change working_directory in the agenda file.


# Create a working directory
self.target.working_directory = self.target.path.join(self.target.working_directory, f'gb_cli-{self.version}')
self.target.execute("mkdir -p {}".format(self.target.working_directory))
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

Comment on lines 523 to 524
def validate(self):
super(GeekbenchCmdline, self).validate()
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're not doing anything workload specific here do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will remove that one.

@scojac01
Copy link
Contributor

Does Geekbench command line not require a license to run? Should we be upstreaming workloads that have such a dependency?

@lukaszluba-arm
Copy link

Hi Scott,

  1. Yes, it needs a license.
  2. This dependency is easy to solve and we can ask our partners to get their own license (internally in different teams - we don't have that issue).

On the other hand... Not having the GB6 cmd line version prevents us from being efficient in our experiments (and aligned across different teams that everyone can reproduce exactly the same scenario).

The APK from public store doesn't allow you to run single sub-test and be more precised how it should be run.
This pull request will be beneficial for a lot of use cases that we (and our partners) investigate.

@scojac01
Copy link
Contributor

Hi Scott,

  1. Yes, it needs a license.
  2. This dependency is easy to solve and we can ask our partners to get their own license (internally in different teams - we don't have that issue).

On the other hand... Not having the GB6 cmd line version prevents us from being efficient in our experiments (and aligned across different teams that everyone can reproduce exactly the same scenario).

The APK from public store doesn't allow you to run single sub-test and be more precised how it should be run. This pull request will be beneficial for a lot of use cases that we (and our partners) investigate.

If we agree that the dependency is for users of WA to sort themselves then that's fine. We have a geekbench cli workload that we have used for years and have not upstreamed because we were under the impression that such a thing was frowned upon.

def run(self, context):
super(GeekbenchCmdline, self).run(context)
taskset = f"taskset {self.cpumask}" if self.cpumask else ""
cmd = '{} {}/{} {}'.format(taskset, self.target_exec_directory, self.binary_name, self.params)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use target.join() instead of hardcoding a /.

super(GeekbenchCmdline, self).setup(context)

self.params = ''
if self.section == 4:
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC the 3 options for section are 1,4,9, is there a reason that we have 3 separate if statements all of which include the same self.params += '--section {} '.format(self.section) line?
Would it make more sense to only add the core explicitly for section 1?


def extract_results(self, context):
super(GeekbenchCmdline, self).extract_results(context)
# Extract results on the target
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment still pending?

@marcbonnici
Copy link
Contributor

If we agree that the dependency is for users of WA to sort themselves then that's fine. We have a geekbench cli workload that we have used for years and have not upstreamed because we were under the impression that such a thing was frowned upon.

Hi @scojac01,

That's interesting, I had thought we had set precedence for this back with the geekbench-corporate workload, in that if we can assume that it is reasonable that a non-trivial amount of other users would be able to source the appropriate workloads, then it could still be beneficial to upstream the workload.

Are you aware of of substantial differences between the availability of the corporate vs the cli flavours of the workloads?

Add Geekbench command-line build workload for Android targets.
Geekbench apks allow to user to run the tests altogether. Using the
command-line, a single test or multiple tests can be specified.

Signed-off-by: Elif Topuz <[email protected]>
@scojac01
Copy link
Contributor

scojac01 commented Mar 3, 2025

If we agree that the dependency is for users of WA to sort themselves then that's fine. We have a geekbench cli workload that we have used for years and have not upstreamed because we were under the impression that such a thing was frowned upon.

Hi @scojac01,

That's interesting, I had thought we had set precedence for this back with the geekbench-corporate workload, in that if we can assume that it is reasonable that a non-trivial amount of other users would be able to source the appropriate workloads, then it could still be beneficial to upstream the workload.

Are you aware of of substantial differences between the availability of the corporate vs the cli flavours of the workloads?

Hi @marcbonnici That's fair enough. We must have missed that but happy with that precedent. The cli workload is the corporate one just triggered in a different method with a few extra params. The license should be the same so no impact there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants