forked from egeor/libxsmm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
1621 lines (1490 loc) · 61.6 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
# Export all variables to sub-make processes.
#.EXPORT_ALL_VARIABLES: #export
# Automatically disable parallel builds
# depending on the version of GNU Make.
# MAKE_PARALLEL=0: disable explicitly
# MAKE_PARALLEL=1: enable explicitly
ifeq (0,$(MAKE_PARALLEL))
.NOTPARALLEL:
else ifeq (,$(strip $(MAKE_PARALLEL)))
ifneq (3.82,$(firstword $(sort $(MAKE_VERSION) 3.82)))
.NOTPARALLEL:
endif
endif
#ROOTDIR = $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
ROOTDIR = $(subst //,$(NULL),$(dir $(firstword $(MAKEFILE_LIST)))/)
SPLDIR = $(ROOTDIR)/samples
SCRDIR = $(ROOTDIR)/scripts
TSTDIR = $(ROOTDIR)/tests
SRCDIR = $(ROOTDIR)/src
INCDIR = include
BLDDIR = build
OUTDIR = lib
BINDIR = bin
DOCDIR = documentation
# subdirectories for prefix based installation
PINCDIR = $(INCDIR)
POUTDIR = $(OUTDIR)
PBINDIR = $(BINDIR)
PTSTDIR = tests
PDOCDIR = share/libxsmm
# initial default flags: RPM_OPT_FLAGS are usually NULL
CFLAGS = $(RPM_OPT_FLAGS)
CXXFLAGS := $(CFLAGS)
FCFLAGS := $(CFLAGS)
DFLAGS = -DLIBXSMM_BUILD
IFLAGS = -I$(INCDIR) -I$(BLDDIR) -I$(SRCDIR)
# 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...16, or the exact strategy
# name pfsigonly...AL1_BL1_CL1.
# 1: auto-select
# 2: pfsigonly
# 3: BL2viaC
# 4: curAL2
# 7: curAL2_BL2viaC
# 5: AL2
# 6: AL2_BL2viaC
# 8: AL2jpst
# 9: AL2jpst_BL2viaC
# 10: AL1
# 11: BL1
# 12: CL1
# 13: AL1_BL1
# 14: BL1_CL1
# 15: AL1_CL1
# 16: AL1_BL1_CL1
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))
$(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))
$(error BETA needs to be either 0 or 1)
endif
endif
# Determines if the library is thread-safe
THREADS ?= 1
# 0: produces shared library files suitable for dynamic linkage
# 1: produces library archives suitable for static linkage
STATIC ?= 1
# Determines if the library can act as a wrapper-library (GEMM)
# 1: enables wrapping SGEMM/DGEMM, and GEMV (depends on "GEMM")
# 2: enables wrapping DGEMM only (DGEMV-wrap depends on "GEMM")
WRAP ?= 0
# Determines the kind of routine called for intercepted GEMMs
# odd: sequential and non-tiled (small problem sizes only)
# even: parallelized and tiled (all problem sizes)
# 3: GEMV is intercepted; small problem sizes
# 4: GEMV is intercepted; all problem sizes
GEMM ?= 1
# JIT backend is enabled by default
JIT ?= 1
# TRACE facility
INSTRUMENT ?= $(TRACE)
# target library for a broad range of systems
ifneq (0,$(JIT))
SSE ?= 1
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 (0,$(OMP))
DFLAGS += -DLIBXSMM_OMP
endif
ifneq (,$(MKL))
ifneq (0,$(MKL))
BLAS = $(MKL)
endif
endif
BLAS_WARNING ?= 0
ifeq (0,$(STATIC))
ifeq (Windows_NT,$(OS)) # !UNAME
BLAS_WARNING = 1
BLAS ?= 2
else ifeq (Darwin,$(shell uname))
BLAS_WARNING = 1
BLAS ?= 2
endif
endif
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
# state to be excluded from tracking the (re-)build state
EXCLUDE_STATE = BLAS_WARNING PREFIX
# include common Makefile artifacts
include $(ROOTDIR)/Makefile.inc
# Version numbers according to interface (version.txt)
VERSION_MAJOR ?= $(shell $(PYTHON) $(SCRDIR)/libxsmm_utilities.py 1)
VERSION_MINOR ?= $(shell $(PYTHON) $(SCRDIR)/libxsmm_utilities.py 2)
VERSION_UPDATE ?= $(shell $(PYTHON) $(SCRDIR)/libxsmm_utilities.py 3)
VERSION_API ?= $(VERSION_MAJOR)
# 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
ifeq (0,$(STATIC))
ifneq (Darwin,$(UNAME))
GENGEMM = @$(ENV) \
LD_LIBRARY_PATH=$(OUTDIR):$${LD_LIBRARY_PATH} \
PATH=$(OUTDIR):$${PATH} \
$(BINDIR)/libxsmm_gemm_generator
else # osx
GENGEMM = @$(ENV) \
DYLD_LIBRARY_PATH=$(OUTDIR):$${DYLD_LIBRARY_PATH} \
PATH=$(OUTDIR):$${PATH} \
$(BINDIR)/libxsmm_gemm_generator
endif
else
GENGEMM = $(BINDIR)/libxsmm_gemm_generator
endif
INDICES ?= $(shell $(PYTHON) $(SCRDIR)/libxsmm_utilities.py -1 $(THRESHOLD) $(words $(MNK)) $(MNK) $(words $(M)) $(words $(N)) $(M) $(N) $(K))
NINDICES = $(words $(INDICES))
HEADERS = $(wildcard $(SRCDIR)/template/*.c) $(wildcard $(SRCDIR)/*.h) \
$(SRCDIR)/libxsmm_hash.c $(SRCDIR)/libxsmm_gemm_diff.c \
$(ROOTDIR)/include/libxsmm_bgemm.h \
$(ROOTDIR)/include/libxsmm_cpuid.h \
$(ROOTDIR)/include/libxsmm_dnn.h \
$(ROOTDIR)/include/libxsmm_dnn_rnncell.h \
$(ROOTDIR)/include/libxsmm_dnn_lstmcell.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_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 %,$(SRCDIR)/%, \
libxsmm_main.c libxsmm_cpuid_x86.c libxsmm_malloc.c libxsmm_math.c libxsmm_sync.c \
libxsmm_python.c libxsmm_mhd.c libxsmm_timer.c libxsmm_perf.c \
libxsmm_gemm.c libxsmm_trans.c libxsmm_bgemm.c \
libxsmm_spmdm.c libxsmm_fsspmdm.c \
libxsmm_dnn.c libxsmm_dnn_dryruns.c libxsmm_dnn_setup.c libxsmm_dnn_handle.c \
libxsmm_dnn_rnncell.c libxsmm_dnn_lstmcell.c \
libxsmm_dnn_convolution_forward.c \
libxsmm_dnn_convolution_backward.c \
libxsmm_dnn_convolution_weight_update.c \
libxsmm_dnn_convolution_winograd_forward.c \
libxsmm_dnn_convolution_winograd_backward.c \
libxsmm_dnn_convolution_winograd_weight_update.o )
SRCFILES_KERNELS = $(patsubst %,$(BLDDIR)/mm_%.c,$(INDICES))
SRCFILES_GEN_LIB = $(patsubst %,$(SRCDIR)/%,$(wildcard $(SRCDIR)/generator_*.c) libxsmm_trace.c libxsmm_generator.c)
SRCFILES_GEN_GEMM_BIN = $(patsubst %,$(SRCDIR)/%,libxsmm_generator_gemm_driver.c)
SRCFILES_GEN_CONVWINO_BIN = $(patsubst %,$(SRCDIR)/%,libxsmm_generator_convolution_winograd_driver.c)
SRCFILES_GEN_CONV_BIN = $(patsubst %,$(SRCDIR)/%,libxsmm_generator_convolution_driver.c)
OBJFILES_GEN_LIB = $(patsubst %,$(BLDDIR)/intel64/%.o,$(basename $(notdir $(SRCFILES_GEN_LIB))))
OBJFILES_GEN_GEMM_BIN = $(patsubst %,$(BLDDIR)/intel64/%.o,$(basename $(notdir $(SRCFILES_GEN_GEMM_BIN))))
OBJFILES_GEN_CONVWINO_BIN = $(patsubst %,$(BLDDIR)/intel64/%.o,$(basename $(notdir $(SRCFILES_GEN_CONVWINO_BIN))))
OBJFILES_GEN_CONV_BIN = $(patsubst %,$(BLDDIR)/intel64/%.o,$(basename $(notdir $(SRCFILES_GEN_CONV_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))))
KRNOBJS_HST = $(patsubst %,$(BLDDIR)/intel64/mm_%.o,$(INDICES))
KRNOBJS_MIC = $(patsubst %,$(BLDDIR)/mic/mm_%.o,$(INDICES))
EXTOBJS_HST = $(BLDDIR)/intel64/libxsmm_ext.o \
$(BLDDIR)/intel64/libxsmm_ext_trans.o \
$(BLDDIR)/intel64/libxsmm_ext_bgemm.o \
$(BLDDIR)/intel64/libxsmm_ext_gemm.o
EXTOBJS_MIC = $(BLDDIR)/mic/libxsmm_ext.o \
$(BLDDIR)/mic/libxsmm_ext_trans.o \
$(BLDDIR)/mic/libxsmm_ext_bgemm.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_GEN_CONV_BIN) $(OBJFILES_GEN_CONVWINO_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
ifneq (0,$(JIT))
ifneq (0,$(SYM))
ifeq (,$(filter Darwin,$(UNAME)))
ifneq (0,$(PERF))
DFLAGS += -DLIBXSMM_PERF
ifneq (0,$(JITDUMP))
DFLAGS += -DLIBXSMM_PERF_JITDUMP
endif
endif
VTUNEROOT = $(shell env | grep VTUNE_AMPLIFIER | grep -m1 _DIR | cut -d= -f2-)
ifneq (,$(wildcard $(VTUNEROOT)/lib64/libjitprofiling.$(SLIBEXT)))
LIBJITPROFILING = $(BLDDIR)/jitprofiling/libjitprofiling.$(SLIBEXT)
OBJJITPROFILING = $(BLDDIR)/jitprofiling/*.o
DFLAGS += -DLIBXSMM_VTUNE
IFLAGS += -I$(VTUNEROOT)/include
ifneq (0,$(INTEL))
CXXFLAGS += -diag-disable 271
CFLAGS += -diag-disable 271
endif
endif
endif
endif
endif
information = \
$(info ================================================================================) \
$(info LIBXSMM $(shell $(PYTHON) $(SCRDIR)/libxsmm_utilities.py)) \
$(info --------------------------------------------------------------------------------) \
$(info $(GINFO)) \
$(info $(CINFO)) \
$(if $(strip $(FC)),$(info $(FINFO)),$(NULL)) \
$(info --------------------------------------------------------------------------------) \
$(if $(strip $(FC)),$(NULL),$(if $(strip $(FC_VERSION_STRING)), \
$(info Fortran Compiler $(FC_VERSION_STRING) is outdated!), \
$(info Fortran Compiler is missing: no Fortran interface is built!)) \
$(info ================================================================================)) \
$(if $(filter Windows_NT0,$(UNAME)$(STATIC)), \
$(info The shared link-time wrapper (libxsmmext) is not supported under Windows/Cygwin!) \
$(info ================================================================================), \
$(NULL)) \
$(if $(filter _0_,_$(BLAS_WARNING)_),$(NULL), \
$(info Building a shared library requires to link against BLAS since there is) \
$(info no runtime resolution/search for weak symbols implemented for this OS.)) \
$(if $(filter _0_,_$(BLAS)_), \
$(if $(filter _0_,_$(NOBLAS)_),$(NULL), \
$(info LIBXSMM's link-time BLAS dependency is removed (fallback might be unavailable!)) \
$(info ================================================================================)), \
$(if $(filter _0_,_$(BLAS_WARNING)_), \
$(info LIBXSMM is link-time agnostic with respect to BLAS/GEMM!) \
$(info Linking a certain BLAS library may prevent users to decide.), \
$(NULL)) \
$(if $(filter _1_,_$(BLAS)_), \
$(info LIBXSMM's THRESHOLD already prevents calling small GEMMs!) \
$(info A sequential BLAS is superfluous with respect to LIBXSMM.), \
$(NULL)) \
$(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 (,$(strip $(LIBJITPROFILING)))
$(info Intel VTune Amplifier support has been incorporated.)
$(info ================================================================================)
endif
.PHONY: lib
lib: headers drytest lib_hst lib_mic
.PHONY: all
all: libxsmm 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: 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) <= 16))))
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
else ifeq (AL2jpst,$(PREFETCH))
PREFETCH_UID = 8
else ifeq (AL2jpst_BL2viaC,$(PREFETCH))
PREFETCH_UID = 9
else ifeq (AL1,$(PREFETCH))
PREFETCH_UID = 10
else ifeq (BL1,$(PREFETCH))
PREFETCH_UID = 11
else ifeq (CL1,$(PREFETCH))
PREFETCH_UID = 12
else ifeq (AL1_BL1,$(PREFETCH))
PREFETCH_UID = 13
else ifeq (BL1_CL1,$(PREFETCH))
PREFETCH_UID = 14
else ifeq (AL1_CL1,$(PREFETCH))
PREFETCH_UID = 15
else ifeq (AL1_BL1_CL1,$(PREFETCH))
PREFETCH_UID = 16
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 = 8
else ifeq (4,$(PREFETCH_UID))
PREFETCH_SCHEME = curAL2
PREFETCH_TYPE = 16
else ifeq (5,$(PREFETCH_UID))
PREFETCH_SCHEME = curAL2_BL2viaC
PREFETCH_TYPE = $(shell echo $$((8 | 16)))
else ifeq (6,$(PREFETCH_UID))
PREFETCH_SCHEME = AL2
PREFETCH_TYPE = 2
else ifeq (7,$(PREFETCH_UID))
PREFETCH_SCHEME = AL2_BL2viaC
PREFETCH_TYPE = $(shell echo $$((8 | 2)))
else ifeq (8,$(PREFETCH_UID))
PREFETCH_SCHEME = AL2jpst
PREFETCH_TYPE = 4
else ifeq (9,$(PREFETCH_UID))
PREFETCH_SCHEME = AL2jpst_BL2viaC
PREFETCH_TYPE = $(shell echo $$((8 | 4)))
else ifeq (10,$(PREFETCH_UID))
PREFETCH_SCHEME = AL1
PREFETCH_TYPE = 32
else ifeq (11,$(PREFETCH_UID))
PREFETCH_SCHEME = BL1
PREFETCH_TYPE = 64
else ifeq (12,$(PREFETCH_UID))
PREFETCH_SCHEME = CL1
PREFETCH_TYPE = 128
else ifeq (13,$(PREFETCH_UID))
PREFETCH_SCHEME = AL1_BL1
PREFETCH_TYPE = $(shell echo $$((32 | 64)))
else ifeq (14,$(PREFETCH_UID))
PREFETCH_SCHEME = BL1_CL1
PREFETCH_TYPE = $(shell echo $$((64 | 128)))
else ifeq (15,$(PREFETCH_UID))
PREFETCH_SCHEME = AL1_CL1
PREFETCH_TYPE = $(shell echo $$((32 | 128)))
else ifeq (16,$(PREFETCH_UID))
PREFETCH_SCHEME = AL1_BL1_CL1
PREFETCH_TYPE = $(shell echo $$((32 | 64 | 128)))
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
.PHONY: config
config: $(INCDIR)/libxsmm_config.h
$(INCDIR)/libxsmm_config.h: $(INCDIR)/.make .state $(SRCDIR)/template/libxsmm_config.h \
$(SCRDIR)/libxsmm_config.py $(SCRDIR)/libxsmm_utilities.py \
$(ROOTDIR)/Makefile $(ROOTDIR)/Makefile.inc \
$(wildcard $(ROOTDIR)/.gitx/*) \
$(ROOTDIR)/version.txt
$(information)
@if [ -e $(ROOTDIR)/.gitx/install.sh ]; then \
$(ROOTDIR)/.gitx/install.sh; \
fi
@$(CP) $(ROOTDIR)/include/libxsmm_bgemm.h $(INCDIR) 2>/dev/null || true
@$(CP) $(ROOTDIR)/include/libxsmm_cpuid.h $(INCDIR) 2>/dev/null || true
@$(CP) $(ROOTDIR)/include/libxsmm_dnn.h $(INCDIR) 2>/dev/null || true
@$(CP) $(ROOTDIR)/include/libxsmm_dnn_rnncell.h $(INCDIR) 2>/dev/null || true
@$(CP) $(ROOTDIR)/include/libxsmm_dnn_lstmcell.h $(INCDIR) 2>/dev/null || true
@$(CP) $(ROOTDIR)/include/libxsmm_frontend.h $(INCDIR) 2>/dev/null || true
@$(CP) $(ROOTDIR)/include/libxsmm_fsspmdm.h $(INCDIR) 2>/dev/null || true
@$(CP) $(ROOTDIR)/include/libxsmm_generator.h $(INCDIR) 2>/dev/null || true
@$(CP) $(ROOTDIR)/include/libxsmm_intrinsics_x86.h $(INCDIR) 2>/dev/null || true
@$(CP) $(ROOTDIR)/include/libxsmm_macros.h $(INCDIR) 2>/dev/null || true
@$(CP) $(ROOTDIR)/include/libxsmm_malloc.h $(INCDIR) 2>/dev/null || true
@$(CP) $(ROOTDIR)/include/libxsmm_math.h $(INCDIR) 2>/dev/null || true
@$(CP) $(ROOTDIR)/include/libxsmm_mhd.h $(INCDIR) 2>/dev/null || true
@$(CP) $(ROOTDIR)/include/libxsmm_spmdm.h $(INCDIR) 2>/dev/null || true
@$(CP) $(ROOTDIR)/include/libxsmm_sync.h $(INCDIR) 2>/dev/null || true
@$(CP) $(ROOTDIR)/include/libxsmm_timer.h $(INCDIR) 2>/dev/null || true
@$(CP) $(ROOTDIR)/include/libxsmm_typedefs.h $(INCDIR) 2>/dev/null || true
@$(PYTHON) $(SCRDIR)/libxsmm_config.py $(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) $(GEMM) $(INDICES) > $@
.PHONY: cheader
cheader: $(INCDIR)/libxsmm.h
$(INCDIR)/libxsmm.h: $(SCRDIR)/libxsmm_interface.py \
$(SRCDIR)/template/libxsmm.h \
$(INCDIR)/libxsmm_config.h $(HEADERS)
@$(PYTHON) $(SCRDIR)/libxsmm_interface.py $(SRCDIR)/template/libxsmm.h \
$(PRECISION) $(PREFETCH_TYPE) $(INDICES) > $@
.PHONY: cheader_only
cheader_only: $(INCDIR)/libxsmm_source.h
$(INCDIR)/libxsmm_source.h: $(INCDIR)/.make $(SCRDIR)/libxsmm_source.sh $(INCDIR)/libxsmm.h
@$(SCRDIR)/libxsmm_source.sh > $@
.PHONY: fheader
fheader: $(INCDIR)/libxsmm.f
$(INCDIR)/libxsmm.f: $(SCRDIR)/libxsmm_interface.py \
$(SRCDIR)/template/libxsmm.f \
$(INCDIR)/libxsmm_config.h
@$(PYTHON) $(SCRDIR)/libxsmm_interface.py $(SRCDIR)/template/libxsmm.f \
$(PRECISION) $(PREFETCH_TYPE) $(INDICES) | \
$(PYTHON) $(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) $(GEMM) $(INDICES) | \
sed "/ATTRIBUTES OFFLOAD:MIC/d" > $@
.PHONY: sources
sources: $(SRCFILES_KERNELS) $(BLDDIR)/libxsmm_dispatch.h
$(BLDDIR)/libxsmm_dispatch.h: $(BLDDIR)/.make $(SCRDIR)/libxsmm_dispatch.py $(SRCFILES_KERNELS) \
$(INCDIR)/libxsmm.h
@$(PYTHON) $(SCRDIR)/libxsmm_dispatch.py $(PRECISION) $(THRESHOLD) $(INDICES) > $@
$(BLDDIR)/%.c: $(BLDDIR)/.make $(INCDIR)/libxsmm.h $(BINDIR)/libxsmm_gemm_generator $(SCRDIR)/libxsmm_utilities.py $(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 >> $@
ifneq (0,$(MIC))
ifneq (0,$(MPSS))
ifneq (2,$(PRECISION))
@echo "#define LIBXSMM_GENTARGET_knc_sp" >> $@
endif
ifneq (1,$(PRECISION))
@echo "#define LIBXSMM_GENTARGET_knc_dp" >> $@
endif
endif
endif
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
ifneq (0,$(MIC))
ifneq (0,$(MPSS))
ifneq (2,$(PRECISION))
$(GENGEMM) dense $@ libxsmm_s$(basename $(notdir $@))_knc $(MNVALUE) $(NMVALUE) $(KVALUE) $(MNVALUE) $(KVALUE) $(MNVALUE) $(ALPHA) $(BETA) 0 0 knc $(PREFETCH_SCHEME_MIC) SP
endif
ifneq (1,$(PRECISION))
$(GENGEMM) dense $@ libxsmm_d$(basename $(notdir $@))_knc $(MNVALUE) $(NMVALUE) $(KVALUE) $(MNVALUE) $(KVALUE) $(MNVALUE) $(ALPHA) $(BETA) 0 0 knc $(PREFETCH_SCHEME_MIC) DP
endif
endif
endif
$(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) $(SCRDIR)/libxsmm_specialized.py $(PRECISION) $(MVALUE) $(NVALUE) $(KVALUE) $(PREFETCH_TYPE) >> $(TMPFILE)
@$(MV) $(TMPFILE) $@
endif
define DEFINE_COMPILE_RULE
$(1): $(2) $(3) $(dir $(1))/.make
$(CC) $(4) -c $(2) -o $(1)
endef
EXTCFLAGS = -DLIBXSMM_BUILD_EXT
ifneq (0,$(STATIC))
ifneq (0,$(WRAP))
ifneq (,$(strip $(WRAP)))
EXTCFLAGS += -DLIBXSMM_GEMM_WRAP=$(WRAP)
endif
endif
endif
ifeq (0,$(OMP))
ifeq (,$(filter environment% override command%,$(origin OMP)))
EXTCFLAGS += $(OMPFLAG)
EXTLDFLAGS += $(OMPFLAG)
endif
endif
ifneq (0,$(MIC))
ifneq (0,$(MPSS))
$(foreach OBJ,$(OBJFILES_MIC),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ), $(patsubst %.o,$(SRCDIR)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h $(BLDDIR)/libxsmm_dispatch.h, \
-mmic $(CFLAGS) $(DFLAGS) $(IFLAGS))))
$(foreach OBJ,$(KRNOBJS_MIC),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ), $(patsubst %.o,$(BLDDIR)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h, \
-mmic $(CFLAGS) $(DFLAGS) $(IFLAGS))))
$(foreach OBJ,$(EXTOBJS_MIC),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ), $(patsubst %.o,$(SRCDIR)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h, \
-mmic $(EXTCFLAGS) $(CFLAGS) $(DFLAGS) $(IFLAGS))))
$(eval $(call DEFINE_COMPILE_RULE,$(NOBLAS_MIC),$(SRCDIR)/libxsmm_ext.c,$(INCDIR)/libxsmm.h, \
-mmic $(NOBLAS_CFLAGS) $(NOBLAS_FLAGS) $(NOBLAS_IFLAGS) $(DNOBLAS)))
endif
endif
$(foreach OBJ,$(OBJFILES_HST),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ),$(patsubst %.o,$(SRCDIR)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h $(BLDDIR)/libxsmm_dispatch.h, \
$(CTARGET) $(CFLAGS) $(DFLAGS) $(IFLAGS))))
$(foreach OBJ,$(KRNOBJS_HST),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ),$(patsubst %.o,$(BLDDIR)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h, \
$(CTARGET) $(CFLAGS) $(DFLAGS) $(IFLAGS))))
$(foreach OBJ,$(EXTOBJS_HST),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ),$(patsubst %.o,$(SRCDIR)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h, \
$(CTARGET) $(EXTCFLAGS) $(CFLAGS) $(DFLAGS) $(IFLAGS))))
$(foreach OBJ,$(OBJFILES_GEN_LIB),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ),$(patsubst %.o,$(SRCDIR)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h, \
$(CFLAGS) $(DFLAGS) $(IFLAGS))))
$(foreach OBJ,$(OBJFILES_GEN_GEMM_BIN),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ),$(patsubst %.o,$(SRCDIR)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h, \
$(CFLAGS) $(DFLAGS) $(IFLAGS))))
$(foreach OBJ,$(OBJFILES_GEN_CONVWINO_BIN),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ),$(patsubst %.o,$(SRCDIR)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h, \
$(CFLAGS) $(DFLAGS) $(IFLAGS))))
$(foreach OBJ,$(OBJFILES_GEN_CONV_BIN),$(eval $(call DEFINE_COMPILE_RULE, \
$(OBJ),$(patsubst %.o,$(SRCDIR)/%.c,$(notdir $(OBJ))), \
$(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h, \
$(CFLAGS) $(DFLAGS) $(IFLAGS))))
$(eval $(call DEFINE_COMPILE_RULE,$(NOBLAS_HST),$(SRCDIR)/libxsmm_ext.c,$(INCDIR)/libxsmm.h, \
$(CTARGET) $(NOBLAS_CFLAGS) $(NOBLAS_FLAGS) $(NOBLAS_IFLAGS) $(DNOBLAS)))
.PHONY: compile_mic
ifneq (0,$(MIC))
ifneq (0,$(MPSS))
compile_mic:
$(BLDDIR)/mic/%.o: $(BLDDIR)/%.c $(BLDDIR)/mic/.make $(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h $(BLDDIR)/libxsmm_dispatch.h
$(CC) $(CFLAGS) $(DFLAGS) $(IFLAGS) -mmic -c $< -o $@
endif
endif
.PHONY: compile_hst
compile_hst:
$(BLDDIR)/intel64/%.o: $(BLDDIR)/%.c $(BLDDIR)/intel64/.make $(INCDIR)/libxsmm.h $(INCDIR)/libxsmm_source.h $(BLDDIR)/libxsmm_dispatch.h
$(CC) $(CFLAGS) $(DFLAGS) $(IFLAGS) $(CTARGET) -c $< -o $@
.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) $(FCMTFLAGS) $(FCFLAGS) $(DFLAGS) $(IFLAGS) -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) $(FCMTFLAGS) $(FCFLAGS) $(DFLAGS) $(IFLAGS) $(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): $(OUTDIR)/.make $(OBJFILES_GEN_LIB)
ifeq (0,$(STATIC))
$(LIB_LD) $(call soname,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) $(OBJFILES_GEN_LIB) $(LDFLAGS) $(CLDFLAGS) $(LIBRT)
else # static
$(AR) -rs $@ $(OBJFILES_GEN_LIB)
endif
.PHONY: generator
generator: $(BINDIR)/libxsmm_gemm_generator $(BINDIR)/libxsmm_conv_generator $(BINDIR)/libxsmm_convwino_generator
$(BINDIR)/libxsmm_gemm_generator: $(BINDIR)/.make $(OBJFILES_GEN_GEMM_BIN) $(OUTDIR)/libxsmmgen.$(LIBEXT)
$(LD) -o $@ $(OBJFILES_GEN_GEMM_BIN) $(call abslib,$(OUTDIR)/libxsmmgen.$(IMPEXT)) $(LDFLAGS) $(CLDFLAGS)
$(BINDIR)/libxsmm_conv_generator: $(BINDIR)/.make $(OBJFILES_GEN_CONV_BIN) $(OUTDIR)/libxsmmgen.$(LIBEXT)
$(LD) -o $@ $(OBJFILES_GEN_CONV_BIN) $(call abslib,$(OUTDIR)/libxsmmgen.$(IMPEXT)) $(LDFLAGS) $(CLDFLAGS)
$(BINDIR)/libxsmm_convwino_generator: $(BINDIR)/.make $(OBJFILES_GEN_CONVWINO_BIN) $(OUTDIR)/libxsmmgen.$(LIBEXT)
$(LD) -o $@ $(OBJFILES_GEN_CONVWINO_BIN) $(call abslib,$(OUTDIR)/libxsmmgen.$(IMPEXT)) $(LDFLAGS) $(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 soname,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) $(OBJFILES_MIC) $(KRNOBJS_MIC) $(LDFLAGS) $(CLDFLAGS)
else # static
$(AR) -rs $@ $(OBJFILES_MIC) $(KRNOBJS_MIC)
endif
endif
endif
.PHONY: clib_hst
clib_hst: $(OUTDIR)/libxsmm.$(LIBEXT)
$(OUTDIR)/libxsmm.$(LIBEXT): $(OUTDIR)/.make $(OBJFILES_HST) $(OBJFILES_GEN_LIB) $(KRNOBJS_HST) $(LIBJITPROFILING)
ifeq (0,$(STATIC))
$(LIB_LD) $(call soname,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) $(OBJFILES_HST) $(OBJFILES_GEN_LIB) $(KRNOBJS_HST) $(LIBJITPROFILING) $(LDFLAGS) $(CLDFLAGS)
else # static
$(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)
ifeq (0,$(STATIC))
$(OUTDIR)/mic/libxsmmf.$(LIBEXT): $(INCDIR)/mic/libxsmm.mod $(OUTDIR)/mic/libxsmm.$(LIBEXT)
$(LIB_FLD) -mmic $(FCMTFLAGS) $(call soname,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(BLDDIR)/mic/libxsmm-mod.o $(call abslib,$(OUTDIR)/mic/libxsmm.$(IMPEXT)) $(LDFLAGS) $(FLDFLAGS)
else # static
$(OUTDIR)/mic/libxsmmf.$(LIBEXT): $(INCDIR)/mic/libxsmm.mod $(OUTDIR)/mic/.make
$(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.$(LIBEXT)
ifeq (0,$(STATIC))
$(OUTDIR)/libxsmmf.$(LIBEXT): $(INCDIR)/libxsmm.mod $(OUTDIR)/libxsmm.$(LIBEXT)
$(LIB_FLD) $(FCMTFLAGS) $(call soname,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(BLDDIR)/intel64/libxsmm-mod.o $(call abslib,$(OUTDIR)/libxsmm.$(IMPEXT)) $(LDFLAGS) $(FLDFLAGS)
else # static
$(OUTDIR)/libxsmmf.$(LIBEXT): $(INCDIR)/libxsmm.mod $(OUTDIR)/.make
$(AR) -rs $@ $(BLDDIR)/intel64/libxsmm-mod.o
endif
else
.PHONY: $(OUTDIR)/libxsmmf.$(LIBEXT)
endif
.PHONY: ext_mic
ifneq (0,$(MIC))
ifneq (0,$(MPSS))
ext_mic: $(OUTDIR)/mic/libxsmmext.$(LIBEXT)
ifeq (0,$(STATIC))
$(OUTDIR)/mic/libxsmmext.$(LIBEXT): $(OUTDIR)/mic/.make $(EXTOBJS_MIC) $(OUTDIR)/mic/libxsmm.$(LIBEXT)
$(LIB_LD) -mmic $(EXTLDFLAGS) $(call soname,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(EXTOBJS_MIC) $(call abslib,$(OUTDIR)/mic/libxsmm.$(IMPEXT)) $(LDFLAGS) $(CLDFLAGS)
else # static
$(OUTDIR)/mic/libxsmmext.$(LIBEXT): $(OUTDIR)/mic/.make $(EXTOBJS_MIC)
$(AR) -rs $@ $(EXTOBJS_MIC)
endif
endif
endif
.PHONY: ext_hst
ext_hst: $(OUTDIR)/libxsmmext.$(LIBEXT)
ifeq (0,$(STATIC))
$(OUTDIR)/libxsmmext.$(LIBEXT): $(OUTDIR)/.make $(EXTOBJS_HST) $(OUTDIR)/libxsmm.$(LIBEXT)
ifneq (Darwin,$(UNAME))
$(LIB_LD) $(EXTLDFLAGS) $(call soname,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(EXTOBJS_HST) $(call abslib,$(OUTDIR)/libxsmm.$(IMPEXT)) $(LDFLAGS) $(CLDFLAGS)
else ifneq (0,$(INTEL)) # intel @ osx
$(LIB_LD) $(EXTLDFLAGS) $(call soname,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(EXTOBJS_HST) $(call abslib,$(OUTDIR)/libxsmm.$(IMPEXT)) $(LDFLAGS) $(CLDFLAGS)
else # osx
$(LIB_LD) $(call soname,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) \
$(EXTOBJS_HST) $(call abslib,$(OUTDIR)/libxsmm.$(IMPEXT)) $(LDFLAGS) $(CLDFLAGS)
endif
else # static
$(OUTDIR)/libxsmmext.$(LIBEXT): $(OUTDIR)/.make $(EXTOBJS_HST)
$(AR) -rs $@ $(EXTOBJS_HST)
endif
.PHONY: noblas_mic
ifneq (0,$(MIC))
ifneq (0,$(MPSS))
noblas_mic: $(OUTDIR)/mic/libxsmmnoblas.$(LIBEXT)
ifeq (0,$(STATIC))
$(OUTDIR)/mic/libxsmmnoblas.$(LIBEXT): $(OUTDIR)/mic/.make $(NOBLAS_MIC)
$(LIB_LD) -mmic $(EXTLDFLAGS) $(call soname,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) $(NOBLAS_MIC) $(LDFLAGS) $(CLDFLAGS)
else # static
$(OUTDIR)/mic/libxsmmnoblas.$(LIBEXT): $(OUTDIR)/mic/.make $(NOBLAS_MIC)
$(AR) -rs $@ $(NOBLAS_MIC)
endif
endif
endif
.PHONY: noblas_hst
noblas_hst: $(OUTDIR)/libxsmmnoblas.$(LIBEXT)
ifeq (0,$(STATIC))
$(OUTDIR)/libxsmmnoblas.$(LIBEXT): $(OUTDIR)/.make $(NOBLAS_HST)
ifneq (Darwin,$(UNAME))
$(LIB_LD) $(EXTLDFLAGS) $(call soname,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) $(NOBLAS_HST) $(LDFLAGS) $(CLDFLAGS)
else ifneq (0,$(INTEL)) # intel @ osx
$(LIB_LD) $(EXTLDFLAGS) $(call soname,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) $(NOBLAS_HST) $(LDFLAGS) $(CLDFLAGS)
else # osx
$(LIB_LD) $(call soname,$@,$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_UPDATE),$(VERSION_API)) $(NOBLAS_HST) $(LDFLAGS) $(CLDFLAGS)
endif
else # static
$(OUTDIR)/libxsmmnoblas.$(LIBEXT): $(OUTDIR)/.make $(NOBLAS_HST)
$(AR) -rs $@ $(NOBLAS_HST)
endif
.PHONY: samples
samples: lib_hst
@find $(SPLDIR) -type f -name Makefile | grep -v /pyfr/ | grep -v /lstmcell/ | grep -v /gxm/ \
$(patsubst %, | grep -v /%/,$^) | xargs -I {} $(FLOCK) {} "$(MAKE) DEPSTATIC=$(STATIC)"
.PHONY: cp2k
cp2k: lib_hst
@$(FLOCK) $(SPLDIR)/cp2k "$(MAKE) --no-print-directory DEPSTATIC=$(STATIC)"
.PHONY: cp2k_mic
cp2k_mic: lib_mic
@$(FLOCK) $(SPLDIR)/cp2k "$(MAKE) --no-print-directory DEPSTATIC=$(STATIC) KNC=1"
.PHONY: wrap
wrap: lib_hst
@$(FLOCK) $(SPLDIR)/wrap "$(MAKE) --no-print-directory DEPSTATIC=$(STATIC) TRACE=0"
.PHONY: wrap_mic
wrap_mic: lib_mic
@$(FLOCK) $(SPLDIR)/wrap "$(MAKE) --no-print-directory DEPSTATIC=$(STATIC) KNC=1 TRACE=0"
.PHONY: nek
nek: lib_hst
@$(FLOCK) $(SPLDIR)/nek "$(MAKE) --no-print-directory DEPSTATIC=$(STATIC)"
.PHONY: nek_mic
nek_mic: lib_mic
@$(FLOCK) $(SPLDIR)/nek "$(MAKE) --no-print-directory DEPSTATIC=$(STATIC) KNC=1"
.PHONY: smm
smm: lib_hst
@$(FLOCK) $(SPLDIR)/smm "$(MAKE) --no-print-directory DEPSTATIC=$(STATIC)"
.PHONY: smm_mic
smm_mic: lib_mic
@$(FLOCK) $(SPLDIR)/smm "$(MAKE) --no-print-directory DEPSTATIC=$(STATIC) KNC=1"
# added for specfem sample
# will need option: make MNK="5 25" ..
.PHONY: specfem
specfem: lib_hst
@$(FLOCK) $(SPLDIR)/specfem "$(MAKE) --no-print-directory DEPSTATIC=$(STATIC)"