forked from libxsmm/libxsmm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
1837 lines (1683 loc) · 69.4 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)))/)
INCDIR := include
SCRDIR := scripts
TSTDIR := tests
BLDDIR := obj
SRCDIR := src
OUTDIR := lib
BINDIR := bin
SPLDIR := samples
DOCDIR := documentation
# subdirectories (relative) to PREFIX (install targets)
PINCDIR ?= $(INCDIR)
PSRCDIR ?= $(PINCDIR)/libxsmm
POUTDIR ?= $(OUTDIR)
PPKGDIR ?= $(OUTDIR)
PMODDIR ?= $(OUTDIR)
PBINDIR ?= $(BINDIR)
PTSTDIR ?= $(TSTDIR)
PDOCDIR ?= share/libxsmm
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/hfp/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
# 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: shared libraries files suitable for dynamic linkage
# 1: library archives suitable for static linkage
STATIC ?= 1
# 0: link all dependencies as specified for the target
# 1: attempt to avoid dependencies if not referenced
ASNEEDED ?= 0
# 0: build according to the value of STATIC
# 1: build according to STATIC=0 and STATIC=1
SHARED ?= 0
# -1: support intercepted malloc (disabled at runtime by default)
# 0: disable intercepted malloc at compile-time
# >0: enable intercepted malloc
MALLOC ?= 0
# 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 PDOCDIR SCRDIR SPLDIR \
SRCDIR TEST VERSION_STRING DEPSTATIC ALIAS_% BLAS %_TARGET %ROOT MPSS KNC
# 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
# include common Makefile artifacts
include $(ROOTDIR)/Makefile.inc
# 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,$(ROOTDIR)/$(SRCDIR))
ifeq (,$(PYTHON))
$(info --------------------------------------------------------------------------------)
$(error No Python interpreter found)
endif
# Version numbers according to interface (version.txt)
VERSION_MAJOR ?= $(shell $(PYTHON) $(ROOTDIR)/$(SCRDIR)/libxsmm_utilities.py 1)
VERSION_MINOR ?= $(shell $(PYTHON) $(ROOTDIR)/$(SCRDIR)/libxsmm_utilities.py 2)
VERSION_UPDATE ?= $(shell $(PYTHON) $(ROOTDIR)/$(SCRDIR)/libxsmm_utilities.py 3)
VERSION_STRING ?= $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_UPDATE)
VERSION_API ?= $(shell $(PYTHON) $(ROOTDIR)/$(SCRDIR)/libxsmm_utilities.py 0 $(VERSION_STRING))
VERSION_ALL ?= $(shell $(PYTHON) $(ROOTDIR)/$(SCRDIR)/libxsmm_utilities.py)
VERSION_RELEASED ?= $(shell $(PYTHON) $(ROOTDIR)/$(SCRDIR)/libxsmm_utilities.py -1 $(VERSION_ALL))
VERSION_RELEASE ?= HEAD
VERSION_PACKAGE ?= 1
# explicitly target all objects
ifneq (,$(strip $(SSE)$(AVX)$(MIC)))
TGT ?= 1
endif
TGT ?= 0
ifeq (0,$(BLAS))
ifeq (0,$(STATIC))
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
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))
ifneq (0,$(MIC))
ifeq (2,$(MIC))
GENTARGET := knm
else
GENTARGET := knl
endif
else
GENTARGET := skx
endif
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) $(ROOTDIR)/$(SCRDIR)/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_HST := $(patsubst %,$(BLDDIR)/intel64/mm_%.o,$(INDICES))
KRNOBJS_MIC := $(patsubst %,$(BLDDIR)/mic/mm_%.o,$(INDICES))
HEADERS := $(wildcard $(ROOTDIR)/$(SRCDIR)/template/*.c) $(wildcard $(ROOTDIR)/$(SRCDIR)/*.h) \
$(ROOTDIR)/$(SRCDIR)/libxsmm_hash.c \
$(ROOTDIR)/include/libxsmm_cpuid.h \
$(ROOTDIR)/include/libxsmm_dnn.h \
$(ROOTDIR)/include/libxsmm_dnn_tensor.h \
$(ROOTDIR)/include/libxsmm_dnn_convolution.h \
$(ROOTDIR)/include/libxsmm_dnn_fusedbatchnorm.h \
$(ROOTDIR)/include/libxsmm_dnn_fusedgroupnorm.h \
$(ROOTDIR)/include/libxsmm_dnn_pooling.h \
$(ROOTDIR)/include/libxsmm_dnn_fullyconnected.h \
$(ROOTDIR)/include/libxsmm_dnn_rnncell.h \
$(ROOTDIR)/include/libxsmm_dnn_softmaxloss.h \
$(ROOTDIR)/include/libxsmm_dnn_optimizer.h \
$(ROOTDIR)/include/libxsmm_rng.h \
$(ROOTDIR)/include/libxsmm_frontend.h \
$(ROOTDIR)/include/libxsmm_fsspmdm.h \
$(ROOTDIR)/include/libxsmm_generator.h \
$(ROOTDIR)/include/libxsmm_intrinsics_x86.h \
$(ROOTDIR)/include/libxsmm_macros.h \
$(ROOTDIR)/include/libxsmm_malloc.h \
$(ROOTDIR)/include/libxsmm_math.h \
$(ROOTDIR)/include/libxsmm_memory.h \
$(ROOTDIR)/include/libxsmm_mhd.h \
$(ROOTDIR)/include/libxsmm_spmdm.h \
$(ROOTDIR)/include/libxsmm_sync.h \
$(ROOTDIR)/include/libxsmm_timer.h \
$(ROOTDIR)/include/libxsmm_typedefs.h
SRCFILES_LIB := $(patsubst %,$(ROOTDIR)/$(SRCDIR)/%, \
libxsmm_main.c libxsmm_memory.c libxsmm_malloc.c libxsmm_hash.c libxsmm_math.c \
libxsmm_sync.c libxsmm_python.c libxsmm_mhd.c libxsmm_timer.c libxsmm_perf.c \
libxsmm_gemm.c libxsmm_xcopy.c libxsmm_spmdm.c libxsmm_fsspmdm.c libxsmm_rng.c\
libxsmm_dnn.c libxsmm_dnn_tensor.c libxsmm_dnn_convolution.c libxsmm_dnn_elementwise.c \
libxsmm_dnn_rnncell.c libxsmm_dnn_rnncell_forward.c libxsmm_dnn_rnncell_backward_weight_update.c \
libxsmm_dnn_fusedbatchnorm.c libxsmm_dnn_fusedbatchnorm_forward.c libxsmm_dnn_fusedbatchnorm_backward.c \
libxsmm_dnn_fusedgroupnorm.c libxsmm_dnn_fusedgroupnorm_forward.c libxsmm_dnn_fusedgroupnorm_backward.c \
libxsmm_dnn_pooling.c libxsmm_dnn_pooling_forward.c libxsmm_dnn_pooling_backward.c libxsmm_dnn_convolution_forward.c \
libxsmm_dnn_fullyconnected.c libxsmm_dnn_fullyconnected_forward.c libxsmm_dnn_fullyconnected_backward_weight_update.c \
libxsmm_dnn_convolution_backward.c libxsmm_dnn_convolution_weight_update.c libxsmm_dnn_softmaxloss.c \
libxsmm_dnn_softmaxloss_forward.c libxsmm_dnn_softmaxloss_backward.c libxsmm_dnn_optimizer.c libxsmm_dnn_optimizer_sgd.c )
SRCFILES_GEN_LIB := $(patsubst %,$(ROOTDIR)/$(SRCDIR)/%,$(notdir $(wildcard $(ROOTDIR)/$(SRCDIR)/generator_*.c)) \
libxsmm_cpuid_arm.c libxsmm_cpuid_x86.c libxsmm_generator.c libxsmm_trace.c libxsmm_matrixeqn.c)
SRCFILES_GEN_GEMM_BIN := $(patsubst %,$(ROOTDIR)/$(SRCDIR)/%,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_HST := $(patsubst %,$(BLDDIR)/intel64/%.o,$(basename $(notdir $(SRCFILES_LIB))))
OBJFILES_MIC := $(patsubst %,$(BLDDIR)/mic/%.o,$(basename $(notdir $(SRCFILES_LIB)))) $(BLDDIR)/mic/generator_common.o
EXTOBJS_HST := $(BLDDIR)/intel64/libxsmm_ext.o \
$(BLDDIR)/intel64/libxsmm_ext_xcopy.o \
$(BLDDIR)/intel64/libxsmm_ext_gemm.o
EXTOBJS_MIC := $(BLDDIR)/mic/libxsmm_ext.o \
$(BLDDIR)/mic/libxsmm_ext_xcopy.o \
$(BLDDIR)/mic/libxsmm_ext_gemm.o
NOBLAS_HST := $(BLDDIR)/intel64/libxsmm_noblas.o
NOBLAS_MIC := $(BLDDIR)/mic/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_HST) $(OBJFILES_MIC) \
$(KRNOBJS_HST) $(KRNOBJS_MIC) $(EXTOBJS_HST) $(EXTOBJS_MIC) $(NOBLAS_HST) $(NOBLAS_MIC)
ifneq (,$(strip $(FC)))
FTNOBJS := $(BLDDIR)/intel64/libxsmm-mod.o $(BLDDIR)/mic/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)
OBJJITPROFILING := $(BLDDIR)/jitprofiling/*.o
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))
ifeq (0,$(SHARED))
libxsmm: lib generator
else
libxsmm: libs generator
endif
else
ifeq (0,$(SHARED))
libxsmm: lib
else
libxsmm: libs
endif
endif
$(information)
ifneq (,$(filter _0_,_$(LNKSOFT)_))
ifeq (0,$(DEPSTATIC))
$(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: lib
lib: headers drytest lib_hst lib_mic
.PHONY: libs
libs: lib
ifneq (0,$(STATIC))
@$(MAKE) --no-print-directory lib STATIC=0
else
@$(MAKE) --no-print-directory lib STATIC=1
endif
.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
.PHONY: lib_mic
lib_mic: clib_mic flib_mic ext_mic noblas_mic
.PHONY: lib_hst
lib_hst: clib_hst flib_hst ext_hst noblas_hst
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
ifeq (,$(PREFETCH_SCHEME_MIC)) # adopt host scheme
PREFETCH_SCHEME_MIC := $(PREFETCH_SCHEME)
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 the co-build
$(ROOTDIR)/$(SRCDIR)/template/libxsmm_config.h: $(ROOTDIR)/$(SCRDIR)/libxsmm_config.py $(ROOTDIR)/$(SCRDIR)/libxsmm_utilities.py \
$(ROOTDIR)/Makefile $(ROOTDIR)/Makefile.inc $(wildcard $(ROOTDIR)/.github/*) \
$(ROOTDIR)/version.txt
#ifneq (,$(filter-out 0 1 2 STATIC,$(words $(PRESTATE)) $(word 2,$(PRESTATE))))
ifneq (0,$(STATIC)) # static
@rm -f $(OUTDIR)/libxsmm*.$(DLIBEXT) $(OUTDIR)/libxsmm*.$(DLIBEXT).*
else # shared/dynamic
@rm -f $(OUTDIR)/libxsmm*.$(SLIBEXT) $(OUTDIR)/libxsmm*.$(SLIBEXT).*
endif
@touch $@
#endif
.PHONY: config
config: $(INCDIR)/libxsmm_config.h $(INCDIR)/libxsmm_version.h
$(INCDIR)/libxsmm_config.h: $(INCDIR)/.make $(ROOTDIR)/$(SRCDIR)/template/libxsmm_config.h $(DIRSTATE)/.state
$(information)
$(info --- LIBXSMM build log)
@if [ -e $(ROOTDIR)/.github/install.sh ]; then \
$(ROOTDIR)/.github/install.sh 2>/dev/null; \
fi
@$(CP) $(filter $(ROOTDIR)/include/%.h,$(HEADERS)) $(INCDIR) 2>/dev/null || true
@$(PYTHON) $(ROOTDIR)/$(SCRDIR)/libxsmm_config.py $(ROOTDIR)/$(SRCDIR)/template/libxsmm_config.h \
$(MAKE_ILP64) $(OFFLOAD) $(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: $(ROOTDIR)/$(SRCDIR)/template/libxsmm_config.h $(INCDIR)/.make \
$(ROOTDIR)/$(SRCDIR)/template/libxsmm_version.h
@$(PYTHON) $(ROOTDIR)/$(SCRDIR)/libxsmm_config.py $(ROOTDIR)/$(SRCDIR)/template/libxsmm_version.h > $@
.PHONY: cheader
cheader: $(INCDIR)/libxsmm.h
$(INCDIR)/libxsmm.h: $(ROOTDIR)/$(SCRDIR)/libxsmm_interface.py \
$(ROOTDIR)/$(SRCDIR)/template/libxsmm.h \
$(INCDIR)/libxsmm_version.h \
$(INCDIR)/libxsmm_config.h \
$(HEADERS)
@$(PYTHON) $(ROOTDIR)/$(SCRDIR)/libxsmm_interface.py $(ROOTDIR)/$(SRCDIR)/template/libxsmm.h \
$(shell echo "$$(($(PRECISION)+($(FORTRAN)<<2)))") $(PREFETCH_TYPE) $(INDICES) > $@
.PHONY: cheader_only
cheader_only: $(INCDIR)/libxsmm_source.h
$(INCDIR)/libxsmm_source.h: $(INCDIR)/.make $(ROOTDIR)/$(SCRDIR)/libxsmm_source.sh $(INCDIR)/libxsmm.h
@$(ROOTDIR)/$(SCRDIR)/libxsmm_source.sh > $@
.PHONY: fheader
fheader: $(INCDIR)/libxsmm.f
$(INCDIR)/libxsmm.f: $(ROOTDIR)/$(SCRDIR)/libxsmm_interface.py \
$(ROOTDIR)/$(SCRDIR)/libxsmm_config.py \
$(ROOTDIR)/$(SRCDIR)/template/libxsmm.f \
$(INCDIR)/libxsmm_version.h \
$(INCDIR)/libxsmm_config.h
@$(PYTHON) $(ROOTDIR)/$(SCRDIR)/libxsmm_interface.py $(ROOTDIR)/$(SRCDIR)/template/libxsmm.f \
$(shell echo "$$(($(PRECISION)+($(FORTRAN)<<2)))") $(PREFETCH_TYPE) $(INDICES) | \
$(PYTHON) $(ROOTDIR)/$(SCRDIR)/libxsmm_config.py /dev/stdin \
$(MAKE_ILP64) $(OFFLOAD) $(CACHELINE) $(PRECISION) $(PREFETCH_TYPE) \
$(shell echo "$$((0<$(THRESHOLD)?$(THRESHOLD):0))") $(shell echo "$$(($(THREADS)+$(OMP)))") \
$(JIT) $(FLAGS) $(ALPHA) $(BETA) $(WRAP) $(MALLOC) $(INDICES) | \
sed "/ATTRIBUTES OFFLOAD:MIC/d" > $@
.PHONY: sources
sources: $(SRCFILES_KERNELS) $(BLDDIR)/libxsmm_dispatch.h
$(BLDDIR)/libxsmm_dispatch.h: $(BLDDIR)/.make $(SRCFILES_KERNELS) $(ROOTDIR)/$(SCRDIR)/libxsmm_dispatch.py $(DIRSTATE)/.state
@$(PYTHON) $(call quote,$(ROOTDIR)/$(SCRDIR)/libxsmm_dispatch.py) $(call qapath,$(DIRSTATE)/.state) $(PRECISION) $(THRESHOLD) $(INDICES) > $@
$(BLDDIR)/%.c: $(BLDDIR)/.make $(INCDIR)/libxsmm.h $(BINDIR)/libxsmm_gemm_generator $(ROOTDIR)/$(SCRDIR)/libxsmm_utilities.py $(ROOTDIR)/$(SCRDIR)/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_INLINE LIBXSMM_RETARGETABLE 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) $(ROOTDIR)/$(SCRDIR)/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) $(4) $(if $(filter 0,$(WERROR)),$(NULL),$(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/hfp/libxsmm#outdated-binutils"; \
echo "--------------------------------------------------------------"; \
fi; \
false; \
fi
endef
ifneq (0,$(GLIBC))
DFLAGS += -DLIBXSMM_BUILD=2
else
DFLAGS += -DLIBXSMM_BUILD=1
endif
ifneq (0,$(MIC))
ifneq (0,$(MPSS))
$(foreach OBJ,$(OBJFILES_MIC),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ), $(patsubst %.o,$(ROOTDIR)/$(SRCDIR)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h $(BLDDIR)/libxsmm_dispatch.h,-mmic \
$(DFLAGS) $(IFLAGS) $(call applyif,1,libxsmm_main,$(OBJ),-I$(BLDDIR)) $(CFLAGS))))
$(foreach OBJ,$(KRNOBJS_MIC),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ), $(patsubst %.o,$(BLDDIR)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h,-mmic \
$(DFLAGS) $(IFLAGS) $(CFLAGS))))
$(foreach OBJ,$(EXTOBJS_MIC),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ), $(patsubst %.o,$(ROOTDIR)/$(SRCDIR)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h,-mmic \
$(DFLAGS) $(IFLAGS) $(EXTCFLAGS) $(CFLAGS))))
$(eval $(call DEFINE_COMPILE_RULE,$(NOBLAS_MIC),$(ROOTDIR)/$(SRCDIR)/libxsmm_ext.c,$(INCDIR)/libxsmm.h,-mmic \
$(NOBLAS_CFLAGS) $(NOBLAS_FLAGS) $(NOBLAS_IFLAGS) $(DNOBLAS)))
endif
endif
# build rules that include target flags
$(eval $(call DEFINE_COMPILE_RULE,$(NOBLAS_HST),$(ROOTDIR)/$(SRCDIR)/libxsmm_ext.c,$(INCDIR)/libxsmm.h, \
$(CTARGET) $(NOBLAS_CFLAGS) $(NOBLAS_FLAGS) $(NOBLAS_IFLAGS) $(DNOBLAS)))
$(foreach OBJ,$(OBJFILES_HST),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ),$(patsubst %.o,$(ROOTDIR)/$(SRCDIR)/%.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,$(KRNOBJS_HST),$(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,$(EXTOBJS_HST),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ),$(patsubst %.o,$(ROOTDIR)/$(SRCDIR)/%.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,$(ROOTDIR)/$(SRCDIR)/%.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,$(ROOTDIR)/$(SRCDIR)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h, \
$(DFLAGS) $(IFLAGS) $(TGT_FLAGS) $(CFLAGS))))
.PHONY: module_mic
ifneq (0,$(MIC))
ifneq (0,$(MPSS))
ifneq (,$(strip $(FC)))
module_mic: $(INCDIR)/mic/libxsmm.mod
$(BLDDIR)/mic/libxsmm-mod.o: $(BLDDIR)/mic/.make $(INCDIR)/mic/.make $(INCDIR)/libxsmm.f
$(FC) $(DFLAGS) $(IFLAGS) $(FCMTFLAGS) $(FCFLAGS) -mmic -c $(INCDIR)/libxsmm.f -o $@ $(FMFLAGS) $(INCDIR)/mic
$(INCDIR)/mic/libxsmm.mod: $(BLDDIR)/mic/libxsmm-mod.o
@if [ -e $(BLDDIR)/mic/LIBXSMM.mod ]; then $(CP) $(BLDDIR)/mic/LIBXSMM.mod $(INCDIR); fi
@if [ -e $(BLDDIR)/mic/libxsmm.mod ]; then $(CP) $(BLDDIR)/mic/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)/mic/libxsmm-mod.o
.PHONY: $(INCDIR)/mic/libxsmm.mod
endif
else
.PHONY: $(BLDDIR)/mic/libxsmm-mod.o
.PHONY: $(INCDIR)/mic/libxsmm.mod
endif
else
.PHONY: $(BLDDIR)/mic/libxsmm-mod.o
.PHONY: $(INCDIR)/mic/libxsmm.mod
endif
.PHONY: module_hst
ifneq (,$(strip $(FC)))
module_hst: $(INCDIR)/libxsmm.mod
$(BLDDIR)/intel64/libxsmm-mod.o: $(BLDDIR)/intel64/.make $(INCDIR)/libxsmm.f
$(FC) $(DFLAGS) $(IFLAGS) $(FCMTFLAGS) $(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: module
module: module_hst module_mic
.PHONY: build_generator_lib
build_generator_lib: $(OUTDIR)/libxsmmgen.$(LIBEXT)
$(OUTDIR)/libxsmmgen.$(LIBEXT): $(OBJFILES_GEN_LIB) $(OUTDIR)/libxsmm.env
ifeq (0,$(STATIC))
$(LIB_LD) $(call solink,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(OBJFILES_GEN_LIB) $(call cleanld,$(NOBLAS_LDFLAGS) $(NOBLAS_CLDFLAGS))
else # static
@rm -f $@
$(AR) -rs $@ $(OBJFILES_GEN_LIB)
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)
endif
.PHONY: clib_mic
ifneq (0,$(MIC))
ifneq (0,$(MPSS))
clib_mic: $(OUTDIR)/mic/libxsmm.$(LIBEXT)
$(OUTDIR)/mic/libxsmm.$(LIBEXT): $(OUTDIR)/mic/.make $(OBJFILES_MIC) $(KRNOBJS_MIC)
ifeq (0,$(STATIC))
$(LIB_LD) -mmic $(call solink,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(OBJFILES_MIC) $(KRNOBJS_MIC) $(call cleanld,$(LDFLAGS) $(CLDFLAGS))
else # static
@rm -f $@
$(AR) -rs $@ $(OBJFILES_MIC) $(KRNOBJS_MIC)
endif
endif
endif
.PHONY: clib_hst
clib_hst: $(OUTDIR)/libxsmm.pc
$(OUTDIR)/libxsmm.$(LIBEXT): $(OUTDIR)/.make $(OBJFILES_HST) $(OBJFILES_GEN_LIB) $(KRNOBJS_HST) $(LIBJITPROFILING)
ifeq (0,$(STATIC))
$(LIB_LD) $(call solink,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(OBJFILES_HST) $(OBJFILES_GEN_LIB) $(KRNOBJS_HST) $(LIBJITPROFILING) $(call cleanld,$(LDFLAGS) $(CLDFLAGS))
else # static
@rm -f $@
$(AR) -rs $@ $(OBJFILES_HST) $(OBJFILES_GEN_LIB) $(KRNOBJS_HST) $(OBJJITPROFILING)
endif
.PHONY: flib_mic
ifneq (0,$(MIC))
ifneq (0,$(MPSS))
ifneq (,$(strip $(FC)))
flib_mic: $(OUTDIR)/mic/libxsmmf.$(LIBEXT)
$(OUTDIR)/mic/libxsmmf.$(LIBEXT): $(INCDIR)/mic/libxsmm.mod $(OUTDIR)/mic/libxsmm.$(LIBEXT)
ifeq (0,$(STATIC))
$(LIB_FLD) -mmic $(FCMTFLAGS) $(call solink,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(BLDDIR)/mic/libxsmm-mod.o $(call abslib,$(OUTDIR)/mic/libxsmm.$(ILIBEXT)) $(call cleanld,$(LDFLAGS) $(FLDFLAGS))
else # static
@rm -f $@
$(AR) -rs $@ $(BLDDIR)/mic/libxsmm-mod.o
endif
else
.PHONY: $(OUTDIR)/mic/libxsmmf.$(LIBEXT)
endif
endif
endif
.PHONY: flib_hst
ifneq (,$(strip $(FC)))
flib_hst: $(OUTDIR)/libxsmmf.pc
$(OUTDIR)/libxsmmf.$(LIBEXT): $(INCDIR)/libxsmm.mod $(OUTDIR)/libxsmm.$(LIBEXT)
ifeq (0,$(STATIC))
$(LIB_FLD) $(FCMTFLAGS) $(call solink,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(BLDDIR)/intel64/libxsmm-mod.o $(call abslib,$(OUTDIR)/libxsmm.$(ILIBEXT)) $(call cleanld,$(LDFLAGS) $(FLDFLAGS))
else # static
@rm -f $@
$(AR) -rs $@ $(BLDDIR)/intel64/libxsmm-mod.o
endif
else
.PHONY: $(OUTDIR)/libxsmmf.pc
endif
.PHONY: ext_mic
ifneq (0,$(MIC))
ifneq (0,$(MPSS))
ext_mic: $(OUTDIR)/mic/libxsmmext.$(LIBEXT)
$(OUTDIR)/mic/libxsmmext.$(LIBEXT): $(EXTOBJS_MIC) $(OUTDIR)/mic/libxsmm.$(LIBEXT)
ifeq (0,$(STATIC))
$(LIB_LD) -mmic $(EXTLDFLAGS) $(call solink,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(EXTOBJS_MIC) $(call abslib,$(OUTDIR)/mic/libxsmm.$(ILIBEXT)) $(call cleanld,$(LDFLAGS) $(CLDFLAGS))
else # static
@rm -f $@
$(AR) -rs $@ $(EXTOBJS_MIC)
endif
endif
endif
.PHONY: ext_hst
ext_hst: $(OUTDIR)/libxsmmext.pc
$(OUTDIR)/libxsmmext.$(LIBEXT): $(OUTDIR)/libxsmm.$(LIBEXT) $(EXTOBJS_HST)
ifeq (0,$(STATIC))
$(LIB_LD) $(EXTLDFLAGS) $(call solink,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(EXTOBJS_HST) $(call abslib,$(OUTDIR)/libxsmm.$(ILIBEXT)) $(call cleanld,$(LDFLAGS) $(CLDFLAGS))
else # static
@rm -f $@
$(AR) -rs $@ $(EXTOBJS_HST)
endif
.PHONY: noblas_mic
ifneq (0,$(MIC))
ifneq (0,$(MPSS))
noblas_mic: $(OUTDIR)/mic/libxsmmnoblas.$(LIBEXT)
$(OUTDIR)/mic/libxsmmnoblas.$(LIBEXT): $(NOBLAS_MIC)
ifeq (0,$(STATIC))
$(LIB_LD) -mmic $(call solink,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(NOBLAS_MIC) $(call cleanld,$(NOBLAS_LDFLAGS) $(NOBLAS_CLDFLAGS))
else # static
@rm -f $@
$(AR) -rs $@ $(NOBLAS_MIC)
endif
endif
endif
.PHONY: noblas_hst
noblas_hst: $(OUTDIR)/libxsmmnoblas.pc
$(OUTDIR)/libxsmmnoblas.$(LIBEXT): $(NOBLAS_HST)
ifeq (0,$(STATIC))
$(LIB_LD) $(call solink,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(NOBLAS_HST) $(call cleanld,$(NOBLAS_LDFLAGS) $(NOBLAS_CLDFLAGS))
else # static
@rm -f $@
$(AR) -rs $@ $(NOBLAS_HST)
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_training/fairseq/docs/ \
| grep -v /deeplearning/sparse_adagrad_fused/ \
| grep -v /deeplearning/tvm_cnnlayer/ \
| grep -v /deeplearning/tf_lstm_ops/ \
| grep -v /deeplearning/gxm/ \
| grep -v /edge/repro/ \
| grep -v /encoder/ \
| grep -v /packed/ \
| grep -v /pyfr/ \
$(NULL)))