diff --git a/tools/server/CMakeLists.txt b/tools/server/CMakeLists.txt index 70b8d7da8eab..7218d76847c5 100644 --- a/tools/server/CMakeLists.txt +++ b/tools/server/CMakeLists.txt @@ -35,6 +35,13 @@ target_include_directories(${TARGET} PRIVATE ../mtmd) target_include_directories(${TARGET} PRIVATE ${PROJECT_SOURCE_DIR}) target_link_libraries(${TARGET} PUBLIC llama-common mtmd ${CMAKE_THREAD_LIBS_INIT}) +# Compile in the post-warmup roofline reset only when the HIP profiler is built +# (ggml-cuda-roofline.cpp, linked via ggml-hip). No-op in every other build. +if (GGML_HIP_ROOFLINE) + target_compile_definitions(${TARGET} PRIVATE GGML_HIP_ROOFLINE) + target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../ggml/src/ggml-cuda) +endif() + # llama-server-impl: server logic, reusable by app set(TARGET llama-server-impl) diff --git a/tools/server/server-context.cpp b/tools/server/server-context.cpp index 60c563345399..5833eebaf151 100644 --- a/tools/server/server-context.cpp +++ b/tools/server/server-context.cpp @@ -18,6 +18,13 @@ #include "mtmd.h" #include "mtmd-helper.h" +// Optional per-op roofline profiler (HIP build with GGML_HIP_ROOFLINE). Used to +// discard warmup so the report covers only measured inference. Compiled out +// otherwise. See ggml/src/ggml-cuda/ggml-cuda-roofline.cpp. +#ifdef GGML_HIP_ROOFLINE +#include "ggml-cuda-roofline.h" +#endif + #include #include #include @@ -1527,6 +1534,12 @@ struct server_context_impl { // propagate new defaults back to caller params = params_base; + // Discard warmup from the per-op roofline profiler so the report covers + // only measured inference. Compiled out unless GGML_HIP_ROOFLINE. +#ifdef GGML_HIP_ROOFLINE + ggml_cuda_roofline_reset(); +#endif + if (!is_resume) { return init(); }