4
c vector boxes lack arithmetic precision
14
#define MISMATCH(x,y) abs(x-y)/max(1d0,abs(x)).gt.THRESH
15
#define MISMATCHF(x,y) abs(x-y)/max(1.0,abs(x)).gt.THRESHF
17
#define USE_SCALAPACK 0
22
#include "mafdecls.fh"
24
#include "testutil.fh"
25
integer heap, stack, fudge, ma_heap, me
28
parameter (nmax = 8, DIM = 2)
30
parameter (nmax = 2375, DIM = 2)
32
integer ndim, nprocs, type, length
33
integer g_a, g_b, g_c, g_d, g_e, g_f, g_h, g_i, g_j, inode
34
MA_ACCESS_INDEX_TYPE index
35
integer i, j, k, nb, dims(7)
36
integer lo(7), hi(7), tlo(7), thi(7), t2lo(7), t2hi(7)
37
integer block_list(10000), block_map(10000), nblock
38
integer chunk(7), ld(7), block(7), proc_grid(7)
39
integer a(nmax, nmax),b(nmax,nmax),e(nmax,nmax),f(nmax,nmax)
40
integer skip(7), i_one, ialpha, ibeta, check_int
41
double precision c(nmax,nmax),d(nmax,nmax), one, ddot
42
double precision alpha, beta
44
parameter (heap=400*400*4, fudge=100, stack=400*400*4)
46
c*** Intitialize a message passing library
55
ma_heap = heap + fudge
60
100 format(' GA initialized')
63
c*** Initialize the MA package
64
c MA must be initialized before any global array is allocated
66
status = ma_init(MT_DBL, stack, ma_heap)
67
if (.not. status) call ga_error('ma_init failed',-1)
70
write(6,101) ga_nnodes()
72
101 format(' Using ',i3,' process(es)')
91
proc_grid(2) = ga_nnodes()/2
93
g_a = ga_create_handle()
94
call ga_set_data(g_a, ndim, dims, MT_F_INT)
95
call ga_set_chunk(g_a, chunk)
97
call ga_set_block_cyclic_proc_grid(g_a, block, proc_grid)
99
call ga_set_block_cyclic(g_a, block)
101
status = ga_allocate(g_a)
104
g_b = ga_create_handle()
105
call ga_set_data(g_b, ndim, dims, MT_F_DBL)
106
call ga_set_chunk(g_b, chunk)
108
call ga_set_block_cyclic_proc_grid(g_b, block, proc_grid)
110
call ga_set_block_cyclic(g_b, block)
112
status = ga_allocate(g_b)
115
g_c = ga_create_handle()
116
call ga_set_data(g_c, ndim, dims, MT_F_INT)
117
call ga_set_chunk(g_c, chunk)
118
status = ga_allocate(g_c)
121
g_d = ga_create_handle()
122
call ga_set_data(g_d, ndim, dims, MT_F_INT)
123
call ga_set_chunk(g_d, chunk)
125
call ga_set_block_cyclic_proc_grid(g_d, block, proc_grid)
127
call ga_set_block_cyclic(g_d, block)
129
status = ga_allocate(g_d)
132
g_e = ga_create_handle()
133
call ga_set_data(g_e, ndim, dims, MT_F_DBL)
134
call ga_set_chunk(g_e, chunk)
136
call ga_set_block_cyclic_proc_grid(g_e, block, proc_grid)
138
call ga_set_block_cyclic(g_e, block)
140
status = ga_allocate(g_e)
143
g_f = ga_create_handle()
144
call ga_set_data(g_f, ndim, dims, MT_F_DBL)
145
call ga_set_chunk(g_f, chunk)
147
call ga_set_block_cyclic_proc_grid(g_f, block, proc_grid)
149
call ga_set_block_cyclic(g_f, block)
151
status = ga_allocate(g_f)
154
g_h = ga_create_handle()
155
call ga_set_data(g_h, ndim, dims, MT_F_DBL)
156
call ga_set_chunk(g_h, chunk)
157
status = ga_allocate(g_h)
160
g_i = ga_create_handle()
161
call ga_set_data(g_i, ndim, dims, MT_F_DBL)
162
call ga_set_chunk(g_i, chunk)
163
status = ga_allocate(g_i)
166
g_j = ga_create_handle()
167
call ga_set_data(g_j, ndim, dims, MT_F_DBL)
168
call ga_set_chunk(g_j, chunk)
169
status = ga_allocate(g_j)
175
102 format(' Completed allocation of GAs')
178
c Initialize local arrays
219
write(6,*) 'Testing GA_Put and GA_Get...'
223
c Copy data from local array to global array
226
call nga_put(g_a,lo,hi,a,ld)
229
c Copy data from global array back to local array
232
call nga_get(g_a,lo,hi,e,ld)
237
if (a(i,j).ne.e(i,j)) then
238
write(6,103) me,a(i,j),e(i,j)
239
call ga_error('GA PUT and GET failed',me)
244
103 format('proc: ',i4,' a(i,j): ',i8,' e(i,j): ',i8)
247
write(6,*) 'GA_Put and GA_Get are OK'
255
write(6,*) 'Testing GA_Add...'
259
call nga_put(g_c,lo,hi,a,ld)
263
call ga_add(ialpha, g_a, ibeta, g_c, g_c)
264
if (ga_idot(g_c,g_c).eq.0) then
267
write(6,*) 'GA_Add operation for regular and block-cyclic',
275
write(6,*) 'GA_Add operation for regular and block-cyclic',
276
+ ' arrays is not OK'
278
call ga_error('exiting', 1)
283
c Check add between two block-cyclic arrays
286
call nga_put(g_d,lo,hi,a,ld)
288
call ga_add(ialpha, g_a, ialpha, g_d, g_d)
290
c Copy data to local buffer and then back to regular array
292
call nga_get(g_d,lo,hi,b,ld)
294
call nga_get(g_c,lo,hi,b,ld)
297
if (ga_idot(g_c,g_c).eq.0) then
300
write(6,*) 'GA_Add operation for two block-cyclic',
308
write(6,*) 'GA_Add operation for two block-cyclic arrays',
311
call ga_error('exiting', 1)
316
c Check to find which blocks correspond to local patch
321
write(6,*) 'Check nga_locate_region and nga_locate_num_blocks'
322
write(6,*) 'functions'
324
write(6,*) 'Printing original matrix'
325
do i = 1, min(nmax,8)
326
write(6,200) (a(i,j),j=1,min(nmax,8))
329
status=nga_locate_region(g_a,tlo,thi,block_map,block_list,nblock)
330
nb = nga_locate_num_blocks(g_a,tlo,thi)
335
write(6,110) i,block_list(i),block_map(4*(i-1)+1),
336
+ block_map(4*(i-1)+3),block_map(4*(i-1)+2),
337
+ block_map(4*(i-1)+4)
340
110 format(i3,' block(',i3,') tlo(1): ',i3,' thi(1): ',i3,
341
+ ' tlo(2): ',i3,' thi(2): ',i3)
342
111 format(' Number of blocks: ',i3)
344
call nga_access_block_segment(g_a,me,index,length)
345
call print_block(int_mb(index),length)
349
c Check onesided accumulate
353
write(6,*) 'Testing GA_Acc...'
357
call nga_acc(g_b,lo,hi,c,ld,one)
361
call nga_acc(g_b,lo,hi,c,ld,one)
365
call nga_put(g_h,lo,hi,c,ld)
369
call ga_add(alpha,g_b,beta,g_h,g_h)
370
if (ga_ddot(g_h,g_h).eq.0.0d00) then
373
write(6,*) 'GA_Acc is OK'
379
write(6,*) 'GA_Acc is not OK'
381
call ga_error('exiting', 1)
390
write(6,*) 'Testing GA_Copy...'
393
call ga_copy(g_a, g_c)
394
call ga_copy(g_c, g_d)
395
call ga_add(ialpha,g_a,ibeta,g_d,g_c)
396
if (ga_idot(g_c,g_c).eq.0) then
399
write(6,*) 'GA_Copy is OK'
405
write(6,*) 'GA_Copy is not OK'
407
call ga_error('exiting', 1)
415
write(6,*) 'Testing GA_Zero...'
417
call nga_get(g_a,lo,hi,a,ld)
421
call ga_copy(g_a,g_c)
422
if (ga_idot(g_c,g_c).eq.0) then
425
write(6,*) 'GA_Zero is OK'
431
write(6,*) 'GA_Zero is not OK'
433
call ga_error('exiting', 1)
441
write(6,*) 'Testing GA_Scale...'
445
call nga_put(g_b,lo,hi,c,ld)
446
call nga_put(g_h,lo,hi,c,ld)
448
call ga_scale(g_b,2.0d00)
449
call ga_scale(g_h,2.0d00)
452
call ga_add(alpha,g_b,beta,g_h,g_h)
453
if (ga_ddot(g_h,g_h).eq.0.0d00) then
456
write(6,*) 'GA_Scale is OK'
462
write(6,*) 'GA_Scale is not OK'
464
call ga_error('exiting', 1)
472
write(6,*) 'Testing GA_Fill...'
477
call ga_add(ialpha,g_a,ibeta,g_c,g_c)
478
if (ga_idot(g_c,g_c).eq.0) then
481
write(6,*) 'GA_Fill is OK'
487
write(6,*) 'GA_Fill is not OK'
489
call ga_error('exiting', 1)
497
write(6,*) 'Testing GA_Zero_patch...'
500
call ga_copy(g_a,g_c)
501
call nga_zero_patch(g_a,tlo,thi)
502
call nga_zero_patch(g_c,tlo,thi)
503
call ga_add(ialpha,g_a,ibeta,g_c,g_c)
504
if (ga_idot(g_c,g_c).eq.0) then
507
write(6,*) 'GA_Zero_patch is OK'
513
write(6,*) 'GA_Zero_patch is not OK'
515
call ga_error('exiting', 1)
523
write(6,*) 'Testing GA_Fill_patch...'
526
call ga_copy(g_a,g_c)
527
call nga_fill_patch(g_a,tlo,thi,2)
528
call nga_fill_patch(g_c,tlo,thi,2)
529
call ga_add(ialpha,g_a,ibeta,g_c,g_c)
530
if (ga_idot(g_c,g_c).eq.0) then
533
write(6,*) 'GA_Fill_patch is OK'
539
write(6,*) 'GA_Fill_patch is not OK'
541
call ga_error('exiting', 1)
549
write(6,*) 'Testing GA_Scale_patch...'
552
call ga_copy(g_a,g_c)
553
call nga_scale_patch(g_a,tlo,thi,2)
554
call nga_scale_patch(g_c,tlo,thi,2)
555
call ga_add(ialpha,g_a,ibeta,g_c,g_c)
556
if (ga_idot(g_c,g_c).eq.0) then
559
write(6,*) 'GA_Scale_patch is OK'
565
write(6,*) 'GA_Scale_patch is not OK'
567
call ga_error('exiting', 1)
575
write(6,*) 'Testing GA_Copy_patch...'
580
call nga_fill_patch(g_a,tlo,thi,2)
581
call nga_copy_patch('n',g_a,tlo,thi,g_c,t2lo,t2hi)
583
call nga_fill_patch(g_a,t2lo,t2hi,2)
584
call ga_add(ialpha,g_a,ibeta,g_c,g_c)
585
if (ga_idot(g_c,g_c).eq.0) then
588
write(6,*) 'GA_Copy_patch from block-cyclic to regular is OK'
594
write(6,*) 'GA_Copy_patch from block-cyclic to regular is',
597
call ga_error('exiting', 1)
602
call nga_fill_patch(g_c,tlo,thi,2)
603
call nga_copy_patch('n',g_c,tlo,thi,g_a,t2lo,t2hi)
605
call nga_fill_patch(g_c,t2lo,t2hi,2)
606
call ga_add(ialpha,g_a,ibeta,g_c,g_c)
607
if (ga_idot(g_c,g_c).eq.0) then
610
write(6,*) 'GA_Copy_patch from regular to block-cyclic is OK'
616
write(6,*) 'GA_Copy_patch from regular to block-cyclic is',
619
call ga_error('exiting', 1)
627
write(6,*) 'Testing GA_Add_patch...'
637
call nga_put(g_e,t2lo,t2hi,c,ld)
638
call nga_put(g_f,t2lo,t2hi,c,ld)
639
call nga_put(g_i,t2lo,t2hi,c,ld)
640
call nga_put(g_j,t2lo,t2hi,c,ld)
643
call nga_add_patch(one,g_e,t2lo,t2hi,one,g_f,tlo,thi,g_b,tlo,thi)
644
call nga_add_patch(one,g_i,t2lo,t2hi,one,g_j,tlo,thi,g_h,tlo,thi)
645
call ga_add(alpha,g_b,beta,g_h,g_i)
646
if (ga_ddot(g_i,g_i).eq.0.0d00) then
649
write(6,*) 'GA_Add_patch is OK'
655
write(6,*) 'GA_Add_patch is not OK'
657
call ga_error('exiting', 1)
665
write(6,*) 'Testing GA_Ddot...'
668
call ga_fill(g_b, 2.0d00)
669
call ga_fill(g_b, 2.0d00)
670
ddot = ga_ddot(g_b, g_b)
672
write(6,112) ddot,dble(nmax*nmax*4)
674
112 format(' Value of DDOT: ',f12.2,' Expected value: ',f12.2)
675
if (me.eq.0) write(6,*)
681
write(6,*) 'Testing GA_Ddot_patch...'
684
ddot = nga_ddot_patch(g_b, 'n', tlo, thi, g_b, 'n', tlo, thi)
686
write(6,113) ddot,dble((thi(1)-tlo(1)+1)*(thi(2)-tlo(2)+1)*4)
688
113 format(' Value of DDOT_PATCH: ',f12.2,' Expected value: ',f12.2)
690
c test ga_abs_value_patch
694
write(6,*) 'Testing GA_Abs_patch...'
698
call ga_abs_value_patch(g_a, tlo, thi)
700
call ga_abs_value_patch(g_c, tlo, thi)
701
call ga_add(ialpha,g_a,ibeta,g_c,g_c)
702
if (ga_idot(g_c,g_c).eq.0) then
705
write(6,*) 'GA_Abs_value_patch is OK'
711
write(6,*) 'GA_Abs_value_patch is not OK'
713
call ga_error('exiting', 1)
717
c test ga_elem_multiply
721
write(6,*) 'Testing GA_Elem_multiply...'
724
call ga_fill(g_b, 2.0d00)
725
call ga_fill(g_e, 3.0d00)
727
call ga_elem_multiply(g_b, g_e, g_f)
728
call ga_fill(g_h, 2.0d00)
729
call ga_fill(g_i, 3.0d00)
731
call ga_elem_multiply(g_h, g_i, g_j)
732
call ga_add(alpha,g_f,beta,g_j,g_h)
733
if (ga_ddot(g_h,g_h).eq.0.0d00) then
736
write(6,*) 'GA_Elem_multiply is OK'
742
write(6,*) 'GA_Elem_multiply is not OK'
744
call ga_error('exiting', 1)
748
c test ga_elem_divide_patch
752
write(6,*) 'Testing GA_Elem_divide_patch...'
755
call ga_fill(g_b, 3.0d00)
756
call ga_elem_divide_patch(g_f,t2lo,t2hi,g_e,tlo,thi,g_b,tlo,thi)
757
call ga_fill(g_h, 3.0d00)
758
call ga_elem_divide_patch(g_j,t2lo,t2hi,g_i,tlo,thi,g_h,tlo,thi)
759
call ga_add(alpha,g_b,beta,g_h,g_h)
760
if (ga_ddot(g_h,g_h).eq.0.0d00) then
763
write(6,*) 'GA_Elem_divide_patch is OK'
769
write(6,*) 'GA_Elem_divide_patch is not OK'
771
call ga_error('exiting', 1)
779
write(6,*) 'Testing GA_Strided_get...'
786
call nga_get(g_a,lo,hi,a,ld)
787
call nga_get(g_c,lo,hi,b,ld)
791
call nga_strided_get(g_a,lo,hi,skip,a,ld)
792
call nga_strided_get(g_c,lo,hi,skip,b,ld)
799
if (a(i,j).ne.b(i,j)) nb = nb + 1
805
write(6,*) 'GA_Strided_get is OK'
811
write(6,*) 'GA_Strided_get is not OK'
813
call ga_error('exiting', 1)
822
write(6,*) 'Testing GA_Strided_put...'
826
if (me.eq.0) call nga_get(g_a,lo,hi,a,ld)
829
if (me.eq.0) call nga_get(g_c,lo,hi,b,ld)
832
call nga_strided_put(g_a,lo,hi,skip,a,ld)
833
call nga_strided_put(g_c,lo,hi,skip,b,ld)
836
call ga_add(ialpha,g_a,ibeta,g_c,g_c)
837
if (ga_idot(g_c,g_c).eq.0) then
840
write(6,*) 'GA_Strided_put is OK'
846
write(6,*) 'GA_Strided_put is not OK'
848
call ga_error('exiting', 1)
852
c test strided accumulate
856
write(6,*) 'Testing GA_Strided_acc...'
859
call ga_fill(g_b, 1.0d00)
860
call nga_get(g_b,lo,hi,c,ld)
861
call ga_fill(g_h, 1.0d00)
862
call nga_get(g_h,lo,hi,d,ld)
865
call nga_strided_acc(g_b,lo,hi,skip,c,ld,one)
866
call nga_strided_acc(g_h,lo,hi,skip,d,ld,one)
869
call ga_add(alpha,g_b,beta,g_h,g_h)
870
if (ga_ddot(g_h,g_h).eq.0.0d00) then
873
write(6,*) 'GA_Strided_acc is OK'
879
write(6,*) 'GA_Strided_acc is not OK'
881
call ga_error('exiting', 1)
889
write(6,*) 'Testing GA_transpose...'
900
call nga_put(g_b,lo,hi,c,ld)
901
call nga_put(g_h,lo,hi,c,ld)
904
call ga_transpose(g_b,g_i)
905
call ga_transpose(g_h,g_j)
906
call ga_add(alpha,g_i,beta,g_j,g_h)
907
if (ga_ddot(g_h,g_h).eq.0.0d00) then
910
write(6,*) 'GA_Transpose is OK'
916
write(6,*) 'GA_Transpose is not OK'
918
call ga_error('exiting', 1)
926
write(6,*) 'Testing GA_symmetrize...'
930
call nga_put(g_b,lo,hi,c,ld)
931
call nga_put(g_h,lo,hi,c,ld)
934
call ga_symmetrize(g_b)
935
call ga_symmetrize(g_h)
936
call ga_add(alpha,g_b,beta,g_h,g_h)
937
if (ga_ddot(g_h,g_h).eq.0.0d00) then
940
write(6,*) 'GA_Symmetrize is OK'
946
write(6,*) 'GA_Symmetrize is not OK'
948
call ga_error('exiting', 1)
956
write(6,*) 'Testing GA_Periodic_get...'
971
call nga_put(g_a,lo,hi,a,ld)
972
call nga_put(g_c,lo,hi,a,ld)
976
call nga_periodic_get(g_a,tlo,thi,a,ld)
977
call nga_periodic_get(g_c,tlo,thi,b,ld)
984
if (a(i,j).ne.b(i,j)) nb = nb + 1
990
write(6,*) 'GA_Periodic_get is OK'
996
write(6,*) 'GA_Periodic_get is not OK'
998
call ga_error('exiting', 1)
1007
write(6,*) 'Testing GA_Periodic_put...'
1018
call nga_periodic_put(g_a,tlo,thi,a,ld)
1019
call nga_periodic_put(g_c,tlo,thi,a,ld)
1022
call ga_add(ialpha,g_a,ibeta,g_c,g_c)
1023
if (ga_idot(g_c,g_c).eq.0) then
1026
write(6,*) 'GA_Periodic_put is OK'
1032
write(6,*) 'GA_Periodic_put is not OK'
1034
call ga_error('exiting', 1)
1038
c test periodic accumulate
1042
write(6,*) 'Testing GA_Periodic_acc...'
1045
call ga_fill(g_b, 1.0d00)
1046
call ga_fill(g_h, 1.0d00)
1049
call nga_periodic_acc(g_b,tlo,thi,c,ld,one)
1050
call nga_periodic_acc(g_h,tlo,thi,c,ld,one)
1053
call ga_add(alpha,g_b,beta,g_h,g_h)
1054
if (ga_ddot(g_h,g_h).eq.0.0d00) then
1057
write(6,*) 'GA_Periodic_acc is OK'
1063
write(6,*) 'GA_Periodic_acc is not OK'
1065
call ga_error('exiting', 1)
1074
302 format(' Finished tests: success')
1075
status = ga_destroy(g_a)
1076
status = ga_destroy(g_b)
1077
status = ga_destroy(g_c)
1078
status = ga_destroy(g_d)
1079
status = ga_destroy(g_e)
1080
status = ga_destroy(g_f)
1083
c*** Tidy up after message-passing library
1090
subroutine print_block(a,length)
1092
#include "mafdecls.fh"
1093
#include "global.fh"
1094
integer length, i, j
1099
write(6,100) (a(4*(j-1)+i), j=1,4)
1102
200 format(' Write contents of processor')