-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of git.nic.uoregon.edu:/gitroot/xpress-apex in…
…to develop
- Loading branch information
Showing
5 changed files
with
101 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include "apex_api.hpp" | ||
#include <unistd.h> | ||
#include <stdio.h> | ||
#include <thread> | ||
#include <string> | ||
#include "thread_instance.hpp" | ||
|
||
#define MAX_OUTER 50 | ||
#define MAX_INNER 50 | ||
#define MAX_THREADS 8 | ||
|
||
uint64_t func(uint64_t i) { | ||
char name[128]; | ||
sprintf(name, "func %lu", i); | ||
apex::profiler* p = apex::start(std::string(name)); | ||
uint64_t j = i * i; | ||
apex::stop(p); | ||
return j; | ||
} | ||
|
||
uint64_t foo(uint64_t i) { | ||
uint64_t j=0; | ||
apex::register_thread(__func__); | ||
apex::profiler* p = apex::start((apex_function_address)(&foo)); | ||
for (uint64_t x = 0 ; x < MAX_OUTER ; x++) { | ||
for (uint64_t y = 0 ; y < MAX_INNER ; y++) { | ||
j += func(x) * func(y) + i; | ||
} | ||
} | ||
apex::stop(p); | ||
return j; | ||
} | ||
|
||
// no timer! | ||
uint64_t bar(uint64_t i) { | ||
// ask for a thread instance, as a test. | ||
// | ||
//apex::thread_instance::instance(false); | ||
// create a task, but don't start a timer. | ||
apex::new_task((apex_function_address)&bar); | ||
uint64_t j=0; | ||
for (uint64_t x = 0 ; x < MAX_OUTER ; x++) { | ||
for (uint64_t y = 0 ; y < MAX_INNER ; y++) { | ||
j += (x*x) * (y*y) + i; | ||
} | ||
} | ||
return j; | ||
} | ||
|
||
int main (int argc, char** argv) { | ||
apex::init("apex_start unit test", 0, 1); | ||
apex::profiler* p = apex::start((apex_function_address)&main); | ||
uint64_t i = 0; | ||
std::thread threads[MAX_THREADS]; | ||
for (i = 0 ; i < MAX_THREADS ; i++) { | ||
//j += foo(i); | ||
if (i % 2 == 0) { | ||
// create a worker thread | ||
threads[i] = std::thread(foo,i); | ||
} else { | ||
// create a non-worker thread | ||
threads[i] = std::thread(bar,i); | ||
} | ||
} | ||
for (i = 0 ; i < MAX_THREADS ; i++) { | ||
threads[i].join(); | ||
} | ||
apex::stop(p); | ||
apex::finalize(); | ||
apex::cleanup(); | ||
return 0; | ||
} | ||
|