[Gs-commits] r535 - in trunk/code/src/gsl: parser resources/mpi/test resources/timer/test
Author: slang Date: 2009-05-22 13:02:47 -0500 (Fri, 22 May 2009) New Revision: 535 Added: trunk/code/src/gsl/resources/timer/test/pthread-compare.gs Removed: trunk/code/src/gsl/parser/gs-parser Modified: trunk/code/src/gsl/resources/mpi/test/pthread-compare.gs trunk/code/src/gsl/resources/timer/test/module.mk.in Log: removed parser binary. Too hard to manage binaries across x86 and x86_64. Hopefully people will be able to just install ghc. Adding pthread comparison for the timer resource. Deleted: trunk/code/src/gsl/parser/gs-parser =================================================================== (Binary files differ) Modified: trunk/code/src/gsl/resources/mpi/test/pthread-compare.gs =================================================================== --- trunk/code/src/gsl/resources/mpi/test/pthread-compare.gs 2009-05-22 16:50:58 UTC (rev 534) +++ trunk/code/src/gsl/resources/mpi/test/pthread-compare.gs 2009-05-22 18:02:47 UTC (rev 535) @@ -37,7 +37,8 @@ { ret = gs_mpi_recv( recvbuf, 1024, MPI_CHAR, - (numprocs+(rank-i))%numprocs, (numprocs+(rank-i))%numprocs, MPI_COMM_WORLD, &status); + (numprocs+(rank-i))%numprocs, + (numprocs+(rank-i))%numprocs, MPI_COMM_WORLD, &status); } } } Modified: trunk/code/src/gsl/resources/timer/test/module.mk.in =================================================================== --- trunk/code/src/gsl/resources/timer/test/module.mk.in 2009-05-22 16:50:58 UTC (rev 534) +++ trunk/code/src/gsl/resources/timer/test/module.mk.in 2009-05-22 18:02:47 UTC (rev 535) @@ -1,3 +1,6 @@ DIR := resources/timer/test -GSTESTSRC += $(DIR)/timer1.gs +GSTESTSRC += $(DIR)/timer1.gs \ + $(DIR)/pthread-compare.gs + +MODLIBS_$(DIR)/pthread-compare.gs = -lpthread Added: trunk/code/src/gsl/resources/timer/test/pthread-compare.gs =================================================================== --- trunk/code/src/gsl/resources/timer/test/pthread-compare.gs (rev 0) +++ trunk/code/src/gsl/resources/timer/test/pthread-compare.gs 2009-05-22 18:02:47 UTC (rev 535) @@ -0,0 +1,116 @@ +#include <stdio.h> +#include <pthread.h> +#include <unistd.h> +#include "include/gs.h" +#include "resources/timer/gs-timer.gsh" + +static int value = 0; +gs_mutex_t mutex = GS_MUTEX_INITIALIZER; + +static __blocking int gs_dosleep(void) +{ + int ret; + + pwait + { + int i; + + for(i = 0; i < 1000; ++i) + { + pbranch + { + gs_timer(1000); + } + } + } + + return 0; +} + +static int done = 0; +static void done_cb(void *up, int ret) +{ + done = 1; +} + +static void *threadfun(void *cb) +{ + sleep(1); +} + +static void thread_dosleep(void) +{ + int i, ret; + void *val; + pthread_t tid[100]; + for(i = 0; i < 100; ++i) + { + ret = pthread_create(&tid[i], NULL, threadfun, NULL); + if(ret != 0) + { + perror("pthread_create failed!\n"); + assert(ret == 0); + } + } + + for(i = 0; i < 100; ++i) + { + pthread_join(tid[i], &val); + } + + return; +} + + + +int main(int argc, char *argv[]) +{ + gs_op_id_t op_id; + gs_context_t ctx; + struct timeval t1, t2, diff; + + gs_timer_init(); + + gs_context_create(&ctx, 1, "timer"); + + gettimeofday(&t1, NULL); + gs_dosleep_post(done_cb, NULL, NULL, ctx, &op_id); + while (done == 0) + { + gs_poll(ctx, 10); + } + gettimeofday(&t2, NULL); + diff.tv_sec = t2.tv_sec - t1.tv_sec; + diff.tv_usec = t2.tv_usec - t1.tv_usec; + if(t2.tv_usec < t1.tv_usec) + { + diff.tv_sec--; + diff.tv_usec += 1e6; + } + printf("gs time: %d.%06d secs\n", diff.tv_sec, diff.tv_usec); + + gettimeofday(&t1, NULL); + thread_dosleep(); + gettimeofday(&t2, NULL); + diff.tv_sec = t2.tv_sec - t1.tv_sec; + diff.tv_usec = t2.tv_usec - t1.tv_usec; + if(t2.tv_usec < t1.tv_usec) + { + diff.tv_sec--; + diff.tv_usec += 1e6; + } + printf("thread time: %d.%06d secs\n", diff.tv_sec, diff.tv_usec); + + gs_context_destroy(ctx); + gs_timer_finalize(); + return 0; +} + +/* + * Local variables: + * c-indent-level: 4 + * c-basic-offset: 4 + * End: + * + * vim: ts=8 sts=4 sw=4 expandtab + */
participants (1)
-
slang@mcs.anl.gov