Skip to content

Commit

Permalink
Creating version of DiskANN dll for build with dependency on tcmalloc
Browse files Browse the repository at this point in the history
  • Loading branch information
gopal-msr committed Jul 20, 2024
1 parent 74ce806 commit 98141ce
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/dll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ else()
../windows_aligned_file_reader.cpp ../distance.cpp ../memory_mapper.cpp ../index.cpp
../in_mem_data_store.cpp ../in_mem_graph_store.cpp ../math_utils.cpp ../disk_utils.cpp ../filter_utils.cpp
../ann_exception.cpp ../natural_number_set.cpp ../natural_number_map.cpp ../scratch.cpp ../index_factory.cpp ../abstract_index.cpp)
add_library(${PROJECT_NAME}_build SHARED dllmain.cpp ../abstract_data_store.cpp ../partition.cpp ../pq.cpp ../pq_flash_index.cpp ../logger.cpp ../utils.cpp
../windows_aligned_file_reader.cpp ../distance.cpp ../memory_mapper.cpp ../index.cpp
../in_mem_data_store.cpp ../in_mem_graph_store.cpp ../math_utils.cpp ../disk_utils.cpp ../filter_utils.cpp
../ann_exception.cpp ../natural_number_set.cpp ../natural_number_map.cpp ../scratch.cpp ../index_factory.cpp ../abstract_index.cpp)
endif()

set(TARGET_DIR "$<$<CONFIG:Debug>:${CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG}>$<$<CONFIG:Release>:${CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE}>")
Expand All @@ -20,17 +24,34 @@ if (DISKANN_USE_STATIC_LIB)
else()
set(DISKANN_DLL_IMPLIB "${TARGET_DIR}/${PROJECT_NAME}.lib")
target_compile_definitions(${PROJECT_NAME} PRIVATE _USRDLL _WINDLL)

set(DISKANN_DLL_IMPLIB_BUILD "${TARGET_DIR}/${PROJECT_NAME}_build.lib")
target_compile_definitions(${PROJECT_NAME}_build PRIVATE _USRDLL _WINDLL)
target_compile_definitions(${PROJECT_NAME}_build PRIVATE DISKANN_BUILD)
endif()

target_compile_options(${PROJECT_NAME} PRIVATE /GL)
target_include_directories(${PROJECT_NAME} PRIVATE ${DISKANN_MKL_INCLUDE_DIRECTORIES})

target_compile_options(${PROJECT_NAME}_build PRIVATE /GL)
target_include_directories(${PROJECT_NAME}_build PRIVATE ${DISKANN_MKL_INCLUDE_DIRECTORIES})


if (NOT DEFINED DISKANN_USE_STATIC_LIB)
target_link_options(${PROJECT_NAME} PRIVATE /DLL /IMPLIB:${DISKANN_DLL_IMPLIB} /LTCG)
target_link_options(${PROJECT_NAME}_build PRIVATE /DLL /IMPLIB:${DISKANN_DLL_IMPLIB_BUILD} /LTCG)
endif()

target_link_libraries(${PROJECT_NAME} PRIVATE ${DISKANN_MKL_LINK_LIBRARIES})
target_link_libraries(${PROJECT_NAME} PRIVATE synchronization.lib)
target_link_libraries(${PROJECT_NAME}_build PRIVATE ${DISKANN_MKL_LINK_LIBRARIES})
target_link_libraries(${PROJECT_NAME}_build PRIVATE synchronization.lib)

#This is the crux of the build dll
target_link_libraries(${PROJECT_NAME}_build PUBLIC ${DISKANN_DLL_TCMALLOC_LINK_OPTIONS})
set_target_properties(${PROJECT_NAME}_build PROPERTIES LINK_FLAGS /INCLUDE:_tcmalloc)



if (DISKANN_DLL_TCMALLOC_LINK_OPTIONS)
target_link_libraries(${PROJECT_NAME} PUBLIC ${DISKANN_DLL_TCMALLOC_LINK_OPTIONS})
Expand All @@ -43,4 +64,8 @@ foreach(RUNTIME_FILE ${RUNTIME_FILES_TO_COPY})
add_custom_command(TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${RUNTIME_FILE}" "${TARGET_DIR}")
add_custom_command(TARGET ${PROJECT_NAME}_build
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${RUNTIME_FILE}" "${TARGET_DIR}")

endforeach()
5 changes: 5 additions & 0 deletions src/pq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
#include "math_utils.h"
#include "tsl/robin_map.h"

#if defined(RELEASE_UNUSED_TCMALLOC_MEMORY_AT_CHECKPOINTS) && defined(DISKANN_BUILD)
#include "gperftools/malloc_extension.h"
#endif


// block size for reading/processing large files and matrices in blocks
#define BLOCK_SIZE 5000000

Expand Down

0 comments on commit 98141ce

Please sign in to comment.