|
@@ -6,6 +6,9 @@ typedef struct {
|
|
|
int argc;
|
|
|
char **argv;
|
|
|
unsigned ctx;
|
|
|
+ int the_other_ctx;
|
|
|
+ int *procs;
|
|
|
+ int ncpus;
|
|
|
} params;
|
|
|
|
|
|
typedef struct {
|
|
@@ -13,13 +16,16 @@ typedef struct {
|
|
|
double avg_timing;
|
|
|
} retvals;
|
|
|
|
|
|
-#define NSAMPLES 5
|
|
|
+#define NSAMPLES 3
|
|
|
+int first = 1;
|
|
|
+pthread_mutex_t mut;
|
|
|
|
|
|
pthread_barrier_t barrier;
|
|
|
|
|
|
void* func_cholesky(void *val){
|
|
|
params *p = (params*)val;
|
|
|
unsigned sched_ctx = p->ctx;
|
|
|
+ int the_other_ctx = p->the_other_ctx;
|
|
|
|
|
|
int i;
|
|
|
retvals *rv = (retvals*)malloc(sizeof(retvals));
|
|
@@ -32,6 +38,17 @@ void* func_cholesky(void *val){
|
|
|
rv->avg_timing += timing;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ pthread_mutex_lock(&mut);
|
|
|
+ if(first)
|
|
|
+ {
|
|
|
+ starpu_delete_sched_ctx(p->ctx);
|
|
|
+ starpu_add_workers_to_sched_ctx(p->procs, p->ncpus, the_other_ctx);
|
|
|
+ }
|
|
|
+ first = 0;
|
|
|
+ pthread_mutex_unlock(&mut);
|
|
|
+
|
|
|
+
|
|
|
rv->flops /= NSAMPLES;
|
|
|
rv->avg_timing /= NSAMPLES;
|
|
|
return (void*)rv;
|
|
@@ -48,22 +65,22 @@ void cholesky_vs_cholesky(params *p1, params *p2, params *p3, int ncpus1, int nc
|
|
|
procs[i] = i;
|
|
|
|
|
|
p1->ctx = starpu_create_sched_ctx("heft", procs, ncpus1, "cholesky1");
|
|
|
-
|
|
|
+ p2->the_other_ctx = (int)p1->ctx;
|
|
|
+ p1->procs = procs;
|
|
|
+ p1->ncpus = ncpus1;
|
|
|
int procs2[ncpus2];
|
|
|
|
|
|
for(i = 0; i < ncpus2; i++)
|
|
|
procs2[i] = ncpus1+i;
|
|
|
|
|
|
p2->ctx = starpu_create_sched_ctx("heft", procs2, ncpus2, "cholesky2");
|
|
|
-
|
|
|
-/* int procs[] = {0, 2, 3, 4, 5, 6, 7, 8, 9, 10}; */
|
|
|
-/* p1->ctx = starpu_create_sched_ctx("heft", procs, 10, "cholesky1"); */
|
|
|
-
|
|
|
-/* int procs2[] = {1, 11}; */
|
|
|
-/* p2->ctx = starpu_create_sched_ctx("heft", procs2, 2, "cholesky2"); */
|
|
|
+ p1->the_other_ctx = (int)p2->ctx;
|
|
|
+ p2->procs = procs2;
|
|
|
+ p2->ncpus = ncpus2;
|
|
|
|
|
|
pthread_t tid[2];
|
|
|
pthread_barrier_init(&barrier, NULL, 2);
|
|
|
+ pthread_mutex_init(&mut, NULL);
|
|
|
|
|
|
struct timeval start;
|
|
|
struct timeval end;
|
|
@@ -82,6 +99,7 @@ void cholesky_vs_cholesky(params *p1, params *p2, params *p3, int ncpus1, int nc
|
|
|
|
|
|
gettimeofday(&end, NULL);
|
|
|
|
|
|
+ pthread_mutex_destroy(&mut);
|
|
|
starpu_helper_cublas_shutdown();
|
|
|
starpu_shutdown();
|
|
|
|
|
@@ -92,50 +110,15 @@ void cholesky_vs_cholesky(params *p1, params *p2, params *p3, int ncpus1, int nc
|
|
|
printf("%2.2f %2.2f ", ((retvals*)gflops_cholesky1)->flops, ((retvals*)gflops_cholesky2)->flops);
|
|
|
printf("%2.2f %2.2f %2.2f\n", ((retvals*)gflops_cholesky1)->avg_timing, ((retvals*)gflops_cholesky2)->avg_timing, timing);
|
|
|
|
|
|
- /* /\* 1 cholesky all alone on the whole machine *\/ */
|
|
|
- /* starpu_init(NULL); */
|
|
|
- /* starpu_helper_cublas_init(); */
|
|
|
-
|
|
|
- /* void *gflops_cholesky3 = func_cholesky((void*)p3); */
|
|
|
-
|
|
|
- /* starpu_helper_cublas_shutdown(); */
|
|
|
- /* starpu_shutdown(); */
|
|
|
|
|
|
-
|
|
|
- /* /\* 2 cholesky in a single ctx *\/ */
|
|
|
- /* starpu_init(NULL); */
|
|
|
- /* starpu_helper_cublas_init(); */
|
|
|
-
|
|
|
- /* pthread_t tid2[2]; */
|
|
|
-
|
|
|
- /* pthread_create(&tid2[0], NULL, (void*)func_cholesky, (void*)p3); */
|
|
|
- /* pthread_create(&tid2[1], NULL, (void*)func_cholesky, (void*)p3); */
|
|
|
-
|
|
|
- /* void *gflops_cholesky4; */
|
|
|
- /* void *gflops_cholesky5; */
|
|
|
-
|
|
|
- /* pthread_join(tid2[0], &gflops_cholesky4); */
|
|
|
- /* pthread_join(tid2[1], &gflops_cholesky5); */
|
|
|
-
|
|
|
- /* starpu_helper_cublas_shutdown(); */
|
|
|
- /* starpu_shutdown(); */
|
|
|
-
|
|
|
- /* printf("%2.2f %2.2f %2.2f %2.2f %2.2f ", ((retvals*)gflops_cholesky1)->flops, ((retvals*)gflops_cholesky2)->flops, ((retvals*)gflops_cholesky3)->flops, ((retvals*)gflops_cholesky4)->flops, ((retvals*)gflops_cholesky5)->flops); */
|
|
|
-
|
|
|
- /* printf("%2.2f %2.2f %2.2f %2.2f %2.2f\n", ((retvals*)gflops_cholesky1)->avg_timing, ((retvals*)gflops_cholesky2)->avg_timing, ((retvals*)gflops_cholesky3)->avg_timing, ((retvals*)gflops_cholesky4)->avg_timing, ((retvals*)gflops_cholesky5)->avg_timing); */
|
|
|
-
|
|
|
- /* free(gflops_cholesky1); */
|
|
|
- /* free(gflops_cholesky2); */
|
|
|
- /* free(gflops_cholesky3); */
|
|
|
- /* free(gflops_cholesky4); */
|
|
|
- /* free(gflops_cholesky5); */
|
|
|
}
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
{
|
|
|
// printf("argc = %d\n", argc);
|
|
|
- int ncpus1, ncpus2;
|
|
|
+ int ncpus1=0, ncpus2=0;
|
|
|
int i;
|
|
|
+
|
|
|
for (i = 9; i < argc; i++) {
|
|
|
if (strcmp(argv[i], "-ncpus1") == 0) {
|
|
|
char *argptr;
|