forked from libxsmm/libxsmm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
1807 lines (1664 loc) · 66.5 KB
/
Makefile
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
# ROOTDIR avoid abspath to match Makefile targets
ROOTDIR := $(subst //,,$(dir $(firstword $(MAKEFILE_LIST)))/)
# Source and scripts locations
ROOTINC := $(ROOTDIR)/include
ROOTSCR := $(ROOTDIR)/scripts
ROOTSRC := $(ROOTDIR)/src
# Project directory structure
INCDIR := include
SCRDIR := scripts
TSTDIR := tests
BLDDIR := obj
SRCDIR := src
OUTDIR := lib
BINDIR := bin
SPLDIR := samples
UTLDIR := $(SPLDIR)/utilities
DOCDIR := documentation
# subdirectories (relative) to PREFIX (install targets)
PINCDIR ?= $(INCDIR)
PSRCDIR ?= libxsmm
POUTDIR ?= $(OUTDIR)
PPKGDIR ?= $(OUTDIR)
PMODDIR ?= $(OUTDIR)
PBINDIR ?= $(BINDIR)
PTSTDIR ?= $(TSTDIR)
PSHRDIR ?= share/libxsmm
PDOCDIR ?= $(PSHRDIR)
LICFDIR ?= $(PDOCDIR)
LICFILE ?= LICENSE.md
# initial default flags: RPM_OPT_FLAGS are usually NULL
CFLAGS := $(RPM_OPT_FLAGS)
CXXFLAGS := $(RPM_OPT_FLAGS)
FCFLAGS := $(RPM_OPT_FLAGS)
# THRESHOLD problem size (M x N x K) determining when to use BLAS
# A value of zero (0) populates a default threshold
THRESHOLD ?= 0
# Generates M,N,K-combinations for each comma separated group, e.g., "1, 2, 3" generates (1,1,1), (2,2,2),
# and (3,3,3). This way a heterogeneous set can be generated, e.g., "1 2, 3" generates (1,1,1), (1,1,2),
# (1,2,1), (1,2,2), (2,1,1), (2,1,2) (2,2,1) out of the first group, and a (3,3,3) for the second group
# To generate a series of square matrices one can specify, e.g., make MNK=$(echo $(seq -s, 1 5))
# Alternative to MNK, index sets can be specified separately according to a loop nest relationship
# (M(N(K))) using M, N, and K separately. Please consult the documentation for further details.
MNK ?= 0
# Enable thread-local cache of recently dispatched kernels either
# 0: "disable", 1: "enable", or small power-of-two number.
CACHE ?= 1
# Issue software prefetch instructions (see end of section
# https://github.com/libxsmm/libxsmm/#generator-driver)
# Use the enumerator 1...6, or the exact strategy
# name pfsigonly...AL2_BL2viaC.
# 0: no prefetch (nopf)
# 1: auto-select
# 2: pfsigonly
# 3: BL2viaC
# 4: curAL2
# 7: curAL2_BL2viaC
# 5: AL2
# 6: AL2_BL2viaC
PREFETCH ?= 1
# Preferred precision when registering statically generated code versions
# 0: SP and DP code versions to be registered
# 1: SP only
# 2: DP only
PRECISION ?= 0
# Specify the size of a cacheline (Bytes)
CACHELINE ?= 64
# Max. size of JIT-buffer [Bytes]
# 0: fixed/internal default
# N: fixed/specific value
CODE_BUF_MAXSIZE ?= 0
ifneq (0,$(CODE_BUF_MAXSIZE))
DFLAGS += -DLIBXSMM_CODE_MAXSIZE=$(CODE_BUF_MAXSIZE)
endif
# Alpha argument of GEMM
# Supported: 1.0
ALPHA ?= 1
ifneq (1,$(ALPHA))
$(info --------------------------------------------------------------------------------)
$(error ALPHA needs to be 1)
endif
# Beta argument of GEMM
# Supported: 0.0, 1.0
# 0: C := A * B
# 1: C += A * B
BETA ?= 1
ifneq (1,$(BETA))
ifneq (0,$(BETA))
$(info --------------------------------------------------------------------------------)
$(error BETA needs to be either 0 or 1)
endif
endif
# Determines if the library is thread-safe
THREADS ?= 1
# 0: link all dependencies as specified for the target
# 1: attempt to avoid dependencies if not referenced
ASNEEDED ?= 0
# -1: support intercepted malloc (disabled at runtime by default)
# 0: disable intercepted malloc at compile-time
# >0: enable intercepted malloc
MALLOC ?= 0
# 0: disable moderating memory allocations
# 1: moderated memory alignment
ALIGN ?= 0
ifneq (0,$(ALIGN))
DFLAGS += -DLIBXSMM_MALLOC_MOD
endif
# Determines the kind of routine called for intercepted GEMMs
# >=1 and odd : sequential and non-tiled (small problem sizes only)
# >=2 and even: parallelized and tiled (all problem sizes)
# >=3 and odd : GEMV is intercepted; small problem sizes
# >=4 and even: GEMV is intercepted; all problem sizes
# negative: BLAS provides DGEMM_BATCH and SGEMM_BATCH
# 0: disabled
WRAP ?= 1
# Attempts to pin OpenMP based threads
AUTOPIN ?= 0
ifneq (0,$(AUTOPIN))
DFLAGS += -DLIBXSMM_AUTOPIN
endif
# Profiling JIT code using Linux Perf
# PERF=0: disabled (default)
# PERF=1: enabled (without JITDUMP)
# PERF=2: enabled (with JITDUMP)
#
# Additional support for jitdump
# JITDUMP=0: disabled (default)
# JITDUMP=1: enabled
# PERF=2: enabled
#
ifneq (,$(PERF))
ifneq (0,$(PERF))
ifneq (1,$(PERF))
JITDUMP ?= 1
endif
endif
endif
JITDUMP ?= 0
ifneq (0,$(JITDUMP))
PERF ?= 1
endif
PERF ?= 0
ifneq (0,$(PERF))
SYM ?= 1
endif
# OpenMP is disabled by default and LIBXSMM is
# always agnostic wrt the threading runtime
OMP ?= 0
ifneq (1,$(CACHE))
DFLAGS += -DLIBXSMM_CAPACITY_CACHE=$(CACHE)
endif
# disable lazy initialization and rely on ctor attribute
ifeq (0,$(INIT))
DFLAGS += -DLIBXSMM_CTOR
endif
# Kind of documentation (internal key)
DOCEXT := pdf
# Timeout when downloading documentation parts
TIMEOUT := 30
# state to be excluded from tracking the (re-)build state
EXCLUDE_STATE := \
DESTDIR PREFIX BINDIR CURDIR DOCDIR DOCEXT INCDIR LICFDIR OUTDIR TSTDIR TIMEOUT \
PBINDIR PINCDIR POUTDIR PPKGDIR PMODDIR PSRCDIR PTSTDIR PSHRDIR PDOCDIR SCRDIR \
SPLDIR UTLDIR SRCDIR TEST VERSION_STRING ALIAS_% BLAS %_TARGET %ROOT
# fixed .state file directory (included by source)
DIRSTATE := $(OUTDIR)/..
ifeq (,$(M)$(N)$(K))
ifeq (,$(filter-out 0,$(MNK)))
EXCLUDE_STATE += PRECISION MNK M N K
endif
endif
# avoid to link with C++ standard library
FORCE_CXX := 0
# enable additional/compile-time warnings
WCHECK := 1
# include common Makefile artifacts
include $(ROOTDIR)/Makefile.inc
# 0: static, 1: shared, 2: static and shared
ifneq (,$(filter-out file,$(origin STATIC)))
ifneq (0,$(STATIC))
BUILD := 0
else # shared
BUILD := 1
endif
else # default
BUILD := 2
endif
# TRACE facility
INSTRUMENT ?= $(TRACE)
# JIT backend is enabled by default
ifeq (0,$(call qnum,$(PLATFORM))) # NaN
JIT ?= 1
else ifeq (1,$(PLATFORM))
# JIT is disabled if platform is forced
# enable with "PLATFORM=1 JIT=1" or "PLATFORM=2"
VTUNE := 0
MKL := 0
JIT ?= 0
else
# imply JIT=1 if PLATFORM=2 (or higher)
VTUNE := 0
MKL := 0
JIT ?= 1
endif
# target library for a broad range of systems
ifneq (0,$(JIT))
SSE ?= 1
endif
ifneq (,$(MKL))
ifneq (0,$(MKL))
BLAS := $(MKL)
endif
endif
ifneq (,$(MAXTARGET))
DFLAGS += -DLIBXSMM_MAXTARGET=$(MAXTARGET)
endif
# necessary include directories
IFLAGS += -I$(call quote,$(INCDIR))
IFLAGS += -I$(call quote,$(ROOTSRC))
ifeq (,$(PYTHON))
$(info --------------------------------------------------------------------------------)
$(error No Python interpreter found)
endif
# Version numbers according to interface (version.txt)
VERSION_MAJOR ?= $(shell $(PYTHON) $(ROOTSCR)/libxsmm_utilities.py 1)
VERSION_MINOR ?= $(shell $(PYTHON) $(ROOTSCR)/libxsmm_utilities.py 2)
VERSION_UPDATE ?= $(shell $(PYTHON) $(ROOTSCR)/libxsmm_utilities.py 3)
VERSION_STRING ?= $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_UPDATE)
VERSION_API ?= $(shell $(PYTHON) $(ROOTSCR)/libxsmm_utilities.py 0 $(VERSION_STRING))
VERSION_ALL ?= $(shell $(PYTHON) $(ROOTSCR)/libxsmm_utilities.py 0)
VERSION_RELEASED ?= $(shell $(PYTHON) $(ROOTSCR)/libxsmm_utilities.py -1 $(VERSION_ALL))
VERSION_RELEASE ?= HEAD
VERSION_PACKAGE ?= 1
# explicitly target all objects
ifneq (,$(strip $(SSE)$(AVX)))
TGT ?= 1
endif
TGT ?= 0
ifeq (0,$(BLAS))
ifneq (0,$(LNKSOFT))
ifeq (Darwin,$(UNAME))
LDFLAGS += $(call linkopt,-U,_dgemm_)
LDFLAGS += $(call linkopt,-U,_sgemm_)
LDFLAGS += $(call linkopt,-U,_dgemv_)
LDFLAGS += $(call linkopt,-U,_sgemv_)
endif
endif
endif
# target library for a broad range of systems
ifneq (0,$(JIT))
ifeq (file,$(origin AVX))
AVX_STATIC := 0
endif
endif
AVX_STATIC ?= $(AVX)
ifeq (1,$(AVX_STATIC))
GENTARGET := snb
else ifeq (2,$(AVX_STATIC))
GENTARGET := hsw
else ifeq (3,$(AVX_STATIC))
GENTARGET := skx
else ifneq (0,$(SSE))
GENTARGET := wsm
else
GENTARGET := noarch
endif
ifneq (Darwin,$(UNAME))
GENGEMM := @$(ENVBIN) \
LD_LIBRARY_PATH="$(OUTDIR):$${LD_LIBRARY_PATH}" \
PATH="$(OUTDIR):$${PATH}" \
$(BINDIR)/libxsmm_gemm_generator
else # osx
GENGEMM := @$(ENVBIN) \
DYLD_LIBRARY_PATH="$(OUTDIR):$${DYLD_LIBRARY_PATH}" \
PATH="$(OUTDIR):$${PATH}" \
$(BINDIR)/libxsmm_gemm_generator
endif
INDICES ?= $(shell $(PYTHON) $(ROOTSCR)/libxsmm_utilities.py -1 $(THRESHOLD) $(words $(MNK)) $(MNK) $(words $(M)) $(words $(N)) $(M) $(N) $(K))
NINDICES := $(words $(INDICES))
SRCFILES_KERNELS := $(patsubst %,$(BLDDIR)/mm_%.c,$(INDICES))
KRNOBJS := $(patsubst %,$(BLDDIR)/intel64/mm_%.o,$(INDICES))
HEADERS_UTILS := \
$(ROOTINC)/utils/libxsmm_lpflt_quant.h \
$(ROOTINC)/utils/libxsmm_barrier.h \
$(ROOTINC)/utils/libxsmm_timer.h \
$(ROOTINC)/utils/libxsmm_math.h \
$(ROOTINC)/utils/libxsmm_mhd.h \
$(NULL)
HEADERS_MAIN := \
$(ROOTINC)/libxsmm_generator.h \
$(ROOTINC)/libxsmm_typedefs.h \
$(ROOTINC)/libxsmm_fsspmdm.h \
$(ROOTINC)/libxsmm_macros.h \
$(ROOTINC)/libxsmm_memory.h \
$(ROOTINC)/libxsmm_malloc.h \
$(ROOTINC)/libxsmm_cpuid.h \
$(ROOTINC)/libxsmm_math.h \
$(ROOTINC)/libxsmm_sync.h \
$(ROOTINC)/libxsmm_utils.h \
$(ROOTINC)/libxsmm_intrinsics_x86.h \
$(NULL)
HEADERS_SRC := $(wildcard $(ROOTSRC)/*.h)
HEADERS := \
$(wildcard $(ROOTSRC)/template/*.h) \
$(HEADERS_SRC) $(HEADERS_MAIN) $(HEADERS_UTILS)
SRCFILES_LIB := $(patsubst %,$(ROOTSRC)/%, \
libxsmm_main.c libxsmm_memory.c libxsmm_malloc.c libxsmm_math.c libxsmm_fsspmdm.c \
libxsmm_hash.c libxsmm_sync.c libxsmm_perf.c libxsmm_gemm.c libxsmm_xcopy.c \
libxsmm_utils.c libxsmm_lpflt_quant.c libxsmm_timer.c libxsmm_barrier.c \
libxsmm_rng.c libxsmm_mhd.c)
SRCFILES_GEN_LIB := $(patsubst %,$(ROOTSRC)/%,$(notdir $(wildcard $(ROOTSRC)/generator_*.c)) \
libxsmm_cpuid_arm.c libxsmm_cpuid_x86.c libxsmm_generator.c libxsmm_trace.c libxsmm_matrixeqn.c)
SRCFILES := $(SRCFILES_LIB) $(SRCFILES_GEN_LIB) $(SRCFILES_KERNELS)
SRCFILES_GEN_GEMM_BIN := $(patsubst %,$(ROOTSRC)/%,libxsmm_generator_gemm_driver.c)
OBJFILES_GEN_GEMM_BIN := $(patsubst %,$(BLDDIR)/intel64/%.o,$(basename $(notdir $(SRCFILES_GEN_GEMM_BIN))))
OBJFILES_GEN_LIB := $(patsubst %,$(BLDDIR)/intel64/%.o,$(basename $(notdir $(SRCFILES_GEN_LIB))))
OBJFILES_LIB := $(patsubst %,$(BLDDIR)/intel64/%.o,$(basename $(notdir $(SRCFILES_LIB))))
OBJFILES_EXT := $(BLDDIR)/intel64/libxsmm_ext.o \
$(BLDDIR)/intel64/libxsmm_ext_xcopy.o \
$(BLDDIR)/intel64/libxsmm_ext_gemm.o
NOBLAS_OBJ := $(BLDDIR)/intel64/libxsmm_noblas.o
# list of object might be "incomplete" if not all code gen. FLAGS are supplied with clean target!
OBJECTS := $(OBJFILES_GEN_LIB) $(OBJFILES_GEN_GEMM_BIN) $(OBJFILES_LIB) \
$(KRNOBJS) $(OBJFILES_EXT) $(NOBLAS_OBJ)
ifneq (,$(strip $(FC)))
FTNOBJS := $(BLDDIR)/intel64/libxsmm-mod.o
endif
MSGJITPROFILING := 0
ifneq (0,$(JIT))
ifneq (0,$(VTUNE))
ifeq (,$(filter Darwin,$(UNAME)))
ifneq (0,$(PERF))
DFLAGS += -DLIBXSMM_PERF
ifneq (0,$(JITDUMP))
DFLAGS += -DLIBXSMM_PERF_JITDUMP
endif
endif
VTUNEROOT := $(shell env | grep VTUNE_PROFILER | grep -m1 _DIR | cut -d= -f2-)
ifeq (,$(VTUNEROOT))
VTUNEROOT := $(shell env | grep VTUNE_AMPLIFIER | grep -m1 _DIR | cut -d= -f2-)
endif
ifeq (,$(VTUNEROOT))
VTUNEROOT := $(EBROOTVTUNE)/vtune_amplifier
endif
ifneq (,$(wildcard $(VTUNEROOT)/lib64/libjitprofiling.$(SLIBEXT)))
ifneq (0,$(SYM))
LIBJITPROFILING := $(BLDDIR)/jitprofiling/libjitprofiling.$(SLIBEXT)
DFLAGS += -DLIBXSMM_VTUNE
IFLAGS += -I$(call quote,$(VTUNEROOT)/include)
WERROR := 0
ifneq (0,$(INTEL))
CXXFLAGS += -diag-disable 271
CFLAGS += -diag-disable 271
endif
endif
MSGJITPROFILING := 1
endif
endif
endif
endif
# no warning conversion for released versions
ifneq (0,$(VERSION_RELEASED))
WERROR := 0
endif
# no warning conversion for non-x86
#ifneq (x86_64,$(MNAME))
# WERROR := 0
#endif
# no warning conversion
ifneq (,$(filter-out 0 1,$(INTEL)))
WERROR := 0
endif
information = \
$(info ================================================================================) \
$(info LIBXSMM $(VERSION_ALL) ($(UNAME)$(if $(filter-out 0,$(LIBXSMM_TARGET_HIDDEN)),$(NULL),$(if $(HOSTNAME),@$(HOSTNAME))))) \
$(info --------------------------------------------------------------------------------) \
$(info $(GINFO)) \
$(info $(CINFO)) \
$(if $(strip $(FC)),$(info $(FINFO))) \
$(if $(strip $(FC)),$(NULL), \
$(if $(strip $(FC_VERSION)), \
$(info Fortran Compiler $(FC_VERSION) is outdated!), \
$(info Fortran Compiler is disabled or missing: no Fortran interface is built!))) \
$(info --------------------------------------------------------------------------------) \
$(if $(ENVSTATE),$(info Environment: $(ENVSTATE)) \
$(info --------------------------------------------------------------------------------))
ifneq (,$(strip $(TEST)))
.PHONY: run-tests
run-tests: tests
endif
.PHONY: libxsmm
ifeq (0,$(COMPATIBLE))
libxsmm: lib generator
else
libxsmm: lib
endif
$(information)
ifneq (,$(filter _0_,_$(LNKSOFT)_))
ifeq (0,$(STATIC))
$(info Building a shared library requires to link against BLAS)
$(info since a deferred choice is not implemented for this OS.)
$(info --------------------------------------------------------------------------------)
endif
endif
ifneq (,$(filter _0_,_$(BLAS)_))
ifeq (,$(filter _0_,_$(NOBLAS)_))
$(info BLAS dependency and fallback is removed!)
$(info --------------------------------------------------------------------------------)
endif
else ifeq (, $(filter _0_,_$(LNKSOFT)_))
$(info LIBXSMM is link-time agnostic with respect to a BLAS library!)
$(info Forcing a specific library can take away a user's choice.)
$(info If this was to solve linker errors (dgemm_, sgemm_, etc.),)
$(info the BLAS library should go after LIBXSMM (link-line).)
$(info --------------------------------------------------------------------------------)
endif
ifneq (,$(filter 0 1,$(INTRINSICS)))
ifeq (0,$(COMPATIBLE))
ifeq (0,$(INTEL))
$(info If adjusting INTRINSICS was necessary, consider updated GNU Binutils.)
else # Intel Compiler
$(info Intel Compiler does not usually require adjusting INTRINSICS.)
endif
$(info --------------------------------------------------------------------------------)
endif # COMPATIBLE
endif # INTRINSICS
ifneq (0,$(MSGJITPROFILING))
ifneq (,$(strip $(LIBJITPROFILING)))
$(info Intel VTune Amplifier support has been incorporated.)
else
$(info Intel VTune Amplifier support has been detected (enable with SYM=1).)
endif
$(info --------------------------------------------------------------------------------)
endif
.PHONY: libs
libs: clib flib elib noblas
.PHONY: lib
lib: libs
.PHONY: all
all: libxsmm
.PHONY: realall
realall: all samples
.PHONY: headers
headers: cheader cheader_only fheader
.PHONY: header-only
header-only: cheader_only
.PHONY: header_only
header_only: header-only
.PHONY: interface
interface: headers module
.PHONY: winterface
winterface: headers sources
PREFETCH_UID := 0
PREFETCH_TYPE := 0
PREFETCH_SCHEME := nopf
ifneq (Windows_NT,$(UNAME)) # TODO: full support for Windows calling convention
ifneq (0,$(shell echo "$$((0<=$(PREFETCH) && $(PREFETCH)<=6))"))
PREFETCH_UID := $(PREFETCH)
else ifneq (0,$(shell echo "$$((0>$(PREFETCH)))")) # auto
PREFETCH_UID := 1
else ifeq (pfsigonly,$(PREFETCH))
PREFETCH_UID := 2
else ifeq (BL2viaC,$(PREFETCH))
PREFETCH_UID := 3
else ifeq (curAL2,$(PREFETCH))
PREFETCH_UID := 4
else ifeq (curAL2_BL2viaC,$(PREFETCH))
PREFETCH_UID := 5
else ifeq (AL2,$(PREFETCH))
PREFETCH_UID := 6
else ifeq (AL2_BL2viaC,$(PREFETCH))
PREFETCH_UID := 7
endif
# Mapping build options to libxsmm_gemm_prefetch_type (see include/libxsmm_typedefs.h)
ifeq (1,$(PREFETCH_UID))
# Prefetch "auto" is a pseudo-strategy introduced by the frontend;
# select "nopf" for statically generated code.
PREFETCH_SCHEME := nopf
PREFETCH_TYPE := -1
else ifeq (2,$(PREFETCH_UID))
PREFETCH_SCHEME := pfsigonly
PREFETCH_TYPE := 1
else ifeq (3,$(PREFETCH_UID))
PREFETCH_SCHEME := BL2viaC
PREFETCH_TYPE := 4
else ifeq (4,$(PREFETCH_UID))
PREFETCH_SCHEME := curAL2
PREFETCH_TYPE := 8
else ifeq (5,$(PREFETCH_UID))
PREFETCH_SCHEME := curAL2_BL2viaC
PREFETCH_TYPE := $(shell echo "$$((4|8))")
else ifeq (6,$(PREFETCH_UID))
PREFETCH_SCHEME := AL2
PREFETCH_TYPE := 2
else ifeq (7,$(PREFETCH_UID))
PREFETCH_SCHEME := AL2_BL2viaC
PREFETCH_TYPE := $(shell echo "$$((4|2))")
endif
endif
# Mapping build options to libxsmm_gemm_flags (see include/libxsmm_typedefs.h)
#FLAGS := $(shell echo "$$((((0==$(ALPHA))*4) | ((0>$(ALPHA))*8) | ((0==$(BETA))*16) | ((0>$(BETA))*32)))")
FLAGS := 0
SUPPRESS_UNUSED_VARIABLE_WARNINGS := LIBXSMM_UNUSED(A); LIBXSMM_UNUSED(B); LIBXSMM_UNUSED(C);
ifneq (nopf,$(PREFETCH_SCHEME))
#SUPPRESS_UNUSED_VARIABLE_WARNINGS += LIBXSMM_UNUSED(A_prefetch); LIBXSMM_UNUSED(B_prefetch);
#SUPPRESS_UNUSED_PREFETCH_WARNINGS := $(NULL) LIBXSMM_UNUSED(C_prefetch);~
SUPPRESS_UNUSED_PREFETCH_WARNINGS := $(NULL) LIBXSMM_UNUSED(A_prefetch); LIBXSMM_UNUSED(B_prefetch); LIBXSMM_UNUSED(C_prefetch);~
endif
EXTCFLAGS := -DLIBXSMM_BUILD_EXT
ifneq (0,$(call qnum,$(OMP))) # NaN
DFLAGS += -DLIBXSMM_SYNC_OMP
else # default (no OpenMP based synchronization)
ifeq (,$(filter environment% override command%,$(origin OMP)))
EXTCFLAGS += $(OMPFLAG)
EXTLDFLAGS += $(OMPLIB)
endif
endif
# auto-clean
$(ROOTSRC)/template/libxsmm_config.h: $(ROOTSCR)/libxsmm_config.py $(ROOTSCR)/libxsmm_utilities.py \
$(ROOTDIR)/Makefile $(ROOTDIR)/Makefile.inc $(wildcard $(ROOTDIR)/.github/*) \
$(ROOTDIR)/version.txt
@-rm -f $(OUTDIR)/libxsmm*.$(SLIBEXT) $(OUTDIR)/libxsmm*.$(DLIBEXT)*
@-touch $@
.PHONY: config
config: $(INCDIR)/libxsmm_config.h $(INCDIR)/libxsmm_version.h
$(INCDIR)/libxsmm_config.h: $(ROOTSRC)/template/libxsmm_config.h $(DIRSTATE)/.state \
$(INCDIR)/utils/.make $(SRCDIR)/.make $(SCRDIR)/.make
$(information)
$(info --- LIBXSMM build log)
@if [ -e $(ROOTDIR)/.github/install.sh ]; then \
$(ROOTDIR)/.github/install.sh 2>/dev/null; \
fi
@$(CP) -r $(ROOTSCR) . 2>/dev/null || true
@$(CP) $(ROOTDIR)/Makefile.inc . 2>/dev/null || true
@$(CP) $(ROOTDIR)/.mktmp.sh . 2>/dev/null || true
@$(CP) $(ROOTDIR)/.flock.sh . 2>/dev/null || true
@$(CP) $(ROOTDIR)/.state.sh . 2>/dev/null || true
@$(CP) $(HEADERS_MAIN) $(INCDIR) 2>/dev/null || true
@$(CP) $(HEADERS_UTILS) $(INCDIR)/utils 2>/dev/null || true
@$(CP) $(SRCFILES) $(HEADERS_SRC) $(SRCDIR) 2>/dev/null || true
@$(PYTHON) $(ROOTSCR)/libxsmm_config.py $(ROOTSRC)/template/libxsmm_config.h \
$(MAKE_ILP64) $(CACHELINE) $(PRECISION) $(PREFETCH_TYPE) \
$(shell echo "$$((0<$(THRESHOLD)?$(THRESHOLD):0))") $(shell echo "$$(($(THREADS)+$(OMP)))") \
$(JIT) $(FLAGS) $(ALPHA) $(BETA) $(WRAP) $(MALLOC) $(INDICES) >$@
$(INCDIR)/libxsmm_version.h: $(ROOTSRC)/template/libxsmm_config.h $(INCDIR)/.make \
$(ROOTSRC)/template/libxsmm_version.h
@$(PYTHON) $(ROOTSCR)/libxsmm_config.py $(ROOTSRC)/template/libxsmm_version.h >$@
.PHONY: cheader
cheader: $(INCDIR)/libxsmm.h
$(INCDIR)/libxsmm.h: $(ROOTSCR)/libxsmm_interface.py \
$(ROOTSRC)/template/libxsmm.h \
$(INCDIR)/libxsmm_version.h \
$(INCDIR)/libxsmm_config.h \
$(HEADERS)
@$(PYTHON) $(ROOTSCR)/libxsmm_interface.py $(ROOTSRC)/template/libxsmm.h \
$(shell echo "$$(($(PRECISION)+($(call qnum,$(FORTRAN),2)<<2)))") $(PREFETCH_TYPE) $(INDICES) >$@
.PHONY: cheader_only
cheader_only: $(INCDIR)/libxsmm_source.h
$(INCDIR)/libxsmm_source.h: $(INCDIR)/.make $(ROOTSCR)/libxsmm_source.sh $(INCDIR)/libxsmm.h
@$(ROOTSCR)/libxsmm_source.sh >$@
.PHONY: fheader
fheader: $(INCDIR)/libxsmm.f
$(INCDIR)/libxsmm.f: $(ROOTSCR)/libxsmm_interface.py \
$(ROOTSCR)/libxsmm_config.py \
$(ROOTSRC)/template/libxsmm.f \
$(INCDIR)/libxsmm_version.h \
$(INCDIR)/libxsmm_config.h
@$(PYTHON) $(ROOTSCR)/libxsmm_interface.py $(ROOTSRC)/template/libxsmm.f \
$(shell echo "$$(($(PRECISION)+($(call qnum,$(FORTRAN),2)<<2)))") $(PREFETCH_TYPE) $(INDICES) \
| $(PYTHON) $(ROOTSCR)/libxsmm_config.py /dev/stdin \
$(MAKE_ILP64) $(CACHELINE) $(PRECISION) $(PREFETCH_TYPE) \
$(shell echo "$$((0<$(THRESHOLD)?$(THRESHOLD):0))") $(shell echo "$$(($(THREADS)+$(OMP)))") \
$(JIT) $(FLAGS) $(ALPHA) $(BETA) $(WRAP) $(MALLOC) $(INDICES) >$@
.PHONY: sources
sources: $(SRCFILES_KERNELS) $(BLDDIR)/libxsmm_dispatch.h
$(BLDDIR)/libxsmm_dispatch.h: $(BLDDIR)/.make $(SRCFILES_KERNELS) $(ROOTSCR)/libxsmm_dispatch.py $(DIRSTATE)/.state
@$(PYTHON) $(call quote,$(ROOTSCR)/libxsmm_dispatch.py) $(call qapath,$(DIRSTATE)/.state) $(PRECISION) $(THRESHOLD) $(INDICES) >$@
$(BLDDIR)/%.c: $(BLDDIR)/.make $(INCDIR)/libxsmm.h $(BINDIR)/libxsmm_gemm_generator $(ROOTSCR)/libxsmm_utilities.py $(ROOTSCR)/libxsmm_specialized.py
ifneq (,$(strip $(SRCFILES_KERNELS)))
$(eval MVALUE := $(shell echo $(basename $(notdir $@)) | cut -d_ -f2))
$(eval NVALUE := $(shell echo $(basename $(notdir $@)) | cut -d_ -f3))
$(eval KVALUE := $(shell echo $(basename $(notdir $@)) | cut -d_ -f4))
$(eval MNVALUE := $(MVALUE))
$(eval NMVALUE := $(NVALUE))
@echo "#include <libxsmm.h>" >$@
@echo >>$@
ifeq (noarch,$(GENTARGET))
ifneq (,$(CTARGET))
ifneq (2,$(PRECISION))
@echo "/*#define LIBXSMM_GENTARGET_knl_sp*/" >>$@
@echo "/*#define LIBXSMM_GENTARGET_hsw_sp*/" >>$@
@echo "/*#define LIBXSMM_GENTARGET_snb_sp*/" >>$@
@echo "/*#define LIBXSMM_GENTARGET_wsm_sp*/" >>$@
endif
ifneq (1,$(PRECISION))
@echo "/*#define LIBXSMM_GENTARGET_knl_dp*/" >>$@
@echo "/*#define LIBXSMM_GENTARGET_hsw_dp*/" >>$@
@echo "/*#define LIBXSMM_GENTARGET_snb_dp*/" >>$@
@echo "/*#define LIBXSMM_GENTARGET_wsm_dp*/" >>$@
endif
@echo >>$@
@echo >>$@
ifneq (2,$(PRECISION))
$(GENGEMM) dense $@ libxsmm_s$(basename $(notdir $@))_knl $(MNVALUE) $(NMVALUE) $(KVALUE) $(MNVALUE) $(KVALUE) $(MNVALUE) $(ALPHA) $(BETA) 0 0 knl $(PREFETCH_SCHEME) SP
$(GENGEMM) dense $@ libxsmm_s$(basename $(notdir $@))_hsw $(MNVALUE) $(NMVALUE) $(KVALUE) $(MNVALUE) $(KVALUE) $(MNVALUE) $(ALPHA) $(BETA) 0 0 hsw $(PREFETCH_SCHEME) SP
$(GENGEMM) dense $@ libxsmm_s$(basename $(notdir $@))_snb $(MNVALUE) $(NMVALUE) $(KVALUE) $(MNVALUE) $(KVALUE) $(MNVALUE) $(ALPHA) $(BETA) 0 0 snb $(PREFETCH_SCHEME) SP
$(GENGEMM) dense $@ libxsmm_s$(basename $(notdir $@))_wsm $(MNVALUE) $(NMVALUE) $(KVALUE) $(MNVALUE) $(KVALUE) $(MNVALUE) $(ALPHA) $(BETA) 0 0 wsm $(PREFETCH_SCHEME) SP
endif
ifneq (1,$(PRECISION))
$(GENGEMM) dense $@ libxsmm_d$(basename $(notdir $@))_knl $(MNVALUE) $(NMVALUE) $(KVALUE) $(MNVALUE) $(KVALUE) $(MNVALUE) $(ALPHA) $(BETA) 0 0 knl $(PREFETCH_SCHEME) DP
$(GENGEMM) dense $@ libxsmm_d$(basename $(notdir $@))_hsw $(MNVALUE) $(NMVALUE) $(KVALUE) $(MNVALUE) $(KVALUE) $(MNVALUE) $(ALPHA) $(BETA) 0 0 hsw $(PREFETCH_SCHEME) DP
$(GENGEMM) dense $@ libxsmm_d$(basename $(notdir $@))_snb $(MNVALUE) $(NMVALUE) $(KVALUE) $(MNVALUE) $(KVALUE) $(MNVALUE) $(ALPHA) $(BETA) 0 0 snb $(PREFETCH_SCHEME) DP
$(GENGEMM) dense $@ libxsmm_d$(basename $(notdir $@))_wsm $(MNVALUE) $(NMVALUE) $(KVALUE) $(MNVALUE) $(KVALUE) $(MNVALUE) $(ALPHA) $(BETA) 0 0 wsm $(PREFETCH_SCHEME) DP
endif
endif # target
else # noarch
ifneq (2,$(PRECISION))
@echo "/*#define LIBXSMM_GENTARGET_$(GENTARGET)_sp*/" >>$@
endif
ifneq (1,$(PRECISION))
@echo "/*#define LIBXSMM_GENTARGET_$(GENTARGET)_dp*/" >>$@
endif
@echo >>$@
@echo >>$@
ifneq (2,$(PRECISION))
$(GENGEMM) dense $@ libxsmm_s$(basename $(notdir $@))_$(GENTARGET) $(MNVALUE) $(NMVALUE) $(KVALUE) $(MNVALUE) $(KVALUE) $(MNVALUE) $(ALPHA) $(BETA) 0 0 $(GENTARGET) $(PREFETCH_SCHEME) SP
endif
ifneq (1,$(PRECISION))
$(GENGEMM) dense $@ libxsmm_d$(basename $(notdir $@))_$(GENTARGET) $(MNVALUE) $(NMVALUE) $(KVALUE) $(MNVALUE) $(KVALUE) $(MNVALUE) $(ALPHA) $(BETA) 0 0 $(GENTARGET) $(PREFETCH_SCHEME) DP
endif
endif # noarch
$(eval TMPFILE = $(shell $(MKTEMP) /tmp/.libxsmm_XXXXXX.mak))
@cat $@ | $(SED) \
-e "s/void libxsmm_/LIBXSMM_API_INLINE void libxsmm_/" \
-e "s/#ifndef NDEBUG/$(SUPPRESS_UNUSED_PREFETCH_WARNINGS)#ifdef LIBXSMM_NEVER_DEFINED/" \
-e "s/#pragma message (\".*KERNEL COMPILATION ERROR in: \" __FILE__)/ $(SUPPRESS_UNUSED_VARIABLE_WARNINGS)/" \
-e "/#error No kernel was compiled, lacking support for current architecture?/d" \
-e "/#pragma message (\".*KERNEL COMPILATION WARNING: compiling ..* code on ..* or newer architecture: \" __FILE__)/d" \
| tr "~" "\n" >$(TMPFILE)
@$(PYTHON) $(ROOTSCR)/libxsmm_specialized.py $(PRECISION) $(MVALUE) $(NVALUE) $(KVALUE) $(PREFETCH_TYPE) >>$(TMPFILE)
@$(MV) $(TMPFILE) $@
endif
define DEFINE_COMPILE_RULE
$(1): $(2) $(3) $(dir $(1))/.make
# @-rm -f $(1)
-$(CC) $(if $(filter 0,$(WERROR)),$(4),$(filter-out $(WERROR_CFLAG),$(4)) $(WERROR_CFLAG)) -c $(2) -o $(1)
@if ! [ -e $(1) ]; then \
if [ "2" = "$(INTRINSICS)" ]; then \
echo "--------------------------------------------------------------"; \
echo "In case of assembler error, perhaps GNU Binutils are outdated."; \
echo "See https://github.com/libxsmm/libxsmm#outdated-binutils"; \
echo "--------------------------------------------------------------"; \
fi; \
false; \
fi
endef
ifneq (0,$(GLIBC))
DFLAGS += -DLIBXSMM_BUILD=2
else
DFLAGS += -DLIBXSMM_BUILD=1
endif
# build rules that include target flags
$(eval $(call DEFINE_COMPILE_RULE,$(NOBLAS_OBJ),$(ROOTSRC)/libxsmm_ext.c,$(INCDIR)/libxsmm.h, \
$(CTARGET) $(NOBLAS_CFLAGS) $(NOBLAS_FLAGS) $(NOBLAS_IFLAGS) $(DNOBLAS)))
ifeq (0,$(CRAY))
$(foreach OBJ,$(OBJFILES_LIB),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ),$(patsubst %.o,$(ROOTSRC)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h $(BLDDIR)/libxsmm_dispatch.h, \
$(DFLAGS) $(IFLAGS) $(call applyif,1,libxsmm_main,$(OBJ),-I$(BLDDIR)) $(CTARGET) $(CFLAGS))))
else
$(foreach OBJ,$(filter-out $(BLDDIR)/intel64/libxsmm_mhd.o,$(OBJFILES_LIB)),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ),$(patsubst %.o,$(ROOTSRC)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h $(BLDDIR)/libxsmm_dispatch.h, \
$(DFLAGS) $(IFLAGS) $(call applyif,1,libxsmm_main,$(OBJ),-I$(BLDDIR)) $(CTARGET) $(CFLAGS))))
$(foreach OBJ,$(BLDDIR)/intel64/libxsmm_mhd.o,$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ),$(patsubst %.o,$(ROOTSRC)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h $(BLDDIR)/libxsmm_dispatch.h, \
$(DFLAGS) $(IFLAGS) $(CTARGET) $(patsubst $(OPTFLAGS),$(OPTFLAG1),$(CFLAGS)))))
endif
$(foreach OBJ,$(KRNOBJS),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ),$(patsubst %.o,$(BLDDIR)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h, \
$(DFLAGS) $(IFLAGS) $(CTARGET) $(CFLAGS))))
$(foreach OBJ,$(OBJFILES_EXT),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ),$(patsubst %.o,$(ROOTSRC)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h, \
$(DFLAGS) $(IFLAGS) $(CTARGET) $(EXTCFLAGS) $(CFLAGS))))
# build rules that by default include no target flags
ifneq (0,$(TGT))
TGT_FLAGS ?= $(CTARGET)
endif
$(foreach OBJ,$(OBJFILES_GEN_LIB),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ),$(patsubst %.o,$(ROOTSRC)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h, \
$(DFLAGS) $(IFLAGS) $(TGT_FLAGS) $(CFLAGS))))
$(foreach OBJ,$(OBJFILES_GEN_GEMM_BIN),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ),$(patsubst %.o,$(ROOTSRC)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h, \
$(DFLAGS) $(IFLAGS) $(TGT_FLAGS) $(CFLAGS))))
.PHONY: module
ifneq (,$(strip $(FC)))
module: $(INCDIR)/libxsmm.mod
$(BLDDIR)/intel64/libxsmm-mod.o: $(BLDDIR)/intel64/.make $(INCDIR)/libxsmm.f
$(FC) $(DFLAGS) $(IFLAGS) $(FCMTFLAGS) $(filter-out $(FFORM_FLAG),$(FCFLAGS)) $(FTARGET) \
-c $(INCDIR)/libxsmm.f -o $@ $(FMFLAGS) $(INCDIR)
$(INCDIR)/libxsmm.mod: $(BLDDIR)/intel64/libxsmm-mod.o
@if [ -e $(BLDDIR)/intel64/LIBXSMM.mod ]; then $(CP) $(BLDDIR)/intel64/LIBXSMM.mod $(INCDIR); fi
@if [ -e $(BLDDIR)/intel64/libxsmm.mod ]; then $(CP) $(BLDDIR)/intel64/libxsmm.mod $(INCDIR); fi
@if [ -e LIBXSMM.mod ]; then $(MV) LIBXSMM.mod $(INCDIR); fi
@if [ -e libxsmm.mod ]; then $(MV) libxsmm.mod $(INCDIR); fi
@-touch $@
else
.PHONY: $(BLDDIR)/intel64/libxsmm-mod.o
.PHONY: $(INCDIR)/libxsmm.mod
endif
.PHONY: build_generator_lib
build_generator_lib: $(OUTDIR)/libxsmmgen.$(SLIBEXT) $(OUTDIR)/libxsmmgen.$(DLIBEXT)
ifeq (,$(filter-out 0 2,$(BUILD)))
$(OUTDIR)/libxsmmgen.$(SLIBEXT): $(OBJFILES_GEN_LIB) $(OUTDIR)/libxsmm.env
$(MAKE_AR) $(OUTDIR)/libxsmmgen.$(SLIBEXT) $(OBJFILES_GEN_LIB)
else
.PHONY: $(OUTDIR)/libxsmmgen.$(SLIBEXT)
endif
ifeq (0,$(filter-out 1 2,$(BUILD))$(ANALYZE))
$(OUTDIR)/libxsmmgen.$(DLIBEXT): $(OBJFILES_GEN_LIB) $(OUTDIR)/libxsmm.env
$(LIB_SOLD) $(call solink,$(OUTDIR)/libxsmmgen.$(DLIBEXT),$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(OBJFILES_GEN_LIB) $(call cleanld,$(NOBLAS_LDFLAGS) $(NOBLAS_CLDFLAGS))
else
.PHONY: $(OUTDIR)/libxsmmgen.$(DLIBEXT)
endif
.PHONY: generator
generator: $(BINDIR)/libxsmm_gemm_generator
$(BINDIR)/libxsmm_gemm_generator: $(BINDIR)/.make $(OBJFILES_GEN_GEMM_BIN) $(OUTDIR)/libxsmmgen.$(LIBEXT)
$(LD) -o $@ $(OBJFILES_GEN_GEMM_BIN) $(call abslib,$(OUTDIR)/libxsmmgen.$(ILIBEXT)) \
$(call cleanld,$(NOBLAS_LDFLAGS) $(NOBLAS_CLDFLAGS))
ifneq (,$(strip $(LIBJITPROFILING)))
$(LIBJITPROFILING): $(BLDDIR)/jitprofiling/.make
@$(CP) $(VTUNEROOT)/lib64/libjitprofiling.$(SLIBEXT) $(BLDDIR)/jitprofiling
@cd $(BLDDIR)/jitprofiling; $(AR) x libjitprofiling.$(SLIBEXT)
JITPROFILINGOBJ := $(BLDDIR)/jitprofiling/jitprofiling.o
endif
.PHONY: clib
clib: $(OUTDIR)/libxsmm-static.pc $(OUTDIR)/libxsmm-shared.pc
ifeq (,$(filter-out 0 2,$(BUILD)))
$(OUTDIR)/libxsmm.$(SLIBEXT): $(OUTDIR)/.make $(OBJFILES_LIB) $(OBJFILES_GEN_LIB) $(KRNOBJS) $(LIBJITPROFILING)
$(MAKE_AR) $(OUTDIR)/libxsmm.$(SLIBEXT) $(call tailwords,$^) $(JITPROFILINGOBJ)
else
.PHONY: $(OUTDIR)/libxsmm.$(SLIBEXT)
endif
ifeq (0,$(filter-out 1 2,$(BUILD))$(ANALYZE))
$(OUTDIR)/libxsmm.$(DLIBEXT): $(OUTDIR)/.make $(OBJFILES_LIB) $(OBJFILES_GEN_LIB) $(KRNOBJS) $(LIBJITPROFILING)
$(LIB_SOLD) $(call solink,$(OUTDIR)/libxsmm.$(DLIBEXT),$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(call tailwords,$^) $(call cleanld,$(LDFLAGS) $(CLDFLAGS))
else
.PHONY: $(OUTDIR)/libxsmm.$(DLIBEXT)
endif
.PHONY: flib
ifneq (,$(strip $(FC)))
flib: $(OUTDIR)/libxsmmf-static.pc $(OUTDIR)/libxsmmf-shared.pc
ifeq (,$(filter-out 0 2,$(BUILD)))
$(OUTDIR)/libxsmmf.$(SLIBEXT): $(INCDIR)/libxsmm.mod $(OUTDIR)/libxsmm.$(DLIBEXT) $(OUTDIR)/libxsmmext.$(DLIBEXT)
$(MAKE_AR) $(OUTDIR)/libxsmmf.$(SLIBEXT) $(BLDDIR)/intel64/libxsmm-mod.o
else
.PHONY: $(OUTDIR)/libxsmmf.$(SLIBEXT)
endif
ifeq (0,$(filter-out 1 2,$(BUILD))$(ANALYZE))
$(OUTDIR)/libxsmmf.$(DLIBEXT): $(INCDIR)/libxsmm.mod $(OUTDIR)/libxsmm.$(DLIBEXT) $(OUTDIR)/libxsmmext.$(DLIBEXT)
ifneq (Darwin,$(UNAME))
$(LIB_SFLD) $(FCMTFLAGS) $(call solink,$(OUTDIR)/libxsmmf.$(DLIBEXT),$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(BLDDIR)/intel64/libxsmm-mod.o $(call abslib,$(OUTDIR)/libxsmm.$(ILIBEXT)) \
$(call cleanld,$(LDFLAGS) $(FLDFLAGS))
else ifneq (0,$(LNKSOFT)) # macOS
$(LIB_SFLD) $(FCMTFLAGS) $(call solink,$(OUTDIR)/libxsmmf.$(DLIBEXT),$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(BLDDIR)/intel64/libxsmm-mod.o $(call abslib,$(OUTDIR)/libxsmm.$(ILIBEXT)) \
$(call cleanld,$(LDFLAGS) $(FLDFLAGS)) $(call linkopt,-U,_libxsmm_gemm_batch_omp_)
else # macOS
$(LIB_SFLD) $(FCMTFLAGS) $(call solink,$(OUTDIR)/libxsmmf.$(DLIBEXT),$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(BLDDIR)/intel64/libxsmm-mod.o $(call abslib,$(OUTDIR)/libxsmmext.$(ILIBEXT)) $(call abslib,$(OUTDIR)/libxsmm.$(ILIBEXT)) \
$(call cleanld,$(LDFLAGS) $(FLDFLAGS))
endif
else
.PHONY: $(OUTDIR)/libxsmmf.$(DLIBEXT)
endif
else
.PHONY: $(OUTDIR)/libxsmmf.$(SLIBEXT) $(OUTDIR)/libxsmmf.$(DLIBEXT)
endif
.PHONY: elib
elib: $(OUTDIR)/libxsmmext-static.pc $(OUTDIR)/libxsmmext-shared.pc
ifeq (,$(filter-out 0 2,$(BUILD)))
$(OUTDIR)/libxsmmext.$(SLIBEXT): $(OUTDIR)/libxsmm.$(DLIBEXT) $(OBJFILES_EXT)
$(MAKE_AR) $(OUTDIR)/libxsmmext.$(SLIBEXT) $(OBJFILES_EXT)
else
.PHONY: $(OUTDIR)/libxsmmext.$(SLIBEXT)
endif
ifeq (0,$(filter-out 1 2,$(BUILD))$(ANALYZE))
$(OUTDIR)/libxsmmext.$(DLIBEXT): $(OUTDIR)/libxsmm.$(DLIBEXT) $(OBJFILES_EXT)
$(LIB_SOLD) $(EXTLDFLAGS) $(call solink,$(OUTDIR)/libxsmmext.$(DLIBEXT),$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(OBJFILES_EXT) $(call abslib,$(OUTDIR)/libxsmm.$(ILIBEXT)) $(call cleanld,$(LDFLAGS) $(CLDFLAGS))
else
.PHONY: $(OUTDIR)/libxsmmext.$(DLIBEXT)
endif
.PHONY: noblas
noblas: $(OUTDIR)/libxsmmnoblas-static.pc $(OUTDIR)/libxsmmnoblas-shared.pc
ifeq (,$(filter-out 0 2,$(BUILD)))
$(OUTDIR)/libxsmmnoblas.$(SLIBEXT): $(NOBLAS_OBJ)
$(MAKE_AR) $(OUTDIR)/libxsmmnoblas.$(SLIBEXT) $(NOBLAS_OBJ)
else
.PHONY: $(OUTDIR)/libxsmmnoblas.$(SLIBEXT)
endif
ifeq (0,$(filter-out 1 2,$(BUILD))$(ANALYZE))
$(OUTDIR)/libxsmmnoblas.$(DLIBEXT): $(NOBLAS_OBJ)
$(LIB_SOLD) $(call solink,$(OUTDIR)/libxsmmnoblas.$(DLIBEXT),$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(NOBLAS_OBJ) $(call cleanld,$(NOBLAS_LDFLAGS) $(NOBLAS_CLDFLAGS))
else
.PHONY: $(OUTDIR)/libxsmmnoblas.$(DLIBEXT)
endif
# use dir not qdir to avoid quotes; also $(ROOTDIR)/$(SPLDIR) is relative
DIRS_SAMPLES := $(dir $(shell find $(ROOTDIR)/$(SPLDIR) -type f -name Makefile \
| grep -v /deeplearning/embbag_distri/ \
| grep -v /deeplearning/sparse_adagrad_fused/ \
| grep -v /encoder/ \
$(NULL)))
.PHONY: samples $(DIRS_SAMPLES)
samples: $(DIRS_SAMPLES)
$(DIRS_SAMPLES): libs
@$(FLOCK) $@ "$(MAKE)"
.PHONY: cp2k
cp2k: libs
@$(FLOCK) $(ROOTDIR)/$(SPLDIR)/cp2k "$(MAKE) --no-print-directory"
.PHONY: nek
nek: libs
@$(FLOCK) $(ROOTDIR)/$(SPLDIR)/nek "$(MAKE) --no-print-directory"
.PHONY: smm
smm: libs
@$(FLOCK) $(ROOTDIR)/$(UTLDIR)/smmbench "$(MAKE) --no-print-directory"
.PHONY: specfem
specfem: libs
@$(FLOCK) $(ROOTDIR)/$(SPLDIR)/specfem "$(MAKE) --no-print-directory"
$(ROOTDIR)/$(SPLDIR)/cp2k/cp2k-perf.sh: $(ROOTDIR)/$(SPLDIR)/cp2k/.make $(ROOTDIR)/Makefile
@echo "#!/usr/bin/env sh" >$@
@echo >>$@
@echo "HERE=\$$(cd \$$(dirname \$$0); pwd -P)" >>$@
@echo "FILE=cp2k-perf.txt" >>$@
ifneq (,$(strip $(INDICES)))
@echo "RUNS=\"$(INDICES)\"" >>$@
else
@echo "RUNS=\"23_23_23 4_6_9 13_5_7 24_3_36\"" >>$@
endif
@echo >>$@
@echo "if [ \"\" != \"\$$1\" ]; then" >>$@
@echo " FILE=\$$1" >>$@
@echo " shift" >>$@
@echo "fi" >>$@
@echo "if [ \"\" != \"\$$1\" ]; then" >>$@
@echo " SIZE=\$$1" >>$@
@echo " shift" >>$@
@echo "else" >>$@
@echo " SIZE=0" >>$@
@echo "fi" >>$@
@echo "cat /dev/null >\$${FILE}" >>$@
@echo >>$@
@echo "NRUN=1" >>$@
@echo "NMAX=\$$(echo \$${RUNS} | wc -w | tr -d ' ')" >>$@
@echo "for RUN in \$${RUNS}; do" >>$@
@echo " MVALUE=\$$(echo \$${RUN} | cut -d_ -f1)" >>$@
@echo " NVALUE=\$$(echo \$${RUN} | cut -d_ -f2)" >>$@
@echo " KVALUE=\$$(echo \$${RUN} | cut -d_ -f3)" >>$@
@echo " >&2 echo -n \"\$${NRUN} of \$${NMAX} (M=\$${MVALUE} N=\$${NVALUE} K=\$${KVALUE})... \"" >>$@
@echo " ERROR=\$$({ CHECK=1 \$${HERE}/cp2k-dbcsr \$${MVALUE} \$${SIZE} 0 \$${NVALUE} \$${KVALUE} >>\$${FILE}; } 2>&1)" >>$@
@echo " RESULT=\$$?" >>$@
@echo " if [ 0 != \$${RESULT} ]; then" >>$@
@echo " echo \"FAILED(\$${RESULT}) \$${ERROR}\"" >>$@
@echo " exit 1" >>$@
@echo " else" >>$@
@echo " echo \"OK \$${ERROR}\"" >>$@
@echo " fi" >>$@
@echo " echo >>\$${FILE}" >>$@
@echo " NRUN=\$$((NRUN+1))" >>$@
@echo "done" >>$@
@echo >>$@
@chmod +x $@
$(ROOTDIR)/$(UTLDIR)/smmbench/smmf-perf.sh: $(ROOTDIR)/$(UTLDIR)/smmbench/.make $(ROOTDIR)/Makefile
@echo "#!/usr/bin/env sh" >$@
@echo >>$@
@echo "HERE=\$$(cd \$$(dirname \$$0); pwd -P)" >>$@
@echo "FILE=\$${HERE}/smmf-perf.txt" >>$@
ifneq (,$(strip $(INDICES)))
@echo "RUNS=\"$(INDICES)\"" >>$@
else
@echo "RUNS=\"23_23_23 4_6_9 13_5_7 24_3_36\"" >>$@
endif
@echo >>$@
@echo "if [ \"\" != \"\$$1\" ]; then" >>$@
@echo " FILE=\$$1" >>$@
@echo " shift" >>$@
@echo "fi" >>$@
@echo "cat /dev/null >\$${FILE}" >>$@
@echo >>$@
@echo "NRUN=1" >>$@
@echo "NMAX=\$$(echo \$${RUNS} | wc -w | tr -d ' ')" >>$@
@echo "for RUN in \$${RUNS}; do" >>$@
@echo " MVALUE=\$$(echo \$${RUN} | cut -d_ -f1)" >>$@
@echo " NVALUE=\$$(echo \$${RUN} | cut -d_ -f2)" >>$@
@echo " KVALUE=\$$(echo \$${RUN} | cut -d_ -f3)" >>$@