Script started on Tue 04 Oct 2016 09:12:10 AM PDT [bxli127@pc60 Rowdist-R-manyflags]$ cat rowdistacc.c #include void rdist(double *x, double *dist, int *rc) { int nrow = rc[0]; int ncol = rc[1]; double sum, diff; int len = nrow * ncol; int distlen = nrow * nrow; #pragma acc data copy(x[0:len], dist[0:distlen]) #pragma acc kernels { // note: adjust for R using row-major order for (int i = 0; i < nrow; i++) { for (int j = 0; j < nrow; j++) { sum = 0.0; for (int k = 0; k < ncol; k++) { diff = x[i + k * nrow] - x[j + k *nrow]; sum += pow(diff, 2); } sum = pow(sum, 0.5); dist[i + j*nrow] = sum; } } } } [bxli127@pc60 Rowdist-R-manyflags]$ pgcc -acc -fPIC -c -g rowdistacc.c -o rowdistacc.o [bxli127@pc60 Rowdist-R-manyflags]$ pgcc -acc -shared -o rowdistacc.so rowdistacc.o [bxli127@pc60 Rowdist-R-manyflags]$ R R version 3.3.1 (2016-06-21) -- "Bug in Your Hair" Copyright (C) 2016 The R Foundation for Statistical Computing Platform: x86_64-redhat-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [Previously saved workspace restored] > rm(list = ls()) > ls() character(0) > dyn.load("rowdistacc.so") > row = 1000; col = 1000; x = matrix(1:(row*col), row, col); dist = matrix(0, row, row) > a =system.time(.C("rdist",as.double(x), as.double(dist), as.integer(dim(x)))) call to cuStreamSynchronize returned error 702: Launch timeout call to cuMemFreeHost returned error 702: Launch timeout Message from syslogd@pc60 at Oct 4 09:14:54 ... kernel:NMI watchdog: BUG: soft lockup - CPU#5 stuck for 22s! [swapper/5:0] [bxli127@pc60 Rowdist-R-manyflags]$ exit exit Script done on Tue 04 Oct 2016 09:15:10 AM PDT Script started on Tue 04 Oct 2016 09:05:09 AM PDT [bxli127@pc60 Rowdist-R-manyflags]$ cat rowdistacc.c #include void rdist(double *x, double *dist, int *rc) { int nrow = rc[0]; int ncol = rc[1]; double sum, diff; int len = nrow * ncol; int distlen = nrow * nrow; #pragma acc data copy(x[0:len], dist[0:distlen]) #pragma acc kernels { // note: adjust for R using row-major order for (int i = 0; i < nrow; i++) { for (int j = 0; j < nrow; j++) { sum = 0.0; for (int k = 0; k < ncol; k++) { diff = x[i + k * nrow] - x[j + k *nrow]; sum += pow(diff, 2); } sum = pow(sum, 0.5); dist[i + j*nrow] = sum; } } } } [bxli127@pc60 Rowdist-R-manyflags]$ pgcc -acc -fPIC -c rowdistacc.c -o rowdistacc.o [bxli127@pc60 Rowdist-R-manyflags]$ pgcc -acc -shared -o rowdistacc.so rowdistacc.o [bxli127@pc60 Rowdist-R-manyflags]$ R R version 3.3.1 (2016-06-21) -- "Bug in Your Hair" Copyright (C) 2016 The R Foundation for Statistical Computing Platform: x86_64-redhat-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [Previously saved workspace restored] > rm(list = ls()) > ls() character(0) > dyn.load("rowdistacc.so") > row = 1000; col = 1000; x = matrix(1:(row*col), row, col); dist = matrix(0, row, row) > a =system.time(.C("rdist",as.double(x), as.double(dist), as.integer(dim(x)))) > a user system elapsed 4.633 0.831 5.671 > q() Save workspace image? [y/n/c]: n [bxli127@pc60 Rowdist-R-manyflags]$ exit exit Script done on Tue 04 Oct 2016 09:11:24 AM PDT