-
Notifications
You must be signed in to change notification settings - Fork 2
/
test1.R
69 lines (53 loc) · 1.5 KB
/
test1.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
suppressMessages(library(pbdMPI,quietly = TRUE))
suppressMessages(library(pbdDMAT,quietly = TRUE))
suppressMessages(library(pmclust,quietly = TRUE))
library(data.table)
init()
barrier()
start.time <- Sys.time()
comm.print(start.time)
data_dim <- 200
dyn_count_csv = read.csv("dynamic_count_of_files", header=FALSE)
sum = 0
id = 1
c_sum_list = list(dyn_count_csv[1, 1])
for ( i in 1:ncol(dyn_count_csv) ){
sum = sum + dyn_count_csv[1, i]
c_sum_list[[id]] = sum
id = id + 1
}
interested_id = 0
for ( i in 1:length(c_sum_list) ){
if ( comm.rank() <= c_sum_list[i] ) {
dir_part = i -1
interested_id = i
break
}
}
init.grid()
#dir_part = as.integer(comm.rank()/47)
if ( ( comm.rank()%%dyn_count_csv[1, interested_id] ) == 0 ) {
file_part = 0
} else {
file_part = comm.rank()%%dyn_count_csv[1, interested_id]
}
if (file_part < 10){
fn <- paste0('gunzip -c model1.',dir_part,'/vector_model1.',dir_part,'.part00',file_part,'.gz')
}else if (file_part >=10 & file_part< 100){
fn <- paste0('gunzip -c model1.',dir_part,'/vector_model1.',dir_part,'.part0',file_part,'.gz')
}
x <- fread(fn, header = F, sep = ';',colClasses=c("character",rep("numeric",data_dim)))
barrier()
nn = x[-1]
#DROP THE FIRST COLUMN OF TAGS
dx <- as.ddmatrix(x[,-1])
sm <- sum(dx)
end.time <- Sys.time()
time <- end.time - start.time
comm.print(time)
comm.print(sm)
nr = allreduce(nrow(x))
nc = allreduce(ncol(x))
comm.print(paste("the overall matrix row is:", nr));
comm.print(paste("the overall matrix col is:", nc));
finalize()