Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 72 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,78 @@ jobs:
cache-to: type=gha,mode=max

- name: Build gpuagent
id: build
run: |
# pipefail is on by default in Actions bash, so make's rc survives tee
make gpuagent \
GIT_COMMIT=$(git rev-list -1 HEAD --abbrev-commit) \
BUILD_DATE=$(date +%Y-%m-%dT%H:%M:%S%z)
BUILD_DATE=$(date +%Y-%m-%dT%H:%M:%S%z) \
2>&1 | tee build.log

- name: Build summary
if: always()
run: |
BIN=sw/nic/build/x86_64/sim/bin
{
echo "## gpuagent build"
echo ""
echo "- status: **${{ steps.build.outcome }}**"
echo "- commit: \`$(git rev-list -1 HEAD --abbrev-commit)\`"
echo ""
echo "| binary | size | sha256 |"
echo "|---|---|---|"
for b in gpuagent gpuagent_gim gpuagent_mock gpuctl; do
if [ -f "$BIN/$b" ]; then
sz=$(du -h "$BIN/$b" | cut -f1)
sha=$(sha256sum "$BIN/$b" | cut -c1-12)
echo "| $b | $sz | \`$sha\` |"
else
echo "| $b | — | **MISSING** |"
fi
done
} >> "$GITHUB_STEP_SUMMARY"

- name: Upload gpuagent
if: always()
uses: actions/upload-artifact@v4
with:
name: gpuagent
path: sw/nic/build/x86_64/sim/bin/gpuagent
retention-days: 10
if-no-files-found: warn

- name: Upload gpuagent_gim
if: always()
uses: actions/upload-artifact@v4
with:
name: gpuagent_gim
path: sw/nic/build/x86_64/sim/bin/gpuagent_gim
retention-days: 10
if-no-files-found: warn

- name: Upload gpuagent_mock
if: always()
uses: actions/upload-artifact@v4
with:
name: gpuagent_mock
path: sw/nic/build/x86_64/sim/bin/gpuagent_mock
retention-days: 10
if-no-files-found: warn

- name: Upload gpuctl
if: always()
uses: actions/upload-artifact@v4
with:
name: gpuctl
path: sw/nic/build/x86_64/sim/bin/gpuctl
retention-days: 10
if-no-files-found: warn

- name: Upload build log
if: always()
uses: actions/upload-artifact@v4
with:
name: build-log
path: build.log
retention-days: 10
if-no-files-found: warn
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ CUR_USER:=$(shell whoami)
CUR_TIME:=$(shell date +%Y-%m-%d_%H.%M.%S)
GPUAGENT_BLD_CONTAINER_IMAGE ?= gpuagent-builder-rhel:9
GPUAGENT_BLD_CONTAINER_IMAGE_UBUNTU ?= gpuagent-bldr-ubuntu:22.04
# inner build -j width. override: make GPUAGENT_JOBS=N gpuagent. default nproc.
GPUAGENT_JOBS ?= $(shell nproc)
CONTAINER_NAME := gpuagent-ctr-${CUR_USER}_${CUR_TIME}
CONTAINER_WORKDIR := /usr/src/github.com/ROCm/gpu-agent
BUILD_DATE ?= $(shell date +%Y-%m-%dT%H:%M:%S%z)
Expand Down Expand Up @@ -38,7 +40,7 @@ gpuagent:
-v $(CURDIR):$(CONTAINER_WORKDIR) \
-w $(CONTAINER_WORKDIR) \
${GPUAGENT_BLD_CONTAINER_IMAGE} \
bash -c " cd $(CONTAINER_WORKDIR) && source ~/.bashrc && make gopkglist && make -C sw/nic/gpuagent all"
bash -c " cd $(CONTAINER_WORKDIR) && source ~/.bashrc && make gopkglist && make -j$(GPUAGENT_JOBS) -C sw/nic/gpuagent all"

