MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / fib

Function fib

check/TestHighsParallel.cpp:23–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23int64_t fib(const int64_t n) {
24 if (n <= 20) return fib_sequential(n);
25
26 int64_t n1;
27 parallel::spawn([&]() {
28 n1 = fib(n - 1);
29 TSAN_ANNOTATE_HAPPENS_BEFORE(&n1);
30 });
31
32 int64_t n2 = fib(n - 2);
33 TSAN_ANNOTATE_HAPPENS_BEFORE(&n2);
34
35 parallel::sync();
36
37 TSAN_ANNOTATE_HAPPENS_AFTER(&n1);
38 TSAN_ANNOTATE_HAPPENS_AFTER(&n2);
39 // printf("fib(%ld) = %ld + %ld = %ld\n", n, n1, n2, n1 + n2);
40 return n1 + n2;
41}
42#if 0
43int64_t fib_omp(const int64_t n) {
44 if (n <= 20) return fib_sequential(n);

Callers 1

Calls 3

fib_sequentialFunction · 0.85
spawnFunction · 0.85
syncFunction · 0.85

Tested by

no test coverage detected