rdma.cmake 3.4 KB
Newer Older
B
backyes 已提交
1 2 3 4 5 6 7
# user should download rdma first from subversion repository

# execute following instruction to download svn mannally
# svn co https://svn.baidu.com/sys/ip/trunk/rdma/sockrdmav1 rdma/
# svn co https://svn.baidu.com/sys/ip/trunk/rdma/thirdparty rdma/
# we use static output in svn repositories to avoid implict bugs from not standard runtime env.

L
liaogang 已提交
8 9
if(WITH_RDMA)
  set(RDMA_ROOT $ENV{RDMA_ROOT} CACHE PATH "Folder contains RDMA sock library and thirdparty library")
B
backyes 已提交
10

L
liaogang 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23
  function(generate_rdma_links)
    #redirect to current DIR to isolate the pollution from system runtime environment
    #it can benifits unified control for different gcc environment. 
    #e.g, by default gcc48 did not refer /usr/lib64 which could contain low version
    #runtime libraries that will crash process while loading it. That redirect trick
    #can fix it.
    execute_process(
      COMMAND mkdir -p librdma
      COMMAND ln -s -f /usr/lib64/libibverbs.so.1.0.0 librdma/libibverbs.so.1
      COMMAND ln -s -f /usr/lib64/libibverbs.so.1.0.0 librdma/libibverbs.so
      COMMAND ln -s -f /usr/lib64/librdmacm.so.1.0.0 librdma/librdmacm.so.1
      COMMAND ln -s -f /usr/lib64/librdmacm.so.1.0.0 librdma/librdmacm.so 
      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
B
backyes 已提交
24
    )
L
liaogang 已提交
25
  endfunction(generate_rdma_links)
B
backyes 已提交
26

L
liaogang 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40
  #check and set headers
  find_path(RDMA_INC_SXISOCK sxi_sock.h PATHS ${RDMA_ROOT}/sockrdmav1/output/include)
  find_path(RDMA_INC_XIO libxio.h PATHS ${RDMA_ROOT}/thirdparty/output/accelio)
  find_path(RDMA_INC_EVENT event2 PATHS ${RDMA_ROOT}/thirdparty/output/libevent)
  find_path(RDMA_INC_NUMA numa.h PATHS ${RDMA_ROOT}/thirdparty/output/libnuma)

  #check and set libs
  find_library(RDMA_LIB_SXISOCK NAMES sxisock PATHS ${RDMA_ROOT}/sockrdmav1/output)
  find_library(RDMA_LIB_XIO NAMES xio PATHS ${RDMA_ROOT}/thirdparty/output/accelio)
  find_library(RDMA_LIB_EVENT NAMES event PATHS ${RDMA_ROOT}/thirdparty/output/libevent)
  find_library(RDMA_LIB_EVENT_CORE NAMES event_core PATHS ${RDMA_ROOT}/thirdparty/output/libevent)
  find_library(RDMA_LIB_EVENT_EXTRA NAMES event_extra PATHS ${RDMA_ROOT}/thirdparty/output/libevent)
  find_library(RDMA_LIB_EVENT_PTHREADS NAMES event_pthreads PATHS ${RDMA_ROOT}/thirdparty/output/libevent)
  find_library(RDMA_LIB_NUMA NAMES numa PATHS ${RDMA_ROOT}/thirdparty/output/libnuma)
B
backyes 已提交
41

L
liaogang 已提交
42 43 44 45 46 47 48 49 50 51 52 53 54
  if(
      RDMA_INC_SXISOCK AND
      RDMA_INC_XIO AND
      RDMA_INC_EVENT AND
      RDMA_INC_NUMA AND
      RDMA_LIB_SXISOCK AND 
      RDMA_LIB_XIO AND
      RDMA_LIB_EVENT AND
      RDMA_LIB_EVENT_CORE AND
      RDMA_LIB_EVENT_EXTRA AND
      RDMA_LIB_EVENT_PTHREADS AND
      RDMA_LIB_NUMA
      )
B
backyes 已提交
55

L
liaogang 已提交
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
    set(RDMA_INC_DIR 
      ${RDMA_INC_SXISOCK} 
      ${RDMA_INC_XIO}
      ${RDMA_INC_EVENT}
      ${RDMA_INC_NUMA})
    set(RDMA_LIBS  
      ${RDMA_LIB_SXISOCK} 
      ${RDMA_LIB_XIO} 
      ${RDMA_LIB_EVENT} 
      ${RDMA_LIB_EVENT_CORE} 
      ${RDMA_LIB_EVENT_EXTRA} 
      ${RDMA_LIB_EVENT_PTHREADS} 
      ${RDMA_LIB_NUMA} 
      )
    set(RDMA_LD_FLAGS "-L./librdma -libverbs -lrdmacm -Xlinker -rpath ./librdma")
    include_directories("${RDMA_INC_DIR}")
  else()
    #if this module is not called, RDMA_INC_DIR RDMA_LIBS will be null, so top module always refer this variable
    message(FATAL_ERROR, "RDMA libraries are not found, try to set RDMA_ROOT or check all related libraries.")
  endif()
else(WITH_RDMA)
  set(RDMA_LIBS "")
  set(RDMA_LD_FLAGS "")
  add_definitions(-DPADDLE_DISABLE_RDMA)
endif(WITH_RDMA)