[GHC] #1933: Zero times in profiling with GHC-6.8.1
GHC
trac at galois.com
Thu Nov 29 09:07:34 EST 2007
#1933: Zero times in profiling with GHC-6.8.1
-------------------------------+--------------------------------------------
Reporter: daniel.is.fischer | Owner: simonmar
Type: bug | Status: new
Priority: normal | Milestone: 6.8.3
Component: Profiling | Version: 6.8.1
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Testcase: | Architecture: x86
Os: Linux |
-------------------------------+--------------------------------------------
Comment (by daniel.is.fischer):
I don't really know what I'm doing, but after digging in a number of
header files I did not understand, I got this programme:
{{{
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <signal.h>
#include <unistd.h>
static volatile int tock = 0;
static void handler(int i)
{
tock = 1;
}
int main(int argc, char *argv[])
{
struct sigevent ev;
timer_t timer;
struct itimerspec it;
struct sigaction action;
unsigned int i;
int m,n,count = 0;
ev.sigev_notify = SIGEV_SIGNAL;
ev.sigev_signo = SIGVTALRM;
printf("%u\n",i);
printf("Random timer is %d\n",timer);
printf("Getting time\n");
m = timer_gettime(timer,&it);
printf("Resulted in %d\n",m);
printf("Timer says: interval is %lld, %ld,\nvalue is %lld, %ld\n"
,(long long)it.it_interval.tv_sec,it.it_interval.tv_nsec
,(long long)it.it_value.tv_sec,it.it_value.tv_nsec);
printf("timer is %d after first gettime\n",timer);
if (timer_create(CLOCK_PROCESS_CPUTIME_ID, &ev, &timer) != 0) {
printf("No CLOCK_PROCESS_CPUTIME_ID timer\n");
exit(1);
}
printf("timer created with CLOCK_PROCESS_CPUTIME_ID is %d\n",timer);
for(n = 3; n < 20000; n++){
for(m = 2; m <= n/2; m++){
if (!(n%m)) count++;
}
}
printf("%d divisors\n",count);
printf("Getting time\n");
m = timer_gettime(timer,&it);
printf("Resulted in %d\n",m);
printf("Timer says: interval is %lld, %ld,\nvalue is %lld, %ld\n"
,(long long)it.it_interval.tv_sec,it.it_interval.tv_nsec
,(long long)it.it_value.tv_sec,it.it_value.tv_nsec);
printf("timer now is %d\n",timer);
if (timer_create(CLOCK_REALTIME, &ev, &timer) != 0) {
printf("No CLOCK_REALTIME timer\n");
exit(2);
}
printf("timer created with CLOCK_REALTIME is %d\n",timer);
printf("Getting time\n");
m = timer_gettime(timer,&it);
printf("Resulted in %d\n",m);
printf("Timer says: interval is %lld, %ld,\nvalue is %lld, %ld\n"
,(long long)it.it_interval.tv_sec,it.it_interval.tv_nsec
,(long long)it.it_value.tv_sec,it.it_value.tv_nsec);
printf("timer now is %d\n",timer);
for(n = 3; n < 20000; n++){
for(m = 2; m <= n/2; m++){
if (!(n%m)) count++;
}
}
printf("%d divisors\n",count);
printf("Getting time\n");
m = timer_gettime(timer,&it);
printf("Resulted in %d\n",m);
printf("Timer says: interval is %lld, %ld,\nvalue is %lld, %ld\n"
,(long long)it.it_interval.tv_sec,it.it_interval.tv_nsec
,(long long)it.it_value.tv_sec,it.it_value.tv_nsec);
printf("timer finally is %d\n",timer);
action.sa_handler = handler;
action.sa_flags = 0;
sigemptyset(&action.sa_mask);
if (sigaction(SIGVTALRM, &action, NULL) == -1) {
printf("SIGVTALRM problem\n");
exit(3);
}
it.it_value.tv_sec = 0;
it.it_value.tv_nsec = 1;
it.it_interval = it.it_value;
if (timer_settime(timer, 0, &it, NULL) != 0) {
printf("settime problem\n");
exit(4);
}
usleep(100);
if (tock) exit(0);
exit(5);
return 0;
exit(0);
}
}}}
and from that the output
{{{
dafis at linux:~/Documents> gcc -Wall -o timerTest Timertest.c -lrt
dafis at linux:~/Documents> ./timerTest
134513370
Random timer is 1075293183
Getting time
Resulted in -1
Timer says: interval is 1075248004, -1073745532,
value is 1074079461, 1075321808
timer is 1075293183 after first gettime
timer created with CLOCK_PROCESS_CPUTIME_ID is 0
161150 divisors
Getting time
Resulted in 0
Timer says: interval is 0, 0,
value is 0, 0
timer now is 0
timer created with CLOCK_REALTIME is 1
Getting time
Resulted in 0
Timer says: interval is 0, 0,
value is 0, 0
timer now is 1
322300 divisors
Getting time
Resulted in 0
Timer says: interval is 0, 0,
value is 0, 0
timer finally is 1
dafis at linux:~/Documents>
}}}
So if I interpret this right, timer_create does work, but timer_gettime
doesn't.
If you give me a good lead, I can investigate further, but I know
practically nothing about the C-libs, so please be detailed.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1933#comment:14>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list