Commit 62c85c1d authored by Ondrej Vysocky's avatar Ondrej Vysocky
Browse files

ADD a basic compute kernel to load the system insted of using sleep() #11

parent f0889fbb
......@@ -6,6 +6,8 @@
#include <iostream>
#include <unistd.h>
#include "work.h"
int main(int argc, char **argv)
{
// MERIC_Init();
......@@ -18,7 +20,7 @@ int main(int argc, char **argv)
// MERIC_MeasureStart("B");
READEX_REGION_DEFINE(B);
READEX_REGION_START(B, "B", SCOREP_USER_REGION_TYPE_COMMON);
sleep(1);
do_work(1);
// MERIC_MeasureStop();
READEX_REGION_STOP(B);
......@@ -31,7 +33,7 @@ int main(int argc, char **argv)
// MERIC_MeasureStart("B");
READEX_REGION_START(B, "B", SCOREP_USER_REGION_TYPE_COMMON);
sleep(2);
do_work(2);
// MERIC_MeasureStop();
READEX_REGION_STOP(B);
......
//#define _GNU_SOURCE
/*
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
*/
#include <sys/time.h>
#define REPS 100000
double timespec2double(timespec time)
{
return time.tv_sec + (double)time.tv_nsec/1e9;
}
void do_work(double timeout)
{
int i, l = 1;
double exe_time = 0;
struct timespec start, end;
while(1)
{
clock_gettime(CLOCK_MONOTONIC, &start);
for(i = 0; i < REPS; i++)
l += l * i;
clock_gettime(CLOCK_MONOTONIC, &end);
exe_time += timespec2double(end) - timespec2double(start);
if(exe_time > timeout)
break;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment