dmlc--dgl
653428bdc7
* [Kernel] Minigun integration and fused kernel support (#519) * kernel interface * add minigun * Add cuda build * functors * working on binary elewise * binary reduce * change kernel interface * WIP * wip * fix minigun * compile * binary reduce kernels * compile * simple test passed * more reducers * fix thrust problem * fix cmake * fix cmake; add proper guard for atomic * WIP: bcast * WIP * bcast kernels * update to new minigun pass-by-value practice * broadcasting dim * add copy src and copy edge * fix linking * fix none array problem * fix copy edge * add device_type and device_id to backend operator * cache csr adj, remove cache for adjmat and incmat * custom ops in backend and pytorch impl * change dgl-mg kernel python interface * add id_mapping var * clean up plus v2e spmv schedule * spmv schedule & clean up fall back * symbolic message and reduce func, remove bundle func * new executors * new backend interface for dgl kernels and pytorch impl * minor fix * fix * fix docstring, comments, func names * nodeflow * fix message id mapping and bugs... * pytorch test case & fix * backward binary reduce * fix bug * WIP: cusparse * change to int32 csr for cusparse workaround * disable cusparse * change back to int64 * broadcasting backward * cusparse; WIP: add rev_csr * unit test for kernels * pytorch backward with dgl kernel * edge softmax * fix backward * improve softmax * cache edge on device * cache mappings on device * fix partial forward code * cusparse done * copy_src_sum with cusparse * rm id getter * reduce grad for broadcast * copy edge reduce backward * kernel unit test for broadcasting * full kernel unit test * add cpu kernels * edge softmax unit test * missing ref * fix compile and small bugs * fix bug in bcast * Add backward both * fix torch utests * expose infershape * create out tensor in python * fix c++ lint * [Kernel] Add GPU utest and kernel utest (#524) * fix gpu utest * cuda utest runnable * temp disable test nodeflow; unified test for kernel * cuda test kernel done * [Kernel] Update kernel branch (#550) * [Model] add multiprocessing training with sampling. (#484) * reorganize sampling code. * add multi-process training. * speed up gcn_cv * fix graphsage_cv. * add new API in graph store. * update barrier impl. * support both local and distributed training. * fix multiprocess train. * fix. * fix barrier. * add script for loading data. * multiprocessing sampling. * accel training. * replace pull with spmv for speedup. * nodeflow copy from parent with context. * enable GPU. * fix a bug in graph store. * enable multi-GPU training. * fix lint. * add comments. * rename to run_store_server.py * fix gcn_cv. * fix a minor bug in sampler. * handle error better in graph store. * improve graphsage_cv for distributed mode. * update README. * fix. * update. * [Tutorial] add sampling tutorial. (#522) * add sampling tutorial. * add readme * update author list. * fix indent in the code. * rename the file. * update tutorial. * fix the last API. * update image. * [BUGFIX] fix the problems in the sampling tutorial. (#523) * add index. * update. * update tutorial. * fix gpu utest * cuda utest runnable * temp disable test nodeflow; unified test for kernel * cuda test kernel done * Fixing typo in JTNN after interface change (#536) * [BugFix] Fix getting src and dst id of ALL edges in NodeFlow.apply_block (#515) * [Bug Fix] Fix inplace op at backend (#546) * Fix inplace operation * fix line seprator * [Feature] Add batch and unbatch for immutable graph (#539) * Add batch and unbatch for immutable graph * fix line seprator * fix lintr * remove unnecessary include * fix code review * [BUGFix] Improve multi-processing training (#526) * fix. * add comment. * remove. * temp fix. * initialize for shared memory. * fix graphsage. * fix gcn. * add more unit tests. * add more tests. * avoid creating shared-memory exclusively. * redefine remote initializer. * improve initializer. * fix unit test. * fix lint. * fix lint. * initialize data in the graph store server properly. * fix test. * fix test. * fix test. * small fix. * add comments. * cleanup server. * test graph store with a random port. * print. * print to stderr. * test1 * test2 * remove comment. * adjust the initializer signature. * [API] update graph store API. (#549) * add init_ndata and init_edata in DGLGraph. * adjust SharedMemoryGraph API. * print warning. * fix comment. * update example * fix. * fix examples. * add unit tests. * add comments. * [Refactor] Immutable graph index (#543) * WIP * header * WIP .cc * WIP * transpose * wip * immutable graph .h and .cc * WIP: nodeflow.cc * compile * remove all tmp dl managed ctx; they caused refcount issue * one simple test * WIP: testing * test_graph * fix graph index * fix bug in sampler; pass pytorch utest * WIP on mxnet * fix lint * fix mxnet unittest w/ unfortunate workaround * fix msvc * fix lint * SliceRows and test_nodeflow * resolve reviews * resolve reviews * try fix win ci * try fix win ci * poke win ci again * poke * lazy multigraph flag; stackoverflow error * revert node subgraph test * lazy object * try fix win build * try fix win build * poke ci * fix build script * fix compile * add a todo * fix reviews * fix compile * [Kernel] Update kernel branch (#576) * [Model] add multiprocessing training with sampling. (#484) * reorganize sampling code. * add multi-process training. * speed up gcn_cv * fix graphsage_cv. * add new API in graph store. * update barrier impl. * support both local and distributed training. * fix multiprocess train. * fix. * fix barrier. * add script for loading data. * multiprocessing sampling. * accel training. * replace pull with spmv for speedup. * nodeflow copy from parent with context. * enable GPU. * fix a bug in graph store. * enable multi-GPU training. * fix lint. * add comments. * rename to run_store_server.py * fix gcn_cv. * fix a minor bug in sampler. * handle error better in graph store. * improve graphsage_cv for distributed mode. * update README. * fix. * update. * [Tutorial] add sampling tutorial. (#522) * add sampling tutorial. * add readme * update author list. * fix indent in the code. * rename the file. * update tutorial. * fix the last API. * update image. * [BUGFIX] fix the problems in the sampling tutorial. (#523) * add index. * update. * update tutorial. * fix gpu utest * cuda utest runnable * temp disable test nodeflow; unified test for kernel * cuda test kernel done * Fixing typo in JTNN after interface change (#536) * [BugFix] Fix getting src and dst id of ALL edges in NodeFlow.apply_block (#515) * [Bug Fix] Fix inplace op at backend (#546) * Fix inplace operation * fix line seprator * [Feature] Add batch and unbatch for immutable graph (#539) * Add batch and unbatch for immutable graph * fix line seprator * fix lintr * remove unnecessary include * fix code review * [BUGFix] Improve multi-processing training (#526) * fix. * add comment. * remove. * temp fix. * initialize for shared memory. * fix graphsage. * fix gcn. * add more unit tests. * add more tests. * avoid creating shared-memory exclusively. * redefine remote initializer. * improve initializer. * fix unit test. * fix lint. * fix lint. * initialize data in the graph store server properly. * fix test. * fix test. * fix test. * small fix. * add comments. * cleanup server. * test graph store with a random port. * print. * print to stderr. * test1 * test2 * remove comment. * adjust the initializer signature. * [API] update graph store API. (#549) * add init_ndata and init_edata in DGLGraph. * adjust SharedMemoryGraph API. * print warning. * fix comment. * update example * fix. * fix examples. * add unit tests. * add comments. * [Refactor] Immutable graph index (#543) * WIP * header * WIP .cc * WIP * transpose * wip * immutable graph .h and .cc * WIP: nodeflow.cc * compile * remove all tmp dl managed ctx; they caused refcount issue * one simple test * WIP: testing * test_graph * fix graph index * fix bug in sampler; pass pytorch utest * WIP on mxnet * fix lint * fix mxnet unittest w/ unfortunate workaround * fix msvc * fix lint * SliceRows and test_nodeflow * resolve reviews * resolve reviews * try fix win ci * try fix win ci * poke win ci again * poke * lazy multigraph flag; stackoverflow error * revert node subgraph test * lazy object * try fix win build * try fix win build * poke ci * fix build script * fix compile * add a todo * fix reviews * fix compile * all demo use python-3 (#555) * [DEMO] Reproduce numbers of distributed training in AMLC giant graph paper (#556) * update * update * update * update num_hops * fix bug * update * report numbers of distributed training in AMLC giant graph paper * [DEMO] Remove duplicate code for sampling (#557) * update * update * re-use single-machine code * update * use relative path * update * update * update * add __init__.py * add __init__.py * import sys, os * fix typo * update * [Perf] Improve performance of graph store. (#554) * fix. * use inplace. * move to shared memory graph store. * fix. * add more unit tests. * fix. * fix test. * fix test. * disable test. * fix. * [BUGIFX] fix a bug in edge_ids (#560) * add test. * fix compute. * fix test. * turn on test. * fix a bug. * add test. * fix. * disable test. * [DEMO] Add Pytorch demo for distributed sampler (#562) * update * update * update * add sender * update * remove duplicate cpde * [Test] Add gtest to project (#547) * add gtest module * add gtest * fix * Update CMakeLists.txt * Update README.md * [Perf] lazily create msg_index. (#563) * lazily create msg_index. * update test. * [BUGFIX] fix bugs for running GCN on giant graphs. (#561) * load mxnet csr. * enable load large csr. * fix * fix. * fix int overflow. * fix test. * [BugFix] Fix error when bfs_level = 0 in Entity Classification with RGCN (#559) * [DEMO] Update demo of distributed sampler (#564) * update * update * update demo * add network cpp test (#565) * Add unittest for C++ RPC (#566) * [CI] Fix CI for cpp test (#570) * fix CI for cpp test * update port number * [Docker] update docker image (#575) * update docker image * specify lint version * rm torch import from unified tests * [Kernel][Scheduler][MXNet] Scheduler for DGL kernels and MXNet backend support (#541) * [Model] add multiprocessing training with sampling. (#484) * reorganize sampling code. * add multi-process training. * speed up gcn_cv * fix graphsage_cv. * add new API in graph store. * update barrier impl. * support both local and distributed training. * fix multiprocess train. * fix. * fix barrier. * add script for loading data. * multiprocessing sampling. * accel training. * replace pull with spmv for speedup. * nodeflow copy from parent with context. * enable GPU. * fix a bug in graph store. * enable multi-GPU training. * fix lint. * add comments. * rename to run_store_server.py * fix gcn_cv. * fix a minor bug in sampler. * handle error better in graph store. * improve graphsage_cv for distributed mode. * update README. * fix. * update. * [Tutorial] add sampling tutorial. (#522) * add sampling tutorial. * add readme * update author list. * fix indent in the code. * rename the file. * update tutorial. * fix the last API. * update image. * [BUGFIX] fix the problems in the sampling tutorial. (#523) * add index. * update. * update tutorial. * fix gpu utest * cuda utest runnable * temp disable test nodeflow; unified test for kernel * cuda test kernel done * edge softmax module * WIP * Fixing typo in JTNN after interface change (#536) * mxnet backend support * improve reduce grad * add max to unittest backend * fix kernel unittest * [BugFix] Fix getting src and dst id of ALL edges in NodeFlow.apply_block (#515) * lint * lint * win build * [Bug Fix] Fix inplace op at backend (#546) * Fix inplace operation * fix line seprator * [Feature] Add batch and unbatch for immutable graph (#539) * Add batch and unbatch for immutable graph * fix line seprator * fix lintr * remove unnecessary include * fix code review * [BUGFix] Improve multi-processing training (#526) * fix. * add comment. * remove. * temp fix. * initialize for shared memory. * fix graphsage. * fix gcn. * add more unit tests. * add more tests. * avoid creating shared-memory exclusively. * redefine remote initializer. * improve initializer. * fix unit test. * fix lint. * fix lint. * initialize data in the graph store server properly. * fix test. * fix test. * fix test. * small fix. * add comments. * cleanup server. * test graph store with a random port. * print. * print to stderr. * test1 * test2 * remove comment. * adjust the initializer signature. * try * fix * fix * fix * fix * fix * try * test * test * test * try * try * try * test * fix * try gen_target * fix gen_target * fix msvc var_args expand issue * fix * [API] update graph store API. (#549) * add init_ndata and init_edata in DGLGraph. * adjust SharedMemoryGraph API. * print warning. * fix comment. * update example * fix. * fix examples. * add unit tests. * add comments. * [Refactor] Immutable graph index (#543) * WIP * header * WIP .cc * WIP * transpose * wip * immutable graph .h and .cc * WIP: nodeflow.cc * compile * remove all tmp dl managed ctx; they caused refcount issue * one simple test * WIP: testing * test_graph * fix graph index * fix bug in sampler; pass pytorch utest * WIP on mxnet * fix lint * fix mxnet unittest w/ unfortunate workaround * fix msvc * fix lint * SliceRows and test_nodeflow * resolve reviews * resolve reviews * try fix win ci * try fix win ci * poke win ci again * poke * lazy multigraph flag; stackoverflow error * revert node subgraph test * lazy object * try fix win build * try fix win build * poke ci * fix build script * fix compile * add a todo * fix reviews * fix compile * WIP * WIP * all demo use python-3 (#555) * ToImmutable and CopyTo * [DEMO] Reproduce numbers of distributed training in AMLC giant graph paper (#556) * update * update * update * update num_hops * fix bug * update * report numbers of distributed training in AMLC giant graph paper * [DEMO] Remove duplicate code for sampling (#557) * update * update * re-use single-machine code * update * use relative path * update * update * update * add __init__.py * add __init__.py * import sys, os * fix typo * update * [Perf] Improve performance of graph store. (#554) * fix. * use inplace. * move to shared memory graph store. * fix. * add more unit tests. * fix. * fix test. * fix test. * disable test. * fix. * [BUGIFX] fix a bug in edge_ids (#560) * add test. * fix compute. * fix test. * turn on test. * fix a bug. * add test. * fix. * disable test. * DGLRetValue DGLContext conversion * [DEMO] Add Pytorch demo for distributed sampler (#562) * update * update * update * add sender * update * remove duplicate cpde * [Test] Add gtest to project (#547) * add gtest module * add gtest * fix * Update CMakeLists.txt * Update README.md * Add support to convert immutable graph to 32 bits * [Perf] lazily create msg_index. (#563) * lazily create msg_index. * update test. * fix binary reduce following new minigun template * enable both int64 and int32 kernels * [BUGFIX] fix bugs for running GCN on giant graphs. (#561) * load mxnet csr. * enable load large csr. * fix * fix. * fix int overflow. * fix test. * new kernel interface done for CPU * docstring * rename & docstring * copy reduce and backward * [BugFix] Fix error when bfs_level = 0 in Entity Classification with RGCN (#559) * [DEMO] Update demo of distributed sampler (#564) * update * update * update demo * adapt cuda kernels to the new interface * add network cpp test (#565) * fix bug * Add unittest for C++ RPC (#566) * [CI] Fix CI for cpp test (#570) * fix CI for cpp test * update port number * [Docker] update docker image (#575) * update docker image * specify lint version * rm torch import from unified tests * remove pytorch-specific test_function * fix unittest * fix * fix unittest backend bug in converting tensor to numpy array * fix * mxnet version * [BUGFIX] fix for MXNet 1.5. (#552) * remove clone. * turn on numpy compatible. * Revert "remove clone." This reverts commit 17bbf76ed72ff178df6b3f35addc428048672457. * revert format changes * fix mxnet api name * revert mistakes in previous revert * roll back CI to 20190523 build * fix unittest * disable test_shared_mem_store.py for now * remove mxnet/test_specialization.py * sync win64 test script * fix lowercase * missing backend in gpu unit test * transpose to get forward graph * pass update all * add sanity check * passing test_specialization.py * fix and pass test_function * fix check * fix pytorch softmax * mxnet kernels * c++ lint * pylint * try * win build * fix * win * ci enable gpu build * init submodule recursively * backend docstring * try * test win dev * doc string * disable pytorch test_nn * try to fix windows issue * bug fixed, revert changes * [Test] fix CI. (#586) * disable unit test in mxnet tutorial. * retry socket connection. * roll back to set_np_compat * try to fix multi-processing test hangs when it fails. * fix test. * fix. * doc string * doc string and clean up * missing field in ctypes * fix node flow schedule and unit test * rename * pylint * copy from parent default context * fix unit test script * fix * demo bug in nodeflow gpu test * [Kernel][Bugfix] fix nodeflow bug (#604) * fix nodeflow bug * remove debug code * add build gtest option * fix cmake; fix graph index bug in spmv.py * remove clone * fix div rhs grad bug * [Kernel] Support full builtin method, edge softmax and unit tests (#605) * add full builtin support * unit test * unit test backend * edge softmax * apply edge with builtin * fix kernel unit test * disable mxnet test_shared_mem_store * gen builtin reduce * enable mxnet gpu unittest * revert some changes * docstring * add note for the hack * [Kernel][Unittest][CI] Fix MXNet GPU CI (#607) * update docker image for MXNet GPU CI * force all dgl graph input and output on CPU * fix gpu unittest * speedup compilation * add some comments * lint * add more comments * fix as requested * add some comments * comment * lint * lint * update pylint * fix as requested * lint * lint * lint * docstrings of python DGL kernel entries * disable lint warnings on arguments in kernel.py * fix docstring in scheduler * fix some bug in unittest; try again * Revert "Merge branch 'kernel' of github.com:zzhang-cn/dgl into kernel" This reverts commit 1d2299e68b004182ea6130b088de1f1122b18a49, reversing changes made to ddc97fbf1bec2b7815c0da7c74f7ecb2f428889b. * Revert "fix some bug in unittest; try again" This reverts commit ddc97fbf1bec2b7815c0da7c74f7ecb2f428889b. * more comprehensive kernel test * remove shape check in test_specialization
398 行
14 KiB
CMake
398 行
14 KiB
CMake
################################################################################################
|
|
# Command alias for debugging messages
|
|
# Usage:
|
|
# dmsg(<message>)
|
|
function(dmsg)
|
|
message(STATUS ${ARGN})
|
|
endfunction()
|
|
|
|
################################################################################################
|
|
# Removes duplicates from list(s)
|
|
# Usage:
|
|
# mshadow_list_unique(<list_variable> [<list_variable>] [...])
|
|
macro(mshadow_list_unique)
|
|
foreach(__lst ${ARGN})
|
|
if(${__lst})
|
|
list(REMOVE_DUPLICATES ${__lst})
|
|
endif()
|
|
endforeach()
|
|
endmacro()
|
|
|
|
################################################################################################
|
|
# Clears variables from list
|
|
# Usage:
|
|
# mshadow_clear_vars(<variables_list>)
|
|
macro(mshadow_clear_vars)
|
|
foreach(_var ${ARGN})
|
|
unset(${_var})
|
|
endforeach()
|
|
endmacro()
|
|
|
|
################################################################################################
|
|
# Removes duplicates from string
|
|
# Usage:
|
|
# mshadow_string_unique(<string_variable>)
|
|
function(mshadow_string_unique __string)
|
|
if(${__string})
|
|
set(__list ${${__string}})
|
|
separate_arguments(__list)
|
|
list(REMOVE_DUPLICATES __list)
|
|
foreach(__e ${__list})
|
|
set(__str "${__str} ${__e}")
|
|
endforeach()
|
|
set(${__string} ${__str} PARENT_SCOPE)
|
|
endif()
|
|
endfunction()
|
|
|
|
################################################################################################
|
|
# Prints list element per line
|
|
# Usage:
|
|
# mshadow_print_list(<list>)
|
|
function(mshadow_print_list)
|
|
foreach(e ${ARGN})
|
|
message(STATUS ${e})
|
|
endforeach()
|
|
endfunction()
|
|
|
|
################################################################################################
|
|
# Function merging lists of compiler flags to single string.
|
|
# Usage:
|
|
# mshadow_merge_flag_lists(out_variable <list1> [<list2>] [<list3>] ...)
|
|
function(mshadow_merge_flag_lists out_var)
|
|
set(__result "")
|
|
foreach(__list ${ARGN})
|
|
foreach(__flag ${${__list}})
|
|
string(STRIP ${__flag} __flag)
|
|
set(__result "${__result} ${__flag}")
|
|
endforeach()
|
|
endforeach()
|
|
string(STRIP ${__result} __result)
|
|
set(${out_var} ${__result} PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
################################################################################################
|
|
# Converts all paths in list to absolute
|
|
# Usage:
|
|
# mshadow_convert_absolute_paths(<list_variable>)
|
|
function(mshadow_convert_absolute_paths variable)
|
|
set(__dlist "")
|
|
foreach(__s ${${variable}})
|
|
get_filename_component(__abspath ${__s} ABSOLUTE)
|
|
list(APPEND __list ${__abspath})
|
|
endforeach()
|
|
set(${variable} ${__list} PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
################################################################################################
|
|
# Reads set of version defines from the header file
|
|
# Usage:
|
|
# mshadow_parse_header(<file> <define1> <define2> <define3> ..)
|
|
macro(mshadow_parse_header FILENAME FILE_VAR)
|
|
set(vars_regex "")
|
|
set(__parnet_scope OFF)
|
|
set(__add_cache OFF)
|
|
foreach(name ${ARGN})
|
|
if("${name}" STREQUAL "PARENT_SCOPE")
|
|
set(__parnet_scope ON)
|
|
elseif("${name}" STREQUAL "CACHE")
|
|
set(__add_cache ON)
|
|
elseif(vars_regex)
|
|
set(vars_regex "${vars_regex}|${name}")
|
|
else()
|
|
set(vars_regex "${name}")
|
|
endif()
|
|
endforeach()
|
|
if(EXISTS "${FILENAME}")
|
|
file(STRINGS "${FILENAME}" ${FILE_VAR} REGEX "#define[ \t]+(${vars_regex})[ \t]+[0-9]+" )
|
|
else()
|
|
unset(${FILE_VAR})
|
|
endif()
|
|
foreach(name ${ARGN})
|
|
if(NOT "${name}" STREQUAL "PARENT_SCOPE" AND NOT "${name}" STREQUAL "CACHE")
|
|
if(${FILE_VAR})
|
|
if(${FILE_VAR} MATCHES ".+[ \t]${name}[ \t]+([0-9]+).*")
|
|
string(REGEX REPLACE ".+[ \t]${name}[ \t]+([0-9]+).*" "\\1" ${name} "${${FILE_VAR}}")
|
|
else()
|
|
set(${name} "")
|
|
endif()
|
|
if(__add_cache)
|
|
set(${name} ${${name}} CACHE INTERNAL "${name} parsed from ${FILENAME}" FORCE)
|
|
elseif(__parnet_scope)
|
|
set(${name} "${${name}}" PARENT_SCOPE)
|
|
endif()
|
|
else()
|
|
unset(${name} CACHE)
|
|
endif()
|
|
endif()
|
|
endforeach()
|
|
endmacro()
|
|
|
|
################################################################################################
|
|
# Reads single version define from the header file and parses it
|
|
# Usage:
|
|
# mshadow_parse_header_single_define(<library_name> <file> <define_name>)
|
|
function(mshadow_parse_header_single_define LIBNAME HDR_PATH VARNAME)
|
|
set(${LIBNAME}_H "")
|
|
if(EXISTS "${HDR_PATH}")
|
|
file(STRINGS "${HDR_PATH}" ${LIBNAME}_H REGEX "^#define[ \t]+${VARNAME}[ \t]+\"[^\"]*\".*$" LIMIT_COUNT 1)
|
|
endif()
|
|
|
|
if(${LIBNAME}_H)
|
|
string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_MAJOR "${${LIBNAME}_H}")
|
|
string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_MINOR "${${LIBNAME}_H}")
|
|
string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_PATCH "${${LIBNAME}_H}")
|
|
set(${LIBNAME}_VERSION_MAJOR ${${LIBNAME}_VERSION_MAJOR} ${ARGN} PARENT_SCOPE)
|
|
set(${LIBNAME}_VERSION_MINOR ${${LIBNAME}_VERSION_MINOR} ${ARGN} PARENT_SCOPE)
|
|
set(${LIBNAME}_VERSION_PATCH ${${LIBNAME}_VERSION_PATCH} ${ARGN} PARENT_SCOPE)
|
|
set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_MAJOR}.${${LIBNAME}_VERSION_MINOR}.${${LIBNAME}_VERSION_PATCH}" PARENT_SCOPE)
|
|
|
|
# append a TWEAK version if it exists:
|
|
set(${LIBNAME}_VERSION_TWEAK "")
|
|
if("${${LIBNAME}_H}" MATCHES "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$")
|
|
set(${LIBNAME}_VERSION_TWEAK "${CMAKE_MATCH_1}" ${ARGN} PARENT_SCOPE)
|
|
endif()
|
|
if(${LIBNAME}_VERSION_TWEAK)
|
|
set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_STRING}.${${LIBNAME}_VERSION_TWEAK}" ${ARGN} PARENT_SCOPE)
|
|
else()
|
|
set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_STRING}" ${ARGN} PARENT_SCOPE)
|
|
endif()
|
|
endif()
|
|
endfunction()
|
|
|
|
########################################################################################################
|
|
# An option that the user can select. Can accept condition to control when option is available for user.
|
|
# Usage:
|
|
# mshadow_option(<option_variable> "doc string" <initial value or boolean expression> [IF <condition>])
|
|
function(mshadow_option variable description value)
|
|
set(__value ${value})
|
|
set(__condition "")
|
|
set(__varname "__value")
|
|
foreach(arg ${ARGN})
|
|
if(arg STREQUAL "IF" OR arg STREQUAL "if")
|
|
set(__varname "__condition")
|
|
else()
|
|
list(APPEND ${__varname} ${arg})
|
|
endif()
|
|
endforeach()
|
|
unset(__varname)
|
|
if("${__condition}" STREQUAL "")
|
|
set(__condition 2 GREATER 1)
|
|
endif()
|
|
|
|
if(${__condition})
|
|
if("${__value}" MATCHES ";")
|
|
if(${__value})
|
|
option(${variable} "${description}" ON)
|
|
else()
|
|
option(${variable} "${description}" OFF)
|
|
endif()
|
|
elseif(DEFINED ${__value})
|
|
if(${__value})
|
|
option(${variable} "${description}" ON)
|
|
else()
|
|
option(${variable} "${description}" OFF)
|
|
endif()
|
|
else()
|
|
option(${variable} "${description}" ${__value})
|
|
endif()
|
|
else()
|
|
unset(${variable} CACHE)
|
|
endif()
|
|
endfunction()
|
|
|
|
################################################################################################
|
|
# Utility macro for comparing two lists. Used for CMake debugging purposes
|
|
# Usage:
|
|
# mshadow_compare_lists(<list_variable> <list2_variable> [description])
|
|
function(mshadow_compare_lists list1 list2 desc)
|
|
set(__list1 ${${list1}})
|
|
set(__list2 ${${list2}})
|
|
list(SORT __list1)
|
|
list(SORT __list2)
|
|
list(LENGTH __list1 __len1)
|
|
list(LENGTH __list2 __len2)
|
|
|
|
if(NOT ${__len1} EQUAL ${__len2})
|
|
message(FATAL_ERROR "Lists are not equal. ${__len1} != ${__len2}. ${desc}")
|
|
endif()
|
|
|
|
foreach(__i RANGE 1 ${__len1})
|
|
math(EXPR __index "${__i}- 1")
|
|
list(GET __list1 ${__index} __item1)
|
|
list(GET __list2 ${__index} __item2)
|
|
if(NOT ${__item1} STREQUAL ${__item2})
|
|
message(FATAL_ERROR "Lists are not equal. Differ at element ${__index}. ${desc}")
|
|
endif()
|
|
endforeach()
|
|
endfunction()
|
|
|
|
################################################################################################
|
|
# Command for disabling warnings for different platforms (see below for gcc and VisualStudio)
|
|
# Usage:
|
|
# mshadow_warnings_disable(<CMAKE_[C|CXX]_FLAGS[_CONFIGURATION]> -Wshadow /wd4996 ..,)
|
|
macro(mshadow_warnings_disable)
|
|
set(_flag_vars "")
|
|
set(_msvc_warnings "")
|
|
set(_gxx_warnings "")
|
|
|
|
foreach(arg ${ARGN})
|
|
if(arg MATCHES "^CMAKE_")
|
|
list(APPEND _flag_vars ${arg})
|
|
elseif(arg MATCHES "^/wd")
|
|
list(APPEND _msvc_warnings ${arg})
|
|
elseif(arg MATCHES "^-W")
|
|
list(APPEND _gxx_warnings ${arg})
|
|
endif()
|
|
endforeach()
|
|
|
|
if(NOT _flag_vars)
|
|
set(_flag_vars CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
|
endif()
|
|
|
|
if(MSVC AND _msvc_warnings)
|
|
foreach(var ${_flag_vars})
|
|
foreach(warning ${_msvc_warnings})
|
|
set(${var} "${${var}} ${warning}")
|
|
endforeach()
|
|
endforeach()
|
|
elseif((CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) AND _gxx_warnings)
|
|
foreach(var ${_flag_vars})
|
|
foreach(warning ${_gxx_warnings})
|
|
if(NOT warning MATCHES "^-Wno-")
|
|
string(REPLACE "${warning}" "" ${var} "${${var}}")
|
|
string(REPLACE "-W" "-Wno-" warning "${warning}")
|
|
endif()
|
|
set(${var} "${${var}} ${warning}")
|
|
endforeach()
|
|
endforeach()
|
|
endif()
|
|
mshadow_clear_vars(_flag_vars _msvc_warnings _gxx_warnings)
|
|
endmacro()
|
|
|
|
################################################################################################
|
|
# Helper function get current definitions
|
|
# Usage:
|
|
# mshadow_get_current_definitions(<definitions_variable>)
|
|
function(mshadow_get_current_definitions definitions_var)
|
|
get_property(current_definitions DIRECTORY PROPERTY COMPILE_DEFINITIONS)
|
|
set(result "")
|
|
|
|
foreach(d ${current_definitions})
|
|
list(APPEND result -D${d})
|
|
endforeach()
|
|
|
|
mshadow_list_unique(result)
|
|
set(${definitions_var} ${result} PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
################################################################################################
|
|
# Helper function get current includes/definitions
|
|
# Usage:
|
|
# mshadow_get_current_cflags(<cflagslist_variable>)
|
|
function(mshadow_get_current_cflags cflags_var)
|
|
get_property(current_includes DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
|
|
mshadow_convert_absolute_paths(current_includes)
|
|
mshadow_get_current_definitions(cflags)
|
|
|
|
foreach(i ${current_includes})
|
|
list(APPEND cflags "-I${i}")
|
|
endforeach()
|
|
|
|
mshadow_list_unique(cflags)
|
|
set(${cflags_var} ${cflags} PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
################################################################################################
|
|
# Helper function to parse current linker libs into link directories, libflags and osx frameworks
|
|
# Usage:
|
|
# mshadow_parse_linker_libs(<mshadow_LINKER_LIBS_var> <directories_var> <libflags_var> <frameworks_var>)
|
|
function(mshadow_parse_linker_libs mshadow_LINKER_LIBS_variable folders_var flags_var frameworks_var)
|
|
|
|
set(__unspec "")
|
|
set(__debug "")
|
|
set(__optimized "")
|
|
set(__framework "")
|
|
set(__varname "__unspec")
|
|
|
|
# split libs into debug, optimized, unspecified and frameworks
|
|
foreach(list_elem ${${mshadow_LINKER_LIBS_variable}})
|
|
if(list_elem STREQUAL "debug")
|
|
set(__varname "__debug")
|
|
elseif(list_elem STREQUAL "optimized")
|
|
set(__varname "__optimized")
|
|
elseif(list_elem MATCHES "^-framework[ \t]+([^ \t].*)")
|
|
list(APPEND __framework -framework ${CMAKE_MATCH_1})
|
|
else()
|
|
list(APPEND ${__varname} ${list_elem})
|
|
set(__varname "__unspec")
|
|
endif()
|
|
endforeach()
|
|
|
|
# attach debug or optimized libs to unspecified according to current configuration
|
|
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
|
set(__libs ${__unspec} ${__debug})
|
|
else()
|
|
set(__libs ${__unspec} ${__optimized})
|
|
endif()
|
|
|
|
set(libflags "")
|
|
set(folders "")
|
|
|
|
# convert linker libraries list to link flags
|
|
foreach(lib ${__libs})
|
|
if(TARGET ${lib})
|
|
list(APPEND folders $<TARGET_LINKER_FILE_DIR:${lib}>)
|
|
list(APPEND libflags -l${lib})
|
|
elseif(lib MATCHES "^-l.*")
|
|
list(APPEND libflags ${lib})
|
|
elseif(IS_ABSOLUTE ${lib})
|
|
get_filename_component(name_we ${lib} NAME_WE)
|
|
get_filename_component(folder ${lib} PATH)
|
|
|
|
string(REGEX MATCH "^lib(.*)" __match ${name_we})
|
|
list(APPEND libflags -l${CMAKE_MATCH_1})
|
|
list(APPEND folders ${folder})
|
|
else()
|
|
message(FATAL_ERROR "Logic error. Need to update cmake script")
|
|
endif()
|
|
endforeach()
|
|
|
|
mshadow_list_unique(libflags folders)
|
|
|
|
set(${folders_var} ${folders} PARENT_SCOPE)
|
|
set(${flags_var} ${libflags} PARENT_SCOPE)
|
|
set(${frameworks_var} ${__framework} PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
################################################################################################
|
|
# Helper function to detect Darwin version, i.e. 10.8, 10.9, 10.10, ....
|
|
# Usage:
|
|
# mshadow_detect_darwin_version(<version_variable>)
|
|
function(mshadow_detect_darwin_version output_var)
|
|
if(APPLE)
|
|
execute_process(COMMAND /usr/bin/sw_vers -productVersion
|
|
RESULT_VARIABLE __sw_vers OUTPUT_VARIABLE __sw_vers_out
|
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
set(${output_var} ${__sw_vers_out} PARENT_SCOPE)
|
|
else()
|
|
set(${output_var} "" PARENT_SCOPE)
|
|
endif()
|
|
endfunction()
|
|
|
|
################################################################################################
|
|
# Convenient command to setup source group for IDEs that support this feature (VS, XCode)
|
|
# Usage:
|
|
# caffe_source_group(<group> GLOB[_RECURSE] <globbing_expression>)
|
|
function(mshadow_source_group group)
|
|
cmake_parse_arguments(CAFFE_SOURCE_GROUP "" "" "GLOB;GLOB_RECURSE" ${ARGN})
|
|
if(CAFFE_SOURCE_GROUP_GLOB)
|
|
file(GLOB srcs1 ${CAFFE_SOURCE_GROUP_GLOB})
|
|
source_group(${group} FILES ${srcs1})
|
|
endif()
|
|
|
|
if(CAFFE_SOURCE_GROUP_GLOB_RECURSE)
|
|
file(GLOB_RECURSE srcs2 ${CAFFE_SOURCE_GROUP_GLOB_RECURSE})
|
|
source_group(${group} FILES ${srcs2})
|
|
endif()
|
|
endfunction() |