.PHONY: docker-shell
docker-shell:
Expand Down
32 changes: 23 additions & 9 deletions sw/nic/gpuagent/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ SRC := $(shell find $(TOPDIR) -type d \( -path $(EXCLUDE_DIRS) \) -prune -o \
-type d \( -path $(SMI_SRC_DIR) \) -prune -o \
-type d \( -path $(BLD_PROTOGEN_DIR) \) -prune -o \
-type f -name "*.cc" -print)
SRC += $(patsubst $(GPUAGENT_PROTO_DIR)/%.proto, $(GPUAGENT_PROTO_GEN_DIR)/%.pb.cc, $(GPUAGENT_PROTO_SRCS))
SRC += $(patsubst $(GPUAGENT_PROTO_DIR)/%.proto, $(GPUAGENT_PROTO_GEN_DIR)/%.grpc.pb.cc, $(GPUAGENT_PROTO_SRCS))
SRC += $(patsubst $(GOGO_PROTO_DIR)/%.proto, $(BLD_PROTOGEN_DIR)/%.pb.cc, $(GOGO_PROTO_SRCS))
SRC += $(patsubst $(GOGO_PROTO_DIR)/%.proto, $(BLD_PROTOGEN_DIR)/%.grpc.pb.cc, $(GOGO_PROTO_SRCS))
# generated .cc named so grouped-target rules below can declare them as
# buildable targets; else %.o:%.cc skips them under -j and link fails.
GEN_CPP_PB := $(patsubst $(GPUAGENT_PROTO_DIR)/%.proto, $(GPUAGENT_PROTO_GEN_DIR)/%.pb.cc, $(GPUAGENT_PROTO_SRCS))
GEN_CPP_GRPC := $(patsubst $(GPUAGENT_PROTO_DIR)/%.proto, $(GPUAGENT_PROTO_GEN_DIR)/%.grpc.pb.cc, $(GPUAGENT_PROTO_SRCS))
GEN_GOGO_PB := $(patsubst $(GOGO_PROTO_DIR)/%.proto, $(BLD_PROTOGEN_DIR)/%.pb.cc, $(GOGO_PROTO_SRCS))
GEN_GOGO_GRPC := $(patsubst $(GOGO_PROTO_DIR)/%.proto, $(BLD_PROTOGEN_DIR)/%.grpc.pb.cc, $(GOGO_PROTO_SRCS))
GEN_CPP_SRCS := $(GEN_CPP_PB) $(GEN_CPP_GRPC) $(GEN_GOGO_PB) $(GEN_GOGO_GRPC)
SRC += $(GEN_CPP_SRCS)
SRC_C := $(shell find $(TOPDIR) -type d \( -path $(EXCLUDE_DIRS) \) -prune -o \
-type d \( -path $(EXCLUDE_VENDOR) \) -prune -o \
-type d \( -path $(BLD_DIR) \) -prune -o \
Expand Down Expand Up @@ -210,8 +214,14 @@ $(BUILD_LIBS_STAMP):

build-libs: $(BUILD_LIBS_STAMP)

# grouped-target (&:, make>=4.3): one protoc call declared producer of all its
# .cc, so %.o:%.cc resolves every generated .o under -j. stamp order-only = protoc.
$(GEN_GOGO_PB) $(GEN_GOGO_GRPC) &: $(GOGO_PROTO_SRCS) | $(BUILD_LIBS_STAMP)
@mkdir -p ${BLD_PROTOGEN_DIR}
LC_ALL=C LD_LIBRARY_PATH=${PROTOC_LIB_PATH} ${PROTOC} --cpp_out=${BLD_PROTOGEN_DIR} --grpc_out=${BLD_PROTOGEN_DIR} ${PROTOC_CPP_OPTS} ${PROTO_INCS} ${PROTOC_DEFS} ${GOGO_PROTO_SRCS}

gen-protos:
# gpuagent protos: gogo dep = shares gogo include path, gogo generated first.
$(GEN_CPP_PB) $(GEN_CPP_GRPC) &: $(GPUAGENT_PROTO_SRCS) $(GEN_GOGO_PB) | $(BUILD_LIBS_STAMP)
@mkdir -p ${GPUAGENT_PROTO_GEN_DIR}
LC_ALL=C LD_LIBRARY_PATH=${PROTOC_LIB_PATH} ${PROTOC} --cpp_out=${GPUAGENT_PROTO_GEN_DIR} --grpc_out=${GPUAGENT_PROTO_GEN_DIR} ${PROTOC_CPP_OPTS} ${PROTO_INCS} ${PROTOC_DEFS} ${GPUAGENT_PROTO_SRCS}
@mkdir -p ${GPUAGENT_PROTO_GO_GEN_DIR}
Expand All @@ -220,14 +230,18 @@ gen-protos:
--gogofast_out=Mgogo.proto=github.com/gogo/protobuf/gogoproto,plugins=grpc:${GPUAGENT_PROTO_GO_GEN_DIR} \
types.proto ${GPU_PROTO_GO_FILES}

# phony aliases -> real outputs (link targets + `make gen-protos` still work).
.PHONY: gen-protos gogo-protos
gogo-protos: $(GEN_GOGO_PB) $(GEN_GOGO_GRPC)
gen-protos: $(GEN_CPP_PB) $(GEN_CPP_GRPC)

# order-only: objects need generated *.pb.h present, no recompile on proto refresh.
$(OBJ) $(OBJ_GIM) $(OBJ_MOCK): | $(BUILD_LIBS_STAMP) $(GEN_CPP_SRCS)

gpuctl:
@echo "building gpuctl"
CGO_ENABLED=0 go build -C cli -ldflags="-s -w -X github.com/ROCm/gpu-agent/sw/nic/gpuagent/cli/cmd.GpuctlVersion=$(GPUAGENT_VERSION)" -o ${BLD_BIN_DIR}/gpuctl

gogo-protos:
@mkdir -p ${BLD_PROTOGEN_DIR}
LC_ALL=C LD_LIBRARY_PATH=${PROTOC_LIB_PATH} ${PROTOC} --cpp_out=${BLD_PROTOGEN_DIR} --grpc_out=${BLD_PROTOGEN_DIR} ${PROTOC_CPP_OPTS} ${PROTO_INCS} ${PROTOC_DEFS} ${GOGO_PROTO_SRCS}

$(OBJ_DIR)/%.o: $(TOPDIR)/%.cc
@mkdir -p $(dir $@) # Create the necessary subdirectories in temp
$(CC) $(CFLAGS) $(DEFS) $(INCS_AMD_SMI) -DAMD_SMI -D__FNAME__=__FILE__ -DGPUAGENT_VERSION=\"$(GPUAGENT_VERSION)\" -c $< -o $@
Expand Down
4 changes: 4 additions & 0 deletions sw/nic/gpuagent/Makefile.lib
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
CC := gcc
CXX := g++

# libs serial across each other: each recipe already runs make -j$(nproc)
# internally; concurrent libs = Nlibs x nproc oversubscribe -> OOM grpc/boost.
.NOTPARALLEL:

# Third-party build targets
.PHONY: third-party-libs protobuf-build abseil-build grpc-build zeromq-build libev-build boost-build

Expand Down
Loading