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

Build on MacOs (10.9) #2

Closed
dcoeurjo opened this issue Jan 15, 2014 · 9 comments
Closed

Build on MacOs (10.9) #2

dcoeurjo opened this issue Jan 15, 2014 · 9 comments
Assignees

Comments

@dcoeurjo
Copy link
Contributor

the project does not compile on MacOs (maverick 10.9).

(as traced in the cmake output, the compiler is Clang 5.0)

@ghost ghost assigned dmah42 Jan 15, 2014
@dmah42
Copy link
Member

dmah42 commented Jan 15, 2014

The first error is fixed as of 4e21f5e.

The second error is curious as State is a friend so should be able to access the private member (and can in my non-clang Linux build).

@dcoeurjo
Copy link
Contributor Author

thanks @dominichamon,

I'm still having bunch of issues (and 4e21f5e fixes the first one I reported): https://gist.github.com/dcoeurjo/8443935

@dmah42
Copy link
Member

dmah42 commented Jan 16, 2014

This is really useful, thank you. I don't have an OSX machine to test on right now.

I just pushed commit c44662e that should help with some (or all) of those errors. Please let me know.

@dcoeurjo
Copy link
Contributor Author

Few warnings that are reported as "errors" (thanks to -Werror option):

/Users/davidcoeurjolly/local/src/benchmark/src/sysinfo.cc:74:8: error: unused variable 'saw_mhz' [-Werror,-  Wunused-variable]
bool saw_mhz = false;

and

 14%] Building CXX object CMakeFiles/benchmark.dir/src/sysinfo.cc.o
 /Users/davidcoeurjolly/local/src/benchmark/src/sysinfo.cc:47:9: error: unused function 'EstimateCyclesPerSecond' [-Werror,-Wunused-function] 
 int64_t EstimateCyclesPerSecond() {
           ^
 /Users/davidcoeurjolly/local/src/benchmark/src/sysinfo.cc:55:6: error: unused function 'ReadIntFromFile' [-Werror,-Wunused-function]
 bool ReadIntFromFile(const char* file, int* value) {
       ^ 
 2 errors generated.

Beside this warnings, there is no more build errors ;)

@dcoeurjo
Copy link
Contributor Author

BTW, it'd be better to have the binary and libs compiled in the current cmake build directory rather than in the source tree (bin/, libs/).

I'm running the benchmark_test

@dcoeurjo
Copy link
Contributor Author

I've run the benchmark test and it's a bit weird: the process uses only 5% of my CPU and does nothing to the std:err.

in this example, I've let it run 16min (wall clock) and then kill it with CTRL-C

time benchmark_test
Reading /proc/self/cputime_ns failed. Using getrusage().
^C
benchmark_test  11,04s user 40,18s system 5% cpu 16:21,84 total

@dmah42
Copy link
Member

dmah42 commented Jan 16, 2014

Commit e2633b9 has the warning(error) fixes.

If you want to submit a patch for cmake i'm happy to take it. The idea is that it should be creating bin and lib in the project root so you have bin, lib, include, src in the project root. Are you seeing something different?

There may be a runtime issue with osx that i don't know about.. it sounds like either one of the clocks isn't ticking or there's a thread issue. I'll try to get an osx test machine going to check it out.

@dcoeurjo
Copy link
Contributor Author

I'll prepare a pull-request for the cmake stuff.

(And no idea for the OS issue ;))

@dcoeurjo
Copy link
Contributor Author

dcoeurjo commented Feb 5, 2014

I've just updated my working copy and the current release works perfectly on MacOS ! ;)

I'm closing this issue and I've also push a pull-request with some cmake edits (make install).

@dcoeurjo dcoeurjo closed this as completed Feb 5, 2014
EricWF added a commit to efcs/benchmark that referenced this issue Mar 23, 2018
This patch addresses issue google#341 by adding the function MakeUnpredictable.
The MakeUnpredictable(...) functions can be used to prevent the optimizer
from knowing the value of the specified 'object'. The function returns
the "laundered" input, either by reference if the input was a non-const
lvalue reference, or by value (when the input was a const lvalue or rvalue).

When MakeUnpredictable is supplied a non-const lvalue, the object
referenced by the input is made unpredictable and the return value
can be ignored. Otherwise, only the return value is considered
"unpredictable". In the latter the MakeUnpredictable function
is marked [[nodiscard]] and a warning is emitted if the return
value is ignored. For example:

```c++
int divide_by_two(int Value) {
  const int Divisor = 2;
  DoNotOptimize(Divisor); // INCORRECT! Has no effect on Divisor
  MakeUnpredictable(Divisor); // INCORRECT! should warn that return is ignored.
  // Correct Usage google#1
  return Value / MakeUnpredictable(Divisor);
  // Correct Usage google#2
  const int Divisor = MakeUnpredictable(2);
  return Value / Divisor;
}
```
EricWF added a commit to efcs/benchmark that referenced this issue Mar 23, 2018
This patch addresses issue google#341 by adding the function MakeUnpredictable.
The MakeUnpredictable(...) functions can be used to prevent the optimizer
from knowing the value of the specified 'object'. The function returns
the "laundered" input, either by reference if the input was a non-const
lvalue reference, or by value (when the input was a const lvalue or rvalue).

When MakeUnpredictable is supplied a non-const lvalue, the object
referenced by the input is made unpredictable and the return value
can be ignored. Otherwise, only the return value is considered
"unpredictable". In the latter the MakeUnpredictable function
is marked [[nodiscard]] and a warning is emitted if the return
value is ignored. For example:

```c++
int divide_by_two(int Value) {
  const int Divisor = 2;
  DoNotOptimize(Divisor); // INCORRECT! Has no effect on Divisor
  MakeUnpredictable(Divisor); // INCORRECT! should warn that return is ignored.
  // Correct Usage google#1
  return Value / MakeUnpredictable(Divisor);
  // Correct Usage google#2
  const int Divisor = MakeUnpredictable(2);
  return Value / Divisor;
}
```
amallia added a commit to amallia/benchmark that referenced this issue Nov 10, 2018
Update based on suggestion google#2 from @brenoguim
dmah42 pushed a commit that referenced this issue May 17, 2021
GerHobbelt pushed a commit to GerHobbelt/benchmark that referenced this issue Mar 20, 2024
Use PMU clock cycles in aarch64 when it was enabled to allows user mode code to read
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