-
Notifications
You must be signed in to change notification settings - Fork 183
/
libxsmm.f
1949 lines (1814 loc) · 94.1 KB
/
libxsmm.f
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!=======================================================================!
! Copyright (c) Intel Corporation - All rights reserved. !
! This file is part of the LIBXSMM library. !
! !
! For information on the license, see the LICENSE file. !
! Further information: https://github.com/libxsmm/libxsmm/ !
! SPDX-License-Identifier: BSD-3-Clause !
!=======================================================================!
! Hans Pabst (Intel Corp.)
!=======================================================================!
MODULE LIBXSMM
USE, INTRINSIC :: ISO_C_BINDING, ONLY: &
& C_DOUBLE, C_FLOAT, C_DOUBLE_COMPLEX, C_FLOAT_COMPLEX, &
& C_LONG_LONG, C_INT, C_SHORT, C_CHAR, C_INT8_T, C_BOOL, &
& C_F_POINTER, C_ASSOCIATED, C_LOC, C_PTR, &
& C_FUNPTR, C_NULL_FUNPTR, C_NULL_PTR
IMPLICIT NONE
!> Name of the version (stringized set of version numbers).
CHARACTER(*), PARAMETER :: LIBXSMM_VERSION = "$VERSION"
!> Name of the branch of which the version is derived from.
CHARACTER(*), PARAMETER :: LIBXSMM_BRANCH = "$BRANCH"
!> Major version based on the last reachable tag under RCS.
INTEGER(C_INT), PARAMETER :: LIBXSMM_VERSION_MAJOR = $MAJOR
!> Minor version based on the last reachable tag of the RCS.
INTEGER(C_INT), PARAMETER :: LIBXSMM_VERSION_MINOR = $MINOR
!> Update number based on the last reachable tag under RCS.
INTEGER(C_INT), PARAMETER :: LIBXSMM_VERSION_UPDATE = $UPDATE
!> Patch number counting commits since the last version stamp.
INTEGER(C_INT), PARAMETER :: LIBXSMM_VERSION_PATCH = $PATCH
!> Parameters the library and static kernels were built for.
INTEGER(C_INT), PARAMETER :: LIBXSMM_CACHELINE = $CACHELINE
INTEGER(C_INT), PARAMETER :: LIBXSMM_ALIGNMENT = $CACHELINE
INTEGER(C_INT), PARAMETER :: LIBXSMM_PREFETCH = $PREFETCH
INTEGER(C_INT), PARAMETER :: LIBXSMM_MAX_MNK = $MAX_MNK
INTEGER(C_INT), PARAMETER :: LIBXSMM_MAX_DIM = $MAX_DIM
INTEGER(C_INT), PARAMETER :: LIBXSMM_FLAGS = $FLAGS
INTEGER(C_INT), PARAMETER :: LIBXSMM_ILP64 = $ILP64
!> Parameters supplied for backward compatibility (deprecated).
INTEGER(C_INT), PARAMETER :: LIBXSMM_COL_MAJOR = 1
INTEGER(C_INT), PARAMETER :: LIBXSMM_ROW_MAJOR = 0
!> LIBXSMM_BLASINT_KIND (LP64: 32-bit, ILP64: 64-bit).
INTEGER(C_INT), PARAMETER :: LIBXSMM_BLASINT_KIND = $BLASINT_KIND
!> Integer kind used by timer interface.
INTEGER(C_INT), PARAMETER :: LIBXSMM_TICKINT_KIND = C_LONG_LONG
!> Parameters for simplified GEMM interface.
REAL(C_DOUBLE), PARAMETER :: LIBXSMM_ALPHA = REAL($ALPHA, C_DOUBLE)
REAL(C_DOUBLE), PARAMETER :: LIBXSMM_BETA = REAL($BETA, C_DOUBLE)
!> Flag enumeration which can be IORed.
INTEGER(C_INT), PARAMETER :: &
& LIBXSMM_GEMM_FLAG_NONE = 0, &
& LIBXSMM_GEMM_FLAG_TRANS_A = 1, &
& LIBXSMM_GEMM_FLAG_TRANS_B = 2, &
& LIBXSMM_GEMM_FLAG_TRANS_AB = IOR( &
& LIBXSMM_GEMM_FLAG_TRANS_A, LIBXSMM_GEMM_FLAG_TRANS_B), &
& LIBXSMM_GEMM_FLAG_BETA_0 = 4, &
& LIBXSMM_GEMM_FLAG_ALIGN_A = 8, &
& LIBXSMM_GEMM_FLAG_ALIGN_C =16, &
& LIBXSMM_GEMM_FLAG_ALIGN_C_NTS_HINT = IOR(1024, &
& LIBXSMM_GEMM_FLAG_ALIGN_C), &
& LIBXSMM_GEMM_FLAG_ALIGN_C_NTS_HINT_BETA_0 = IOR( &
& LIBXSMM_GEMM_FLAG_ALIGN_C_NTS_HINT, &
& LIBXSMM_GEMM_FLAG_BETA_0), &
& LIBXSMM_GEMM_FLAG_INVALID = 131072
!> Enumerates element/data types.
INTEGER(C_INT), PARAMETER :: &
& LIBXSMM_DATATYPE_F64 = 0, &
& LIBXSMM_DATATYPE_F32 = 1, &
& LIBXSMM_DATATYPE_BF16 = 2, &
& LIBXSMM_DATATYPE_F16 = 3, &
& LIBXSMM_DATATYPE_BF8 = 4, &
& LIBXSMM_DATATYPE_HF8 = 5, &
& LIBXSMM_DATATYPE_I64 = 6, &
& LIBXSMM_DATATYPE_I32 = 7, &
& LIBXSMM_DATATYPE_I16 = 8, &
& LIBXSMM_DATATYPE_I8 = 9, &
& LIBXSMM_DATATYPE_UNSIGNED = 10, &
& LIBXSMM_DATATYPE_UNSUPPORTED = 11
!> Enumeration of prefetch strategies which can be IORed.
INTEGER(C_INT), PARAMETER :: &
! Automatically select strategy (frontend).
& LIBXSMM_PREFETCH_AUTO = -1, &
! No prefetching and no prefetch function signature.
& LIBXSMM_PREFETCH_NONE = 0, &
! Prefetch PA using accesses to A.
& LIBXSMM_GEMM_PREFETCH_AL2 = 1, &
! Prefetch PB using accesses to C.
& LIBXSMM_GEMM_PREFETCH_BL2_VIA_C = 2, &
! Prefetch A ahead.
& LIBXSMM_GEMM_PREFETCH_AL2_AHEAD = 4, &
! Composed prefetch strategies.
& LIBXSMM_GEMM_PREFETCH_AL2BL2_VIA_C = IOR( &
& LIBXSMM_GEMM_PREFETCH_BL2_VIA_C, &
& LIBXSMM_GEMM_PREFETCH_AL2), &
& LIBXSMM_GEMM_PREFETCH_AL2BL2_VIA_C_AHEAD = IOR( &
& LIBXSMM_GEMM_PREFETCH_BL2_VIA_C, &
& LIBXSMM_GEMM_PREFETCH_AL2_AHEAD), &
! Current B into L1.
& LIBXSMM_GEMM_PREFETCH_BL1 = 8, &
& LIBXSMM_GEMM_PREFETCH_C = 64
!> Enumerates the available target architectures and instruction
!> set extensions as returned by libxsmm_get_target_archid().
INTEGER(C_INT), PARAMETER :: &
& LIBXSMM_TARGET_ARCH_UNKNOWN = 0, &
& LIBXSMM_TARGET_ARCH_GENERIC = 1, &
& LIBXSMM_X86_GENERIC = 1002, &
& LIBXSMM_X86_SSE3 = 1003, &
& LIBXSMM_X86_SSE4 = 1004, &
& LIBXSMM_X86_AVX = 1005, &
& LIBXSMM_X86_AVX2 = 1006, &
& LIBXSMM_X86_AVX2_ADL = 1007, &
& LIBXSMM_X86_AVX2_SRF = 1008, &
& LIBXSMM_X86_AVX512_VL128_SKX = 1041, &
& LIBXSMM_X86_AVX512_VL256_SKX = 1051, &
& LIBXSMM_X86_AVX512_VL256_CLX = 1052, &
& LIBXSMM_X86_AVX512_VL256_CPX = 1053, &
& LIBXSMM_X86_AVX512_SKX = 1101, &
& LIBXSMM_X86_AVX512_CLX = 1102, &
& LIBXSMM_X86_AVX512_CPX = 1103, &
& LIBXSMM_X86_AVX512_SPR = 1104, &
& LIBXSMM_X86_AVX512_GNR = 1105, &
& LIBXSMM_X86_AVX512_DMR = 1106, &
& LIBXSMM_X86_ALLFEAT = 1999, &
& LIBXSMM_AARCH64_V81 = 2001, &
& LIBXSMM_AARCH64_V82 = 2002, &
& LIBXSMM_AARCH64_APPL_M1 = 2101, &
& LIBXSMM_AARCH64_SVE128 = 2201, &
& LIBXSMM_AARCH64_SVE256 = 2301, &
& LIBXSMM_AARCH64_NEOV1 = 2302, &
& LIBXSMM_AARCH64_SVX512 = 2401, &
& LIBXSMM_AARCH64_A64FX = 2402, &
& LIBXSMM_AARCH64_ALLFEAT = 2999
!> Generic function type (double-precision).
TYPE, BIND(C) :: LIBXSMM_DMMFUNCTION
TYPE(C_FUNPTR) :: handle = C_NULL_FUNPTR
END TYPE
!> Generic function type (single-precision).
TYPE, BIND(C) :: LIBXSMM_SMMFUNCTION
TYPE(C_FUNPTR) :: handle = C_NULL_FUNPTR
END TYPE
!> Generic function type (low-precision)
TYPE, BIND(C) :: LIBXSMM_WIMMFUNCTION
TYPE(C_FUNPTR) :: handle = C_NULL_FUNPTR
END TYPE
!> Generic function types with certain arity.
ABSTRACT INTERFACE
PURE SUBROUTINE LIBXSMM_FUNCTION3(a, b, c) BIND(C)
IMPORT :: C_PTR
TYPE(C_PTR), INTENT(IN), VALUE :: a, b, c
END SUBROUTINE
PURE SUBROUTINE LIBXSMM_FUNCTION6(a, b, c, pa, pb, pc) BIND(C)
IMPORT :: C_PTR
TYPE(C_PTR), INTENT(IN), VALUE :: a, b, c
TYPE(C_PTR), INTENT(IN), VALUE :: pa, pb, pc
END SUBROUTINE
END INTERFACE
!> Structure of differences with matrix norms according
!> to http://www.netlib.org/lapack/lug/node75.html).
TYPE, BIND(C) :: LIBXSMM_MATDIFF_INFO
REAL(C_DOUBLE) norm1_abs, norm1_rel !! One-norm
REAL(C_DOUBLE) normi_abs, normi_rel !! Infinity-norm
REAL(C_DOUBLE) normf_rel !! Froebenius-norm
!> Maximum difference, L2-norm (absolute and relative),
!> and R-squared.
REAL(C_DOUBLE) linf_abs, linf_rel, l2_abs, l2_rel, rsq
!> Statistics (reference): sum/l1, minimum, maximum,
!> arithmetic average, and variance.
REAL(C_DOUBLE) l1_ref, min_ref, max_ref, avg_ref, var_ref
!> Statistics (test): sum/l1, minimum, maximum,
!> arithmetic average, and variance.
REAL(C_DOUBLE) l1_tst, min_tst, max_tst, avg_tst, var_tst
!> Values(v_ref, v_tst) and location(m, n)
!> of largest linf_abs.
REAL(C_DOUBLE) v_ref, v_tst
!> If r is non-zero (i is not negative), values (v_ref,
!> v_tst), and location (m, n) stem from the i-th
!> reduction (r calls of libxsmm_matdiff_reduce)
!> of the largest difference (libxsmm_matdiff_epsilon).
INTEGER(LIBXSMM_BLASINT_KIND) m, n, i, r
END TYPE
INTERFACE
!> Initialize the library.
SUBROUTINE libxsmm_init() BIND(C)
END SUBROUTINE
!> De-initialize the library.
SUBROUTINE libxsmm_finalize() BIND(C)
END SUBROUTINE
!> Returns the architecture and instruction set extension
!> as determined by the CPUID flags, as set by the
!> libxsmm_get_target_arch* functions, or as set by
!> the LIBXSMM_TARGET environment variable.
PURE FUNCTION libxsmm_get_target_archid() BIND(C)
IMPORT :: C_INT
INTEGER(C_INT) :: libxsmm_get_target_archid
END FUNCTION
!> Set target architecture (archid: see PARAMETER
!> enumeration) for subsequent code generation (JIT).
SUBROUTINE libxsmm_set_target_archid(archid) BIND(C)
IMPORT :: C_INT
INTEGER(C_INT), INTENT(IN), VALUE :: archid
END SUBROUTINE
!> Set target architecture for subsequent code
!> generation (JIT); arch argument can be
!> "sse", "snb", "hsw", "skx",
!> "clx", "cpx", "spr", or "0" to rely on
!> the CPUID (default).
!> There are some alternative target names as well:
!> "sse", "avx", "avx2", "avx3" (incomplete list).
SUBROUTINE libxsmm_set_target_arch(arch) BIND(C)
IMPORT :: C_CHAR
CHARACTER(C_CHAR), INTENT(IN) :: arch(*)
END SUBROUTINE
!> Get the level of verbosity.
PURE FUNCTION libxsmm_get_verbosity() BIND(C)
IMPORT :: C_INT
INTEGER(C_INT) :: libxsmm_get_verbosity
END FUNCTION
!> Set the level of verbosity (0: off, positive value:
!> verbosity level, negative value: maximum verbosity,
!> which also dumps JIT-code).
SUBROUTINE libxsmm_set_verbosity(level) BIND(C)
IMPORT :: C_INT
INTEGER(C_INT), INTENT(IN), VALUE :: level
END SUBROUTINE
!> Impure function which returns the current clock tick
!> of a monotonic timer source; uses a platform-specific
!> resolution.
!> Implicit FORTRAN 77 interface: not available.
INTEGER(LIBXSMM_TICKINT_KIND) &
& FUNCTION libxsmm_timer_tick() BIND(C)
IMPORT :: LIBXSMM_TICKINT_KIND
END FUNCTION
!> Impure function (timer freq. may vary) which returns
!> the duration (in seconds) between two values received
!> by libxsmm_timer_tick.
!> Implicit FORTRAN 77 interface: not available.
FUNCTION libxsmm_timer_duration(tick0, tick1) BIND(C)
IMPORT :: LIBXSMM_TICKINT_KIND, C_DOUBLE
INTEGER(LIBXSMM_TICKINT_KIND), INTENT(IN), VALUE :: tick0
INTEGER(LIBXSMM_TICKINT_KIND), INTENT(IN), VALUE :: tick1
REAL(C_DOUBLE) :: libxsmm_timer_duration
END FUNCTION
!> Deallocates the JIT'ted code, or unregisters
!> and releases code from the registry.
!> Implicit FORTRAN 77 interface:
!> INTEGER(8) :: kernel
SUBROUTINE libxsmm_release_kernel(kernel) &
& BIND(C, NAME="libxsmm_release_kernel_")
IMPORT :: C_FUNPTR
TYPE(C_FUNPTR), INTENT(IN) :: kernel
END SUBROUTINE
!> Type-generic (unsafe) code dispatch.
!> Implicit FORTRAN 77 interface:
!> INTEGER(4) :: gemm_precision, flags, prefetch
!> INTEGER(4|8) :: m, n, k, lda, ldb, ldc
!> REAL(4|8) :: alpha, beta
!> INTEGER(8) :: kernel
SUBROUTINE libxsmm_xmmdispatch(kernel, gemm_precision, &
& m, n, k, lda, ldb, ldc, alpha, beta, flags, prefetch) &
& BIND(C, NAME="libxsmm_xmmdispatch_")
IMPORT :: C_FUNPTR, C_PTR, C_INT, LIBXSMM_BLASINT_KIND
TYPE(C_FUNPTR), INTENT(OUT) :: kernel
INTEGER(C_INT), INTENT(IN) :: gemm_precision
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: m, n, k
TYPE(C_PTR), INTENT(IN), VALUE :: lda, ldb, ldc
TYPE(C_PTR), INTENT(IN), VALUE :: alpha, beta
TYPE(C_PTR), INTENT(IN), VALUE :: flags, prefetch
END SUBROUTINE
!> Type-generic (unsafe) code dispatch.
!> Implicit FORTRAN 77 interface:
!> INTEGER(4) :: iprec, oprec, flags, prefetch
!> INTEGER(4|8) :: m, n, k, lda, ldb, ldc
!> REAL(4|8) :: alpha, beta
!> INTEGER(8) :: kernel
SUBROUTINE libxsmm_xmmdispatch2(kernel, iprec, oprec, &
& m, n, k, lda, ldb, ldc, alpha, beta, flags, prefetch) &
& BIND(C, NAME="libxsmm_xmmdispatch2_")
IMPORT :: C_FUNPTR, C_PTR, C_INT, LIBXSMM_BLASINT_KIND
TYPE(C_FUNPTR), INTENT(OUT) :: kernel
INTEGER(C_INT), INTENT(IN) :: iprec, oprec
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: m, n, k
TYPE(C_PTR), INTENT(IN), VALUE :: lda, ldb, ldc
TYPE(C_PTR), INTENT(IN), VALUE :: alpha, beta
TYPE(C_PTR), INTENT(IN), VALUE :: flags, prefetch
END SUBROUTINE
!> Generic call routine (3-argument form).
!> Implicit FORTRAN 77 interface:
!> REAL(4|8) :: a, b, c
!> INTEGER(8) :: kernel
PURE SUBROUTINE libxsmm_xmmcall_abc(kernel, a, b, c) &
& BIND(C, NAME="libxsmm_xmmcall_abc_")
IMPORT :: C_FUNPTR, C_PTR
TYPE(C_FUNPTR), INTENT(IN) :: kernel
TYPE(C_PTR), INTENT(IN), VALUE :: a, b, c
END SUBROUTINE
!> Generic call routine (6-argument form).
!> Implicit FORTRAN 77 interface:
!> REAL(4|8) :: a, b, c, pa, pb, pc
!> INTEGER(8) :: kernel
PURE SUBROUTINE libxsmm_xmmcall_prf(kernel, &
& a, b, c, pa, pb, pc) &
& BIND(C, NAME="libxsmm_xmmcall_prf_")
IMPORT :: C_FUNPTR, C_PTR
TYPE(C_FUNPTR), INTENT(IN) :: kernel
TYPE(C_PTR), INTENT(IN), VALUE :: a, b, c, pa, pb, pc
END SUBROUTINE
!> Fill destination with zeros; dst is a raw/binary buffer.
SUBROUTINE libxsmm_xclear(dst, nbytes) &
& BIND(C, NAME="libxsmm_xclear_")
IMPORT :: C_PTR, C_INT
TYPE(C_PTR), INTENT(IN), VALUE :: dst
INTEGER(C_INT), INTENT(IN) :: nbytes
END SUBROUTINE
!> Remove key-value from code registry and release memory.
SUBROUTINE libxsmm_xrelease(key, keysize) &
& BIND(C, NAME="libxsmm_xrelease_")
IMPORT :: C_PTR, C_INT
TYPE(C_PTR), INTENT(IN), VALUE :: key
INTEGER(C_INT), INTENT(IN) :: keysize
END SUBROUTINE
!> Matrix-copy (2-dimensional copy) routine.
!> Implicit FORTRAN 77 interface:
!> ARRAY :: input, output
!> INTEGER(4|8) :: m, n, ldi, ldo
!> INTEGER(4) :: typesize
PURE SUBROUTINE libxsmm_xmatcopy(output, input, typesize, &
& m, n, ldi, ldo) BIND(C, NAME="libxsmm_matcopy_")
IMPORT :: LIBXSMM_BLASINT_KIND, C_PTR, C_INT
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: m, n, ldi, ldo
TYPE(C_PTR), INTENT(IN), VALUE :: output, input
INTEGER(C_INT), INTENT(IN) :: typesize
END SUBROUTINE
!> Transpose a matrix (in-place form).
!> Implicit FORTRAN 77 interface:
!> ARRAY :: matrix
!> INTEGER(4|8) :: m, n, ldi, ldo
!> INTEGER(4) :: typesize
PURE SUBROUTINE libxsmm_xitrans(matrix, typesize, &
& m, n, ldi, ldo) BIND(C, NAME="libxsmm_itrans_")
IMPORT :: C_PTR, C_INT, LIBXSMM_BLASINT_KIND
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: m, n, ldi, ldo
TYPE(C_PTR), INTENT(IN), VALUE :: matrix
INTEGER(C_INT), INTENT(IN) :: typesize
END SUBROUTINE
!> Transpose a matrix (out-of-place form).
!> Implicit FORTRAN 77 interface:
!> ARRAY :: input, output
!> INTEGER(4|8) :: m, n, ldi, ldo
!> INTEGER(4) :: typesize
PURE SUBROUTINE libxsmm_xotrans(output, input, typesize, &
& m, n, ldi, ldo) BIND(C, NAME="libxsmm_otrans_")
IMPORT :: C_PTR, C_INT, LIBXSMM_BLASINT_KIND
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: m, n, ldi, ldo
TYPE(C_PTR), INTENT(IN), VALUE :: output, input
INTEGER(C_INT), INTENT(IN) :: typesize
END SUBROUTINE
!> Matrix copy; MT via libxsmmext (out-of-place form).
!> Implicit FORTRAN 77 interface:
!> ARRAY :: output, input
!> INTEGER(4|8) :: m, n, ldi, ldo
!> INTEGER(4) :: typesize
PURE SUBROUTINE libxsmm_matcopy_omp(output, input, typesize, &
& m, n, ldi, ldo) BIND(C, NAME="libxsmm_matcopy_omp_")
IMPORT :: C_PTR, C_INT, LIBXSMM_BLASINT_KIND
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: m, n, ldi, ldo
TYPE(C_PTR), INTENT(IN), VALUE :: output, input
INTEGER(C_INT), INTENT(IN) :: typesize
END SUBROUTINE
!> Matrix transpose; MT via libxsmmext (out-of-place form).
!> Implicit FORTRAN 77 interface:
!> ARRAY :: output, input
!> INTEGER(4|8) :: m, n, ldi, ldo
!> INTEGER(4) :: typesize
PURE SUBROUTINE libxsmm_otrans_omp(output, input, typesize, &
& m, n, ldi, ldo) BIND(C, NAME="libxsmm_otrans_omp_")
IMPORT :: C_PTR, C_INT, LIBXSMM_BLASINT_KIND
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: m, n, ldi, ldo
TYPE(C_PTR), INTENT(IN), VALUE :: output, input
INTEGER(C_INT), INTENT(IN) :: typesize
END SUBROUTINE
!> Process a series of SMMs (batch).
!> See also libxsmm_gemm_batch/omp.
!> The kind of matrices (a, b, c) depend on index_stride:
!> index_stride==0: stride_* are each scalar strides used
!> to walk the corresponding a, b, or c
!> with each being an array of pointers
!> to the respective matrices.
!> index_stride!=0: stride_* are each scalar strides used
!> to walk the corresponding a, b, or c
!> with each being a pointer to the
!> respective matrix-data.
!> The index_stride is not used otherwise.
!> index_stride is non-zero (smaller than libxsmm_blasint):
!> stride_* indexes determining the start
!> of the corresponding a, b, or c
!> with each being a pointer to the
!> respective matrix-data.
!> The index_stride to walk stride_*.
!> Implicit FORTRAN 77 interface:
!> INTEGER(4) :: iprec, oprec
!> CHAR :: transa, transb
!> INTEGER(4|8) :: m, n, k, lda, ldb, ldc
!> REAL(4|8) :: alpha, beta
!> ARRAY :: a, b, c
!> ARRAY/VALUE :: stride_a, stride_b, stride_c
!> INTEGER(4|8) :: index_stride, index_base, batchsize
!> INTEGER(4) :: batchcheck, tid, ntasks
PURE SUBROUTINE libxsmm_xgemm_batch_task( &
& iprec, oprec, transa, transb, m, n, k, &
& alpha, a, lda, stride_a, b, ldb, stride_b, &
& beta, c, ldc, stride_c, index_stride, index_base, &
& batchsize, batchcheck, tid, ntasks) &
& BIND(C, NAME="libxsmm_gemm_batch_task_")
IMPORT :: C_PTR, C_CHAR, C_INT, LIBXSMM_BLASINT_KIND
!> Determines index-base (1 for one-based indexes).
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: index_base
!> Stride (measured in Bytes) used to walk stride_*.
!> In Fortran (usually): index_stride!=0.
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: index_stride
!> Number of SMMs. If the size is given as a neg. value,
!> then internal synchronization is omitted.
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: batchsize
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: m, n, k
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: lda, ldb, ldc
CHARACTER(C_CHAR), INTENT(IN) :: transa, transb
TYPE(C_PTR), INTENT(IN), VALUE :: alpha, beta
TYPE(C_PTR), INTENT(IN), VALUE :: a, b, c
!> Arrays of indexes determining the position of
!> a, b, and c operands.
TYPE(C_PTR), INTENT(IN), VALUE :: stride_a
TYPE(C_PTR), INTENT(IN), VALUE :: stride_b
TYPE(C_PTR), INTENT(IN), VALUE :: stride_c
INTEGER(C_INT), INTENT(IN) :: iprec, oprec, batchcheck
!> Task-ID (TID), and number of tasks.
INTEGER(C_INT), INTENT(IN) :: tid, ntasks
END SUBROUTINE
!> Process a series of SMMs (batch).
!> See also libxsmm_xgemm_batch_task.
!> Implicit FORTRAN 77 interface:
!> INTEGER(4) :: iprec, oprec, batchcheck
!> CHAR :: transa, transb
!> INTEGER(4|8) :: m, n, k, lda, ldb, ldc
!> REAL(4|8) :: alpha, beta
!> ARRAY :: a, b, c
!> ARRAY/VALUE :: stride_a, stride_b, stride_c
!> INTEGER(4|8) :: index_stride, index_base, batchsize
PURE SUBROUTINE libxsmm_xgemm_batch( &
& iprec, oprec, transa, transb, m, n, k, &
& alpha, a, lda, stride_a, b, ldb, stride_b, &
& beta, c, ldc, stride_c, index_stride, index_base, &
& batchsize, batchcheck) &
& BIND(C, NAME="libxsmm_gemm_batch_")
IMPORT :: C_PTR, C_CHAR, C_INT, LIBXSMM_BLASINT_KIND
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: index_base
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: index_stride
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: batchsize
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: m, n, k
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: lda, ldb, ldc
CHARACTER(C_CHAR), INTENT(IN) :: transa, transb
TYPE(C_PTR), INTENT(IN), VALUE :: alpha, beta
TYPE(C_PTR), INTENT(IN), VALUE :: a, b, c
TYPE(C_PTR), INTENT(IN), VALUE :: stride_a
TYPE(C_PTR), INTENT(IN), VALUE :: stride_b
TYPE(C_PTR), INTENT(IN), VALUE :: stride_c
INTEGER(C_INT), INTENT(IN) :: iprec, oprec, batchcheck
END SUBROUTINE
!> Process a series of SMMs (batch) with OpenMP (libxsmmext).
!> Implicit FORTRAN 77 interface:
!> INTEGER(4) :: iprec, oprec, batchcheck
!> CHAR :: transa, transb
!> INTEGER(4|8) :: m, n, k, lda, ldb, ldc
!> REAL(4|8) :: alpha, beta
!> ARRAY :: a, b, c
!> ARRAY/VALUE :: stride_a, stride_b, stride_c
!> INTEGER(4|8) :: index_stride, index_base, batchsize
PURE SUBROUTINE libxsmm_xgemm_batch_omp( &
& iprec, oprec, transa, transb, m, n, k, &
& alpha, a, lda, stride_a, b, ldb, stride_b, &
& beta, c, ldc, stride_c, index_stride, index_base, &
& batchsize, batchcheck) &
& BIND(C, NAME="libxsmm_gemm_batch_omp_")
IMPORT :: C_PTR, C_CHAR, C_INT, LIBXSMM_BLASINT_KIND
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: index_base
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: index_stride
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: batchsize
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: m, n, k
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: lda, ldb, ldc
CHARACTER(C_CHAR), INTENT(IN) :: transa, transb
TYPE(C_PTR), INTENT(IN), VALUE :: alpha, beta
TYPE(C_PTR), INTENT(IN), VALUE :: a, b, c
TYPE(C_PTR), INTENT(IN), VALUE :: stride_a
TYPE(C_PTR), INTENT(IN), VALUE :: stride_b
TYPE(C_PTR), INTENT(IN), VALUE :: stride_c
INTEGER(C_INT), INTENT(IN) :: iprec, oprec, batchcheck
END SUBROUTINE
!> Reduces input into output such that the difference is
!> maintained or increased (max function). The very first
!> (initial) output should be zeroed (libxsmm_matdiff_clear).
!> Implicit FORTRAN 77 interface: available.
PURE SUBROUTINE libxsmm_matdiff_reduce(output, input) BIND(C)
IMPORT :: LIBXSMM_MATDIFF_INFO
TYPE(LIBXSMM_MATDIFF_INFO), INTENT(INOUT) :: output
TYPE(LIBXSMM_MATDIFF_INFO), INTENT(IN) :: input
END SUBROUTINE
!> Clears the given info-structure, e.g., for the initial
!> reduction-value (libxsmm_matdiff_reduce).
!> Implicit FORTRAN 77 interface: available.
PURE SUBROUTINE libxsmm_matdiff_clear(info) BIND(C)
IMPORT :: LIBXSMM_MATDIFF_INFO
TYPE(LIBXSMM_MATDIFF_INFO), INTENT(OUT) :: info
END SUBROUTINE
!> Calculates a hash value for the given array and seed.
!> Routine suitable for FORTRAN 77; keysize in Bytes.
PURE SUBROUTINE libxsmm_xhash(hash_seed, key, keysize) &
& BIND(C, NAME="libxsmm_xhash_")
IMPORT :: C_INT, C_PTR
INTEGER(C_INT), INTENT(INOUT) :: hash_seed
INTEGER(C_INT), INTENT(IN) :: keysize
TYPE(C_PTR), INTENT(IN), VALUE :: key
END SUBROUTINE
!> Calculates if there is a difference between two arrays.
!> Routine suitable for FORTRAN 77; size in Bytes.
PURE SUBROUTINE libxsmm_xdiff(diff, a, b, nbytes) &
& BIND(C, NAME="libxsmm_xdiff_")
IMPORT :: C_PTR, C_LONG_LONG, C_BOOL
TYPE(C_PTR), INTENT(IN), VALUE :: a, b
INTEGER(C_LONG_LONG), INTENT(IN) :: nbytes
LOGICAL(C_BOOL), INTENT(OUT) :: diff
END SUBROUTINE
END INTERFACE
$MNK_INTERFACE_LIST
INTERFACE libxsmm_ptr0
MODULE PROCEDURE libxsmm_ptr_z0, libxsmm_ptr_c0
MODULE PROCEDURE libxsmm_ptr_d0, libxsmm_ptr_s0
MODULE PROCEDURE libxsmm_ptr_i0, libxsmm_ptr_w0
MODULE PROCEDURE libxsmm_ptr_j0 !! Byte/char
MODULE PROCEDURE libxsmm_ptr_b0 !! Byte/char
MODULE PROCEDURE libxsmm_ptr_l0 !! long long
END INTERFACE
INTERFACE libxsmm_ptr1
MODULE PROCEDURE libxsmm_ptr_z1, libxsmm_ptr_c1
MODULE PROCEDURE libxsmm_ptr_d1, libxsmm_ptr_s1
MODULE PROCEDURE libxsmm_ptr_i1, libxsmm_ptr_w1
MODULE PROCEDURE libxsmm_ptr_j1 !! Byte/char
MODULE PROCEDURE libxsmm_ptr_b1 !! Byte/char
MODULE PROCEDURE libxsmm_ptr_l1 !! long long
MODULE PROCEDURE libxsmm_ptr_dmm
MODULE PROCEDURE libxsmm_ptr_smm
END INTERFACE
INTERFACE libxsmm_ptr2
MODULE PROCEDURE libxsmm_ptr_z2, libxsmm_ptr_c2
MODULE PROCEDURE libxsmm_ptr_d2, libxsmm_ptr_s2
MODULE PROCEDURE libxsmm_ptr_i2, libxsmm_ptr_w2
MODULE PROCEDURE libxsmm_ptr_j2 !! Byte/char
MODULE PROCEDURE libxsmm_ptr_b2 !! Byte/char
MODULE PROCEDURE libxsmm_ptr_l2 !! long long
END INTERFACE
INTERFACE libxsmm_ptr
MODULE PROCEDURE libxsmm_ptr_z0, libxsmm_ptr_c0
MODULE PROCEDURE libxsmm_ptr_d0, libxsmm_ptr_s0
MODULE PROCEDURE libxsmm_ptr_i0, libxsmm_ptr_w0
MODULE PROCEDURE libxsmm_ptr_j0 !! Byte/char
MODULE PROCEDURE libxsmm_ptr_b0 !! Byte/char
MODULE PROCEDURE libxsmm_ptr_l0 !! long long
MODULE PROCEDURE libxsmm_ptr_z1, libxsmm_ptr_c1
MODULE PROCEDURE libxsmm_ptr_d1, libxsmm_ptr_s1
MODULE PROCEDURE libxsmm_ptr_i1, libxsmm_ptr_w1
MODULE PROCEDURE libxsmm_ptr_j1 !! Byte/char
MODULE PROCEDURE libxsmm_ptr_b1 !! Byte/char
MODULE PROCEDURE libxsmm_ptr_l1 !! long long
MODULE PROCEDURE libxsmm_ptr_z2, libxsmm_ptr_c2
MODULE PROCEDURE libxsmm_ptr_d2, libxsmm_ptr_s2
MODULE PROCEDURE libxsmm_ptr_i2, libxsmm_ptr_w2
MODULE PROCEDURE libxsmm_ptr_j2 !! Byte/char
MODULE PROCEDURE libxsmm_ptr_b2 !! Byte/char
MODULE PROCEDURE libxsmm_ptr_l2 !! long long
MODULE PROCEDURE libxsmm_ptr_dmm
MODULE PROCEDURE libxsmm_ptr_smm
END INTERFACE
!> Deallocates JIT'ted code, or unregisters and
!> releases code from registry.
INTERFACE libxsmm_release_mmkernel
MODULE PROCEDURE libxsmm_release_dmmkernel
MODULE PROCEDURE libxsmm_release_smmkernel
END INTERFACE
!> Construct JIT-code depending on given argument set.
INTERFACE libxsmm_mmdispatch
MODULE PROCEDURE libxsmm_dmmdispatch, libxsmm_smmdispatch
END INTERFACE
!> Construct JIT-code depending on given argument set.
INTERFACE libxsmm_dispatch
MODULE PROCEDURE libxsmm_dmmdispatch, libxsmm_smmdispatch
END INTERFACE
!> Check if a function is available (LIBXSMM_?MMFUNCTION).
INTERFACE libxsmm_mmavailable
MODULE PROCEDURE libxsmm_dmmavailable, libxsmm_smmavailable
END INTERFACE
!> Check if a function is available (LIBXSMM_?MMFUNCTION).
INTERFACE libxsmm_available
MODULE PROCEDURE libxsmm_smmavailable, libxsmm_dmmavailable
END INTERFACE
!> Overloaded GEMM routines (double-precision).
INTERFACE libxsmm_dgemm
MODULE PROCEDURE libxsmm_dgemm0
MODULE PROCEDURE libxsmm_dgemm1
MODULE PROCEDURE libxsmm_dgemm2
MODULE PROCEDURE libxsmm_dgemm3
END INTERFACE
!> Overloaded GEMM routines (single-precision).
INTERFACE libxsmm_sgemm
MODULE PROCEDURE libxsmm_sgemm0
MODULE PROCEDURE libxsmm_sgemm1
MODULE PROCEDURE libxsmm_sgemm2
END INTERFACE
!> Overloaded GEMM routines.
INTERFACE libxsmm_gemm
MODULE PROCEDURE libxsmm_dgemm0
MODULE PROCEDURE libxsmm_dgemm1
MODULE PROCEDURE libxsmm_dgemm2
MODULE PROCEDURE libxsmm_dgemm3
MODULE PROCEDURE libxsmm_sgemm0
MODULE PROCEDURE libxsmm_sgemm1
MODULE PROCEDURE libxsmm_sgemm2
MODULE PROCEDURE libxsmm_sgemm3
END INTERFACE
!> Overloaded BLAS GEMM routines (double-precision).
INTERFACE libxsmm_blas_dgemm
MODULE PROCEDURE libxsmm_blas_dgemm0
MODULE PROCEDURE libxsmm_blas_dgemm1
MODULE PROCEDURE libxsmm_blas_dgemm2
MODULE PROCEDURE libxsmm_blas_dgemm3
END INTERFACE
!> Overloaded BLAS GEMM routines (single-precision).
INTERFACE libxsmm_blas_sgemm
MODULE PROCEDURE libxsmm_blas_sgemm0
MODULE PROCEDURE libxsmm_blas_sgemm1
MODULE PROCEDURE libxsmm_blas_sgemm2
MODULE PROCEDURE libxsmm_blas_sgemm3
END INTERFACE
!> Overloaded BLAS GEMM routines (single/double-precision).
INTERFACE libxsmm_blas_gemm
MODULE PROCEDURE libxsmm_blas_dgemm0
MODULE PROCEDURE libxsmm_blas_dgemm1
MODULE PROCEDURE libxsmm_blas_dgemm2
MODULE PROCEDURE libxsmm_blas_dgemm3
MODULE PROCEDURE libxsmm_blas_sgemm0
MODULE PROCEDURE libxsmm_blas_sgemm1
MODULE PROCEDURE libxsmm_blas_sgemm2
MODULE PROCEDURE libxsmm_blas_sgemm3
END INTERFACE
!> Overloaded MATCOPY routines (2d-copy).
INTERFACE libxsmm_matcopy
MODULE PROCEDURE libxsmm_matcopy_p0
MODULE PROCEDURE libxsmm_matcopy_d1
MODULE PROCEDURE libxsmm_matcopy_d2
MODULE PROCEDURE libxsmm_matcopy_s1
MODULE PROCEDURE libxsmm_matcopy_s2
END INTERFACE
!> Overloaded TRANSPOSE routines (in-place form).
INTERFACE libxsmm_itrans
MODULE PROCEDURE libxsmm_itrans_p0
MODULE PROCEDURE libxsmm_itrans_d1
MODULE PROCEDURE libxsmm_itrans_d2
MODULE PROCEDURE libxsmm_itrans_s1
MODULE PROCEDURE libxsmm_itrans_s2
END INTERFACE
!> Overloaded TRANSPOSE routines (out-of-place form).
INTERFACE libxsmm_otrans
MODULE PROCEDURE libxsmm_otrans_p0
MODULE PROCEDURE libxsmm_otrans_d1
MODULE PROCEDURE libxsmm_otrans_d2
MODULE PROCEDURE libxsmm_otrans_s1
MODULE PROCEDURE libxsmm_otrans_s2
END INTERFACE
!> Calculate a hash value for a given key value (binary blob).
!> Conceptually pure, but C_LOC may be (incorrectly) impure.
INTERFACE libxsmm_hash
MODULE PROCEDURE libxsmm_hash_char
MODULE PROCEDURE libxsmm_hash_i8
MODULE PROCEDURE libxsmm_hash_i32
MODULE PROCEDURE libxsmm_hash_i64
END INTERFACE
!> Calculate whether there is a difference between two series
!> of items. Conceptually pure, but C_LOC may be
!> (incorrectly) impure.
INTERFACE libxsmm_diff
MODULE PROCEDURE libxsmm_diff_char
MODULE PROCEDURE libxsmm_diff_i8
MODULE PROCEDURE libxsmm_diff_i32
MODULE PROCEDURE libxsmm_diff_i64
END INTERFACE
CONTAINS
!> Returns the name of the target architecture as determined
!> by the CPUID flags, as set by the libxsmm_get_target_arch*
!> functions, or as set by the LIBXSMM_TARGET environment
!> variable.
FUNCTION libxsmm_get_target_arch()
!CHARACTER(LEN=:), POINTER :: libxsmm_get_target_arch
CHARACTER, POINTER :: libxsmm_get_target_arch(:)
INTEGER(C_INT) :: length(1)
TYPE(C_PTR) :: arch
INTERFACE
FUNCTION libxsmmf_get_target_arch(length) BIND(C)
IMPORT :: C_INT, C_PTR
INTEGER(C_INT), INTENT(OUT) :: length
TYPE(C_PTR) :: libxsmmf_get_target_arch
END FUNCTION
END INTERFACE
arch = libxsmmf_get_target_arch(length(1))
CALL C_F_POINTER(arch, libxsmm_get_target_arch, length)
END FUNCTION
!> Returns C_NULL_PTR.
PURE FUNCTION libxsmm_ptr_null()
TYPE(C_PTR) :: libxsmm_ptr_null
libxsmm_ptr_null = C_NULL_PTR
END FUNCTION
!> Determines the C-address of the given array.
FUNCTION libxsmm_ptr_z0(a)
COMPLEX(C_DOUBLE_COMPLEX), INTENT(IN), TARGET :: a
TYPE(C_PTR) :: libxsmm_ptr_z0
libxsmm_ptr_z0 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_z1(a)
COMPLEX(C_DOUBLE_COMPLEX), INTENT(IN), TARGET :: a(*)
TYPE(C_PTR) :: libxsmm_ptr_z1
libxsmm_ptr_z1 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_z2(a)
COMPLEX(C_DOUBLE_COMPLEX), INTENT(IN) :: a(:,:)
TYPE(C_PTR) :: libxsmm_ptr_z2
libxsmm_ptr_z2 = libxsmm_ptr_z1(a)
END FUNCTION
!> Determines the C-address of the given array.
FUNCTION libxsmm_ptr_c0(a)
COMPLEX(C_FLOAT_COMPLEX), INTENT(IN), TARGET :: a
TYPE(C_PTR) :: libxsmm_ptr_c0
libxsmm_ptr_c0 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_c1(a)
COMPLEX(C_FLOAT_COMPLEX), INTENT(IN), TARGET :: a(*)
TYPE(C_PTR) :: libxsmm_ptr_c1
libxsmm_ptr_c1 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_c2(a)
COMPLEX(C_FLOAT_COMPLEX), INTENT(IN) :: a(:,:)
TYPE(C_PTR) :: libxsmm_ptr_c2
libxsmm_ptr_c2 = libxsmm_ptr_c1(a)
END FUNCTION
!> Determines the C-address of the given array.
FUNCTION libxsmm_ptr_d0(a)
REAL(C_DOUBLE), INTENT(IN), TARGET :: a
TYPE(C_PTR) :: libxsmm_ptr_d0
libxsmm_ptr_d0 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_d1(a)
REAL(C_DOUBLE), INTENT(IN), TARGET :: a(*)
TYPE(C_PTR) :: libxsmm_ptr_d1
libxsmm_ptr_d1 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_d2(a)
REAL(C_DOUBLE), INTENT(IN) :: a(:,:)
TYPE(C_PTR) :: libxsmm_ptr_d2
libxsmm_ptr_d2 = libxsmm_ptr_d1(a)
END FUNCTION
!> Determines the C-address of the given array.
FUNCTION libxsmm_ptr_s0(a)
REAL(C_FLOAT), INTENT(IN), TARGET :: a
TYPE(C_PTR) :: libxsmm_ptr_s0
libxsmm_ptr_s0 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_s1(a)
REAL(C_FLOAT), INTENT(IN), TARGET :: a(*)
TYPE(C_PTR) :: libxsmm_ptr_s1
libxsmm_ptr_s1 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_s2(a)
REAL(C_FLOAT), INTENT(IN) :: a(:,:)
TYPE(C_PTR) :: libxsmm_ptr_s2
libxsmm_ptr_s2 = libxsmm_ptr_s1(a)
END FUNCTION
!> Determines the C-address of the given array.
FUNCTION libxsmm_ptr_i0(a)
INTEGER(C_INT), INTENT(IN), TARGET :: a
TYPE(C_PTR) :: libxsmm_ptr_i0
libxsmm_ptr_i0 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_i1(a)
INTEGER(C_INT), INTENT(IN), TARGET :: a(*)
TYPE(C_PTR) :: libxsmm_ptr_i1
libxsmm_ptr_i1 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_i2(a)
INTEGER(C_INT), INTENT(IN) :: a(:,:)
TYPE(C_PTR) :: libxsmm_ptr_i2
libxsmm_ptr_i2 = libxsmm_ptr_i1(a)
END FUNCTION
!> Determines the C-address of the given array.
FUNCTION libxsmm_ptr_w0(a)
INTEGER(C_SHORT), INTENT(IN), TARGET :: a
TYPE(C_PTR) :: libxsmm_ptr_w0
libxsmm_ptr_w0 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_w1(a)
INTEGER(C_SHORT), INTENT(IN), TARGET :: a(*)
TYPE(C_PTR) :: libxsmm_ptr_w1
libxsmm_ptr_w1 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_w2(a)
INTEGER(C_SHORT), INTENT(IN) :: a(:,:)
TYPE(C_PTR) :: libxsmm_ptr_w2
libxsmm_ptr_w2 = libxsmm_ptr_w1(a)
END FUNCTION
!> Determines the C-address of the given array.
FUNCTION libxsmm_ptr_j0(a)
INTEGER(C_INT8_T), INTENT(IN), TARGET :: a
TYPE(C_PTR) :: libxsmm_ptr_j0
libxsmm_ptr_j0 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_j1(a)
INTEGER(C_INT8_T), INTENT(IN), TARGET :: a(*)
TYPE(C_PTR) :: libxsmm_ptr_j1
libxsmm_ptr_j1 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_j2(a)
INTEGER(C_INT8_T), INTENT(IN) :: a(:,:)
TYPE(C_PTR) :: libxsmm_ptr_j2
libxsmm_ptr_j2 = libxsmm_ptr_j1(a)
END FUNCTION
!> Determines the C-address of the given array.
FUNCTION libxsmm_ptr_b0(a)
CHARACTER(C_CHAR), INTENT(IN), TARGET :: a
TYPE(C_PTR) :: libxsmm_ptr_b0
libxsmm_ptr_b0 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_b1(a)
CHARACTER(C_CHAR), INTENT(IN), TARGET :: a(*)
TYPE(C_PTR) :: libxsmm_ptr_b1
libxsmm_ptr_b1 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_b2(a)
CHARACTER(C_CHAR), INTENT(IN) :: a(:,:)
TYPE(C_PTR) :: libxsmm_ptr_b2
libxsmm_ptr_b2 = libxsmm_ptr_b1(a)
END FUNCTION
!> Determines the C-address of the given array.
FUNCTION libxsmm_ptr_l0(a)
INTEGER(C_LONG_LONG), INTENT(IN), TARGET :: a
TYPE(C_PTR) :: libxsmm_ptr_l0
libxsmm_ptr_l0 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_l1(a)
INTEGER(C_LONG_LONG), INTENT(IN), TARGET :: a(*)
TYPE(C_PTR) :: libxsmm_ptr_l1
libxsmm_ptr_l1 = C_LOC(a)
END FUNCTION
FUNCTION libxsmm_ptr_l2(a)
INTEGER(C_LONG_LONG), INTENT(IN) :: a(:,:)
TYPE(C_PTR) :: libxsmm_ptr_l2
libxsmm_ptr_l2 = libxsmm_ptr_l1(a)
END FUNCTION
FUNCTION libxsmm_ptr_dmm(a)
TYPE(LIBXSMM_DMMFUNCTION), INTENT(IN), TARGET :: a(:)
TYPE(LIBXSMM_DMMFUNCTION), POINTER :: p
TYPE(C_PTR) :: libxsmm_ptr_dmm
p => a(LBOUND(a,1)); libxsmm_ptr_dmm = C_LOC(p%handle)
END FUNCTION
FUNCTION libxsmm_ptr_smm(a)
TYPE(LIBXSMM_SMMFUNCTION), INTENT(IN), TARGET :: a(:)
TYPE(LIBXSMM_SMMFUNCTION), POINTER :: p
TYPE(C_PTR) :: libxsmm_ptr_smm
p => a(LBOUND(a,1)); libxsmm_ptr_smm = C_LOC(p%handle)
END FUNCTION
!> Deallocate JIT'ted code created by libxsmm_create routines.
!> To unregister code generated with libxsmm_dispatch
!> is unnecessary.
SUBROUTINE libxsmm_release_dmmkernel(kernel)
TYPE(LIBXSMM_DMMFUNCTION), INTENT(IN) :: kernel
CALL libxsmm_release_kernel(kernel%handle)
END SUBROUTINE
!> Deallocate JIT'ted code created by libxsmm_create routines.
!> To unregister code generated with libxsmm_dispatch
!> is unnecessary.
SUBROUTINE libxsmm_release_smmkernel(kernel)
TYPE(LIBXSMM_SMMFUNCTION), INTENT(IN) :: kernel
CALL libxsmm_release_kernel(kernel%handle)
END SUBROUTINE
!> Query or JIT-generate an SMM-kernel (double-precision).
SUBROUTINE libxsmm_dmmdispatch(kernel, &
& m, n, k, lda, ldb, ldc, alpha, beta, flags, prefetch)
TYPE(LIBXSMM_DMMFUNCTION), INTENT(OUT) :: kernel
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: m, n, k
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN), &
& OPTIONAL, TARGET :: lda, ldb, ldc
REAL(C_DOUBLE), INTENT(IN), OPTIONAL, TARGET :: alpha, beta
INTEGER(C_INT), INTENT(IN), OPTIONAL, TARGET :: flags
INTEGER(C_INT), INTENT(IN), OPTIONAL, TARGET :: prefetch
CALL libxsmm_xmmdispatch( &
& kernel%handle, LIBXSMM_DATATYPE_F64, &
& m, n, k, C_LOC(lda), C_LOC(ldb), C_LOC(ldc), &
& C_LOC(alpha), C_LOC(beta), C_LOC(flags), C_LOC(prefetch))
END SUBROUTINE
!> Query or JIT-generate an SMM-kernel (single-precision).
SUBROUTINE libxsmm_smmdispatch(kernel, &
& m, n, k, lda, ldb, ldc, alpha, beta, flags, prefetch)
TYPE(LIBXSMM_SMMFUNCTION), INTENT(OUT) :: kernel
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN) :: m, n, k
INTEGER(LIBXSMM_BLASINT_KIND), INTENT(IN), &
& OPTIONAL, TARGET :: lda, ldb, ldc
REAL(C_FLOAT), INTENT(IN), OPTIONAL, TARGET :: alpha, beta
INTEGER(C_INT), INTENT(IN), OPTIONAL, TARGET :: flags
INTEGER(C_INT), INTENT(IN), OPTIONAL, TARGET :: prefetch
CALL libxsmm_xmmdispatch( &
& kernel%handle, LIBXSMM_DATATYPE_F32, &
& m, n, k, C_LOC(lda), C_LOC(ldb), C_LOC(ldc), &
& C_LOC(alpha), C_LOC(beta), C_LOC(flags), C_LOC(prefetch))
END SUBROUTINE
!> Checks if the given kernel was generated. JIT code is
!> guaranteed to be generated if JIT support was enabled
!> at build-time of the library (default).
!> This overload belongs to libxsmm_(mm)available.
LOGICAL FUNCTION libxsmm_dmmavailable(kernel)