1
subroutine m4_func_NGA_DOT_PATCH(m4_test_type, m4_ndim)
9
parameter (m = (m4_n**m4_ndim)/100)
10
parameter (ndim = m4_ndim)
11
m4_data_type a(substr(m4_array, 1, eval(m4_ndim*2-1)))
12
m4_data_type b(substr(m4_array, 1, eval(m4_ndim*2-1)))
13
m4_data_type c(substr(m4_array, 1, eval(m4_ndim*2-1)))
18
integer elems, count_elems
20
integer lop(ndim), hip(ndim), hipl(ndim)
21
integer alo(ndim), ahi(ndim)
22
integer blo(ndim), bhi(ndim)
23
integer tlo(ndim), thi(ndim)
24
m4_data_type alpha, beta
25
m4_data_type m4_util_dot_patch(m4_test_type)
26
c for different array dimensions
28
m4_data_type d(substr(m4_array, 1, eval((m4_ndim-1)*2-1)))
30
parameter (dndim = m4_ndim-1)
31
integer ddims(dndim),dlo(dndim),dhi(dndim),dtotal
41
c---------------------- initialize the GA -----------------------
42
c initialize the chunk, dims, ld, and calculate the number
48
total = total * dims(i)
51
c*** Create global arrays
52
if (.not. nga_create(m4_MT, ndim, dims, 'a', chunk, g_a))
53
$ call ga_error(' ga_create failed ',1)
55
c test the same distribution and different distribution seperately
58
status = ga_duplicate(g_a, g_b, 'a_duplicated')
59
if(.not.ga_compare_distr(g_a, g_b))
60
$ call ga_error("g_b distribution different",0)
64
if(mod(i,2).eq.0) chunk(i) = n
66
if (.not. nga_create(m4_MT, ndim, dims, 'b', chunk, g_b))
67
$ call ga_error(' ga_create failed ',1)
72
c---------------------------NGA_DOT_PATCH -------------------------
75
m4_print_info(m4_nga_dot_patch(m4_dot))
76
if(me.eq.0) print *, 'Testing with the same distributions'
78
if(me.eq.0) print *, 'Testing with different distributions'
82
call m4_util_init_array(m4_test_type)(a,total)
83
call nga_distribution(g_a, me, lop, hip)
84
elems = count_elems(lop, hip, ndim)
85
if(elems.gt.0) call nga_put(g_a,lop,hip,
86
$ a(substr(m4_lop_all, 1, eval(m4_ndim*7-1))),dims)
87
call m4_util_init_array(m4_test_type)(b,total)
88
call nga_distribution(g_b, me, lop, hip)
89
elems = count_elems(lop, hip, ndim)
90
if(elems.gt.0) call nga_put(g_b,lop,hip,
91
$ b(substr(m4_lop_all, 1, eval(m4_ndim*7-1))),dims)
102
call random_range(lop,hipl,alo,ahi,ndim)
108
call dot_range(loop,alo,ahi,ndim,blo,bhi,ndim)
109
c$$$ print *, loop,'dot: [',(alo(i),':',ahi(i), i=1,ndim),']',
110
c$$$ $ ',', '[',(blo(i),':',bhi(i), i=1,ndim),']'
113
alpha=m4_nga_dot_patch(m4_dot)(g_a,'n',alo,ahi,g_b,'n',blo,bhi)
115
c the result should be
116
beta = m4_util_dot_patch(m4_test_type)(total,
117
$ a,alo,ahi,ndim,dims,b,blo,bhi,ndim,dims)
119
if(ABS(beta-alpha).gt.1d-6*ABS(alpha)) then
120
print *,me, ' error ', beta, alpha
121
call ga_error('exiting ...',0)
128
print *, ' without transpose OK'
133
c prepare array a, make it transposed
134
call m4_util_transpose(m4_test_type)(b,c,total,ndim,dims)
137
call random_range(lop,hipl,alo,ahi,ndim)
143
call dot_range(loop,alo,ahi,ndim,blo,bhi,ndim)
144
c$$$ print *, loop,'dot: [',(alo(i),':',ahi(i), i=1,ndim),']',
145
c$$$ $ ',', '[',(blo(i),':',bhi(i), i=1,ndim),']'
148
alpha=m4_nga_dot_patch(m4_dot)(g_a,'n',alo,ahi,g_b,'t',blo,bhi)
150
c adjust index of array a
152
tlo(i) = blo(ndim-i+1)
153
thi(i) = bhi(ndim-i+1)
156
c the result should be
157
beta = m4_util_dot_patch(m4_test_type)(total,
158
$ a,alo,ahi,ndim,dims,b,tlo,thi,ndim,dims)
160
if(ABS(beta-alpha).gt.1d-6*ABS(alpha)) then
161
print *,me, ' error ', beta, alpha
162
call ga_error('exiting ...',0)
169
print *, ' with transpose OK'
173
c---------------------------
175
status = ga_destroy(g_b)
178
c-----------------------------------------------------------------
180
ifelse(m4_ndim,1,{},{
181
c testing copy on differet dimensions
185
dtotal = dtotal * ddims(i)
188
if (.not. nga_create(m4_MT, dndim, ddims, 'd', chunk, g_b))
189
$ call ga_error(' ga_create failed ',1)
192
$ print *, 'Testing dot patch on different dimensions'
195
call m4_util_init_array(m4_test_type)(a,total)
196
call nga_distribution(g_a, me, lop, hip)
197
elems = count_elems(lop, hip, ndim)
198
if(elems.gt.0) call nga_put(g_a,lop,hip,
199
$ a(substr(m4_lop_all, 1, eval(m4_ndim*7-1))),dims)
200
call m4_util_init_array(m4_test_type)(d,dtotal)
201
call nga_distribution(g_b, me, dlo, dhi)
202
elems = count_elems(dlo, dhi, dndim)
203
if(elems.gt.0) call nga_put(g_b,dlo,dhi,
204
$ d(substr(m4_dlo_all, 1, eval((m4_ndim-1)*7-1))),ddims)
208
c calculate the maximum range of g_a that can fit into g_b
216
call random_range(lop,hip,alo,ahi,ndim)
219
dlo(i) = alo(dndim-i+1)
220
dhi(i) = ahi(dndim-i+1)
226
call dot_range(loop,alo,ahi,ndim,dlo,dhi,dndim)
227
c$$$ print *,loop,'dot: [',(alo(i),':',ahi(i), i=1,ndim),']',
228
c$$$ $ ',', '[',(dlo(i),':',dhi(i), i=1,dndim),']'
231
alpha=m4_nga_dot_patch(m4_dot)(g_a,'n',alo,ahi,
234
c the result should be
235
beta = m4_util_dot_patch(m4_test_type)(total,
236
$ a,alo,ahi,ndim,dims,d,dlo,dhi,dndim,ddims)
238
if(ABS(beta-alpha).gt.1d-6*ABS(alpha)) then
239
print *,me, ' error ', beta, alpha
240
call ga_error('exiting ...',0)
247
print *, ' dot patch on different dimensions: OK'
252
status = ga_destroy(g_b)
256
status = ga_destroy(g_a)