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

Platform-agnostic C timers #115

Open
tiagolascasas opened this issue Mar 17, 2023 · 1 comment
Open

Platform-agnostic C timers #115

tiagolascasas opened this issue Mar 17, 2023 · 1 comment

Comments

@tiagolascasas
Copy link
Member

tiagolascasas commented Mar 17, 2023

When using the lara.code.Timer API, the timers inserted into the code are those from the current OS, i.e., Windows timers if Clava is running on Windows, and UNIX timers if it is running on Linux or other *nix.

However, I've run into the use case where I am working with Linux-specific input C code, but since I am running Clava on Windows it inserts Windows timers into the Linux application.

Therefore, I suggest an additional (optional) argument to the Timer constructor, specifying which kinds of timers we want to use, like so:

const timer = new Timer("MICROSECONDS", this.filename);

becomes

const timer = new Timer("MICROSECONDS", this.filename, "UNIX");

As an added note, I don't think this problem happens with C++, as it uses STL timers in that scenario. This is a C-only issue.

@tiagolascasas tiagolascasas changed the title Platform-agnostic timers Platform-agnostic C timers Mar 17, 2023
@joaobispo
Copy link
Member

The Timer API, as well as other APIs that generate code that depends on the platform, use the API Platforms to check on which platform they are currently executing.

The API contains setters (e.g. Platforms.setLinux()) which can be used to set a particular platform. That is the preferred way to generate code for a target platform that is not the same as the host platform.

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

No branches or pull requests

2 participants