Skip to content

Commit bc1a295

Browse files
committed
Add Makefiles
1 parent db9089d commit bc1a295

File tree

44 files changed

+1454
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1454
-2
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
EXAMPLES := \
24+
attention \
25+
basic \
26+
gemm \
27+
moe \
28+
normalization \
29+
quantization
30+
31+
all: $(EXAMPLES)
32+
33+
clean: TARGET=clean
34+
clean: all
35+
36+
$(EXAMPLES):
37+
$(MAKE) -C $@ $(TARGET)
38+
39+
.PHONY: all clean $(EXAMPLES)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
EXAMPLES := \
24+
fmha \
25+
topk_softmax
26+
27+
all: $(EXAMPLES)
28+
29+
clean: TARGET=clean
30+
clean: all
31+
32+
$(EXAMPLES):
33+
$(MAKE) -C $@ $(TARGET)
34+
35+
.PHONY: all clean $(EXAMPLES)
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1+
codegen/__pycache__
2+
codegen/ops/__pycache__
3+
14
ComposableKernel_ck_tile_fmha_fwd
2-
ComposableKernel_ck_tile_fmha_bwd
5+
ComposableKernel_ck_tile_fmha_bwd
6+
fwd_sources
7+
fwd_objects
8+
bwd_sources
9+
bwd_objects
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
EXAMPLE_FWD := ComposableKernel_ck_tile_fmha_fwd
24+
EXAMPLE_BWD := ComposableKernel_ck_tile_fmha_bwd
25+
EXAMPLE_GENERATOR := generate.py
26+
GPU_RUNTIME := HIP
27+
28+
# HIP variables
29+
ROCM_INSTALL_DIR := /opt/rocm
30+
HIP_INCLUDE_DIR := $(ROCM_INSTALL_DIR)/include
31+
32+
HIPCXX ?= $(ROCM_INSTALL_DIR)/bin/hipcc
33+
34+
# Common variables and flags
35+
CXX_STD := c++17
36+
ICXXFLAGS := -std=$(CXX_STD) -x hip -fgpu-flush-denormals-to-zero
37+
ICPPFLAGS :=
38+
ILDFLAGS :=
39+
ILDLIBS :=
40+
41+
CXXFLAGS ?= -Wall -Wextra -Wno-float-equal -Wno-undefined-func-template
42+
ICXXFLAGS += $(CXXFLAGS)
43+
ICPPFLAGS += $(CPPFLAGS)
44+
ILDFLAGS += $(LDFLAGS)
45+
ILDLIBS += $(LDLIBS)
46+
47+
FWD_PP_DEFS := -DCK_TILE_FMHA_FWD_FAST_EXP2=1 -DCK_TILE_FMHA_FWD_SPLITKV_API=1 -DCK_TILE_FMHA_FWD_APPENDKV_API=1 -DCK_TILE_FMHA_FWD_PAGEDKV_API=1
48+
FWD_SRC_DIR := fwd_sources
49+
FWD_OBJ_DIR := fwd_objects
50+
BWD_SRC_DIR := bwd_sources
51+
BWD_OBJ_DIR := bwd_objects
52+
SRC_DIR := .
53+
54+
FWD_GENERATION_DONE := $(FWD_SRC_DIR)/.generated
55+
BWD_GENERATION_DONE := $(BWD_SRC_DIR)/.generated
56+
57+
.PHONY: all
58+
all: $(EXAMPLE_FWD) $(EXAMPLE_BWD)
59+
60+
$(FWD_SRC_DIR) $(FWD_OBJ_DIR) $(BWD_SRC_DIR) $(BWD_OBJ_DIR):
61+
mkdir -p $@
62+
63+
.PHONY: generate
64+
generate: $(FWD_GENERATION_DONE) $(BWD_GENERATION_DONE)
65+
66+
$(FWD_GENERATION_DONE): $(EXAMPLE_GENERATOR) | $(FWD_SRC_DIR)
67+
python3 $(EXAMPLE_GENERATOR) --api fwd,fwd_splitkv,fwd_appendkv --output_dir $(FWD_SRC_DIR)
68+
@touch $@
69+
70+
$(BWD_GENERATION_DONE): $(EXAMPLE_GENERATOR) | $(BWD_SRC_DIR)
71+
python3 $(EXAMPLE_GENERATOR) --api bwd --output_dir $(BWD_SRC_DIR) --receipt 3
72+
@touch $@
73+
74+
FWD_SRCS := fmha_fwd.cpp
75+
FWD_GEN_SRCS = $(shell if [ -f $(FWD_GENERATION_DONE) ]; then find $(FWD_SRC_DIR) -name "*.cpp" 2> /dev/null; fi)
76+
77+
BWD_SRCS := fmha_bwd.cpp
78+
BWD_GEN_SRCS = $(shell if [ -f $(BWD_GENERATION_DONE) ]; then find $(BWD_SRC_DIR) -name "*.cpp" 2> /dev/null; fi)
79+
80+
-include $(FWD_GENERATION_DONE)
81+
-include $(BWD_GENERATION_DONE)
82+
83+
FWD_OBJECTS := $(patsubst $(SRC_DIR)/%.cpp,$(FWD_OBJ_DIR)/%.o,$(FWD_SRCS)) \
84+
$(patsubst $(FWD_SRC_DIR)/%.cpp,$(FWD_OBJ_DIR)/%.o,$(FWD_GEN_SRCS))
85+
86+
BWD_OBJECTS := $(patsubst $(SRC_DIR)/%.cpp,$(BWD_OBJ_DIR)/%.o,$(BWD_SRCS)) \
87+
$(patsubst $(BWD_SRC_DIR)/%.cpp,$(BWD_OBJ_DIR)/%.o,$(BWD_GEN_SRCS))
88+
89+
$(FWD_OBJ_DIR)/fmha_fwd.o: fmha_fwd.cpp | $(FWD_OBJ_DIR)
90+
$(HIPCXX) $(ICXXFLAGS) $(ICPPFLAGS) $(FWD_PP_DEFS) -c $< -o $@
91+
92+
$(FWD_OBJ_DIR)/%.o: $(FWD_SRC_DIR)/%.cpp | $(FWD_OBJ_DIR)
93+
$(HIPCXX) $(ICXXFLAGS) $(ICPPFLAGS) $(FWD_PP_DEFS) -c $< -o $@
94+
95+
$(EXAMPLE_FWD): $(FWD_OBJECTS)
96+
$(HIPCXX) $(ILDFLAGS) -o $@ $^ $(ILDLIBS)
97+
98+
$(BWD_OBJ_DIR)/fmha_bwd.o: fmha_bwd.cpp | $(BWD_OBJ_DIR)
99+
$(HIPCXX) $(ICXXFLAGS) $(ICPPFLAGS) -c $< -o $@
100+
101+
$(BWD_OBJ_DIR)/%.o: $(BWD_SRC_DIR)/%.cpp | $(BWD_OBJ_DIR)
102+
$(HIPCXX) $(ICXXFLAGS) $(ICPPFLAGS) -c $< -o $@
103+
104+
$(EXAMPLE_BWD): $(BWD_OBJECTS)
105+
$(HIPCXX) $(ILDFLAGS) -o $@ $^ $(ILDLIBS)
106+
107+
.PHONY: clean
108+
clean:
109+
$(RM) -r $(EXAMPLE_FWD) $(EXAMPLE_BWD) $(FWD_SRC_DIR) $(FWD_OBJ_DIR) $(BWD_SRC_DIR) $(BWD_OBJ_DIR)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
*.o
12
ComposableKernel_ck_tile_topk_softmax
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
EXAMPLE := ComposableKernel_ck_tile_topk_softmax
24+
GPU_RUNTIME := HIP
25+
26+
# HIP variables
27+
ROCM_INSTALL_DIR := /opt/rocm
28+
HIP_INCLUDE_DIR := $(ROCM_INSTALL_DIR)/include
29+
30+
HIPCXX ?= $(ROCM_INSTALL_DIR)/bin/hipcc
31+
32+
# Common variables and flags
33+
CXX_STD := c++17
34+
ICXXFLAGS := -std=$(CXX_STD) -x hip
35+
ICPPFLAGS :=
36+
ILDFLAGS :=
37+
ILDLIBS :=
38+
39+
CXXFLAGS ?= -Wall -Wextra -Wno-undefined-func-template -Wno-float-equal
40+
ICXXFLAGS += $(CXXFLAGS)
41+
ICPPFLAGS += $(CPPFLAGS)
42+
ILDFLAGS += $(LDFLAGS)
43+
ILDLIBS += $(LDLIBS)
44+
45+
SOURCES := $(wildcard *.cpp)
46+
OBJECTS := $(SOURCES:.cpp=.o)
47+
48+
%.o: %.cpp
49+
$(HIPCXX) $(ICXXFLAGS) $(ICPPFLAGS) -o $@ -c $<
50+
51+
$(EXAMPLE): $(OBJECTS)
52+
$(HIPCXX) $(ILDFLAGS) -o $@ $^ $(ILDLIBS)
53+
54+
clean:
55+
$(RM) $(EXAMPLE) $(OBJECTS)
56+
57+
.PHONY: clean
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
EXAMPLES := \
24+
batched_transpose \
25+
copy \
26+
img2col \
27+
permute \
28+
reduce
29+
30+
all: $(EXAMPLES)
31+
32+
clean: TARGET=clean
33+
clean: all
34+
35+
$(EXAMPLES):
36+
$(MAKE) -C $@ $(TARGET)
37+
38+
.PHONY: all clean $(EXAMPLES)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
*.o
12
ComposableKernel_ck_tile_batched_transpose
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
EXAMPLE := ComposableKernel_ck_tile_batched_transpose
24+
GPU_RUNTIME := HIP
25+
26+
# HIP variables
27+
ROCM_INSTALL_DIR := /opt/rocm
28+
HIP_INCLUDE_DIR := $(ROCM_INSTALL_DIR)/include
29+
30+
HIPCXX ?= $(ROCM_INSTALL_DIR)/bin/hipcc
31+
32+
# Common variables and flags
33+
CXX_STD := c++17
34+
ICXXFLAGS := -std=$(CXX_STD) -x hip
35+
ICPPFLAGS :=
36+
ILDFLAGS :=
37+
ILDLIBS :=
38+
39+
CXXFLAGS ?= -Wall -Wextra -Wno-undefined-func-template -Wno-float-equal
40+
ICXXFLAGS += $(CXXFLAGS)
41+
ICPPFLAGS += $(CPPFLAGS)
42+
ILDFLAGS += $(LDFLAGS)
43+
ILDLIBS += $(LDLIBS)
44+
45+
SOURCES := $(wildcard *.cpp)
46+
OBJECTS := $(SOURCES:.cpp=.o)
47+
48+
%.o: %.cpp
49+
$(HIPCXX) $(ICXXFLAGS) $(ICPPFLAGS) -o $@ -c $<
50+
51+
$(EXAMPLE): $(OBJECTS)
52+
$(HIPCXX) $(ILDFLAGS) -o $@ $^ $(ILDLIBS)
53+
54+
clean:
55+
$(RM) $(EXAMPLE) $(OBJECTS)
56+
57+
.PHONY: clean
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
*.o
12
ComposableKernel_ck_tile_copy

0 commit comments

Comments
 (0)