You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/01/05 07:33:51 UTC

[GitHub] [incubator-mxnet] yzhliu opened a new pull request #17214: [tvmop] support cuda multi-arch compilation

yzhliu opened a new pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214
 
 
   accept the same (multi) arch setting provided by Makefile

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] leezu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
leezu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#discussion_r363406763
 
 

 ##########
 File path: contrib/tvmop/compile.py
 ##########
 @@ -105,18 +105,13 @@ def get_cuda_arch(arch):
         return arch.split(';')
 
     # the arch string contains '-arch=sm_xx'
+    archs = []
     flags = arch.split()
     for flag in flags:
-        if flag.startswith('-arch='):
-            return flag[len('-arch='):]
+        if flag.startswith('-gencode') or flag.startswith('arch='):
 
 Review comment:
   `if flag.startswith('-gencode')` should never be True, as then line 104 would have been True already?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] leezu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
leezu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#discussion_r363240314
 
 

 ##########
 File path: CMakeLists.txt
 ##########
 @@ -840,7 +841,7 @@ install(TARGETS ${MXNET_INSTALL_TARGETS}
 
 install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dlpack/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dmlc-core/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-if(USE_MKLDNN)
+if(INSTALL_MKLDNN)
 
 Review comment:
   @yzhliu Yes, parent scope is affected in the current case. To fix this problem, you can make use of CMakes function scopes. Ie define a new function insede the BuildTVM.cmake, and do all variable changes inside that function.
   
   You can take 
   https://github.com/apache/incubator-mxnet/blob/3e638b4fc4de959c7afc614facc336a796347c9d/CMakeLists.txt#L407-L414
   as a reference 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] yzhliu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
yzhliu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#discussion_r363440181
 
 

 ##########
 File path: contrib/tvmop/compile.py
 ##########
 @@ -105,18 +105,13 @@ def get_cuda_arch(arch):
         return arch.split(';')
 
     # the arch string contains '-arch=sm_xx'
+    archs = []
     flags = arch.split()
     for flag in flags:
-        if flag.startswith('-arch='):
-            return flag[len('-arch='):]
+        if flag.startswith('-gencode') or flag.startswith('arch='):
 
 Review comment:
   an example input arch string would be
   `-gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=[sm_75,compute_75] --fatbin-options -compress-all`
   
   L104 has semicolon ; after "gencode", I believe it's for single arch compilation @reminisce if I understand correctly.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] leezu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
leezu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#discussion_r363406763
 
 

 ##########
 File path: contrib/tvmop/compile.py
 ##########
 @@ -105,18 +105,13 @@ def get_cuda_arch(arch):
         return arch.split(';')
 
     # the arch string contains '-arch=sm_xx'
+    archs = []
     flags = arch.split()
     for flag in flags:
-        if flag.startswith('-arch='):
-            return flag[len('-arch='):]
+        if flag.startswith('-gencode') or flag.startswith('arch='):
 
 Review comment:
   What's an example of `flags` where `if flag.startswith('-gencode')` here is True but line 104 False?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] TaoLv commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
TaoLv commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#discussion_r363139757
 
 

 ##########
 File path: CMakeLists.txt
 ##########
 @@ -840,7 +841,7 @@ install(TARGETS ${MXNET_INSTALL_TARGETS}
 
 install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dlpack/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dmlc-core/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-if(USE_MKLDNN)
+if(INSTALL_MKLDNN)
 
 Review comment:
   What's the problem with `USE_MKLDNN`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] reminisce commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
reminisce commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#discussion_r363446841
 
 

 ##########
 File path: contrib/tvmop/compile.py
 ##########
 @@ -105,18 +105,13 @@ def get_cuda_arch(arch):
         return arch.split(';')
 
     # the arch string contains '-arch=sm_xx'
+    archs = []
     flags = arch.split()
     for flag in flags:
-        if flag.startswith('-arch='):
-            return flag[len('-arch='):]
+        if flag.startswith('-gencode') or flag.startswith('arch='):
 
 Review comment:
   I believe the example comes from the Makefile setup:
   
   https://github.com/apache/incubator-mxnet/blob/83a23b0988b55c1483f5ecec941207357492bcff/Makefile#L429-L442

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] TaoLv commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
TaoLv commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#discussion_r363144487
 
 

 ##########
 File path: CMakeLists.txt
 ##########
 @@ -840,7 +841,7 @@ install(TARGETS ${MXNET_INSTALL_TARGETS}
 
 install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dlpack/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dmlc-core/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-if(USE_MKLDNN)
+if(INSTALL_MKLDNN)
 
 Review comment:
   I see. So both MXNet and TVM have this `USE_MKLDNN` flag but you don't want to enable it in TVM. Does the `<PARENT_SCOPE>` help here? https://cmake.org/cmake/help/latest/command/set.html#set-normal-variable

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] yzhliu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
yzhliu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#discussion_r363182656
 
 

 ##########
 File path: CMakeLists.txt
 ##########
 @@ -840,7 +841,7 @@ install(TARGETS ${MXNET_INSTALL_TARGETS}
 
 install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dlpack/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dmlc-core/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-if(USE_MKLDNN)
+if(INSTALL_MKLDNN)
 
 Review comment:
   actually I need something opposite of `PARENT_SCOPE`
   
   ```cmake
   option(USE_MKLDNN ON)
   if(USE_MKLDNN)
   ...
   endif()
   if(USE_TVM_OP)
     include(cmake/BuildTVM.cmake)   <- in BuildTVM.cmake I set(USE_MKLDNN OFF)
     ...
   endif()
   if(USE_MKLDNN) <- here it is OFF, while should be ON
   ...
   endif()
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] yzhliu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
yzhliu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#discussion_r363364077
 
 

 ##########
 File path: CMakeLists.txt
 ##########
 @@ -758,11 +759,15 @@ if(USE_DIST_KVSTORE)
   list(APPEND mxnet_LINKER_LIBS ${pslite_LINKER_LIBS})
 endif()
 
-if(USE_TVM_OP)
-  list(APPEND mxnet_LINKER_LIBS ${CMAKE_CURRENT_BINARY_DIR}/3rdparty/tvm/libtvm_runtime.so)
+function(BuildTVMOP)
+  # scope the variables in BuildTVM.cmake to avoid conflict
 
 Review comment:
   @TaoLv @leezu How about this?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] yzhliu commented on issue #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
yzhliu commented on issue #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#issuecomment-571485560
 
 
   Thanks @reminisce @leezu @TaoLv for help. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] yzhliu merged pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
yzhliu merged pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] leezu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
leezu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#discussion_r363406763
 
 

 ##########
 File path: contrib/tvmop/compile.py
 ##########
 @@ -105,18 +105,13 @@ def get_cuda_arch(arch):
         return arch.split(';')
 
     # the arch string contains '-arch=sm_xx'
+    archs = []
     flags = arch.split()
     for flag in flags:
-        if flag.startswith('-arch='):
-            return flag[len('-arch='):]
+        if flag.startswith('-gencode') or flag.startswith('arch='):
 
 Review comment:
   What's an example of `flags` where `if flag.startswith('-gencode')` here is True but line 104 False? When does it occur?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] yzhliu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
yzhliu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#discussion_r363509581
 
 

 ##########
 File path: contrib/tvmop/compile.py
 ##########
 @@ -105,18 +105,13 @@ def get_cuda_arch(arch):
         return arch.split(';')
 
     # the arch string contains '-arch=sm_xx'
+    archs = []
     flags = arch.split()
     for flag in flags:
-        if flag.startswith('-arch='):
-            return flag[len('-arch='):]
+        if flag.startswith('-gencode') or flag.startswith('arch='):
 
 Review comment:
   sorry I'm a bit confused, should I remove L102-L105? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] leezu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
leezu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#discussion_r364252395
 
 

 ##########
 File path: contrib/tvmop/compile.py
 ##########
 @@ -99,24 +99,16 @@ def get_cuda_arch(arch):
     if len(arch) == 0:
         return None
 
-    # the arch string is of format '-gencode;arch=compute_XX,code=sm_XX'
-    # this format is computed by CMake CUDA_SELECT_NVCC_ARCH_FLAGS
-    if arch.startswith('-gencode;'):
-        return arch.split(';')
-
-    # the arch string contains '-arch=sm_xx'
-    flags = arch.split()
+    # an example of arch string,
+    # -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35
+    # -gencode;arch=compute_75,code=[sm_75,compute_75] --fatbin-options -compress-all
+    archs = []
+    flags = arch.replace("-gencode;", "-gencode ").split()
 
 Review comment:
   @yzhliu 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] leezu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
leezu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#discussion_r364252192
 
 

 ##########
 File path: contrib/tvmop/compile.py
 ##########
 @@ -99,24 +99,16 @@ def get_cuda_arch(arch):
     if len(arch) == 0:
         return None
 
-    # the arch string is of format '-gencode;arch=compute_XX,code=sm_XX'
-    # this format is computed by CMake CUDA_SELECT_NVCC_ARCH_FLAGS
-    if arch.startswith('-gencode;'):
-        return arch.split(';')
-
-    # the arch string contains '-arch=sm_xx'
-    flags = arch.split()
+    # an example of arch string,
+    # -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35
+    # -gencode;arch=compute_75,code=[sm_75,compute_75] --fatbin-options -compress-all
+    archs = []
+    flags = arch.replace("-gencode;", "-gencode ").split()
 
 Review comment:
   Should this be `arch.replace(";", " ").split()`? Consider your example of `gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35`. The equivalent case for cmake is `gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35`.
   
   Alternatively you can change the CMakeList `    set(TVM_OP_COMPILE_OPTIONS "${TVM_OP_COMPILE_OPTIONS}" "--cuda-arch" "\"${CUDA_ARCH_FLAGS}\"")` to `    set(TVM_OP_COMPILE_OPTIONS "${TVM_OP_COMPILE_OPTIONS}" "--cuda-arch" "\"${CUDA_ARCH_FLAGS_SPACES}\"")`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] yzhliu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
yzhliu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#discussion_r363143270
 
 

 ##########
 File path: CMakeLists.txt
 ##########
 @@ -840,7 +841,7 @@ install(TARGETS ${MXNET_INSTALL_TARGETS}
 
 install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dlpack/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dmlc-core/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-if(USE_MKLDNN)
+if(INSTALL_MKLDNN)
 
 Review comment:
   in cmake/BuildTVM.cmake I set `USE_MKLDNN` to OFF, does it affect this variable used later in root cmake? what is the best approach to scope an cmake option?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] leezu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
leezu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#discussion_r363443020
 
 

 ##########
 File path: contrib/tvmop/compile.py
 ##########
 @@ -105,18 +105,13 @@ def get_cuda_arch(arch):
         return arch.split(';')
 
     # the arch string contains '-arch=sm_xx'
+    archs = []
     flags = arch.split()
     for flag in flags:
-        if flag.startswith('-arch='):
-            return flag[len('-arch='):]
+        if flag.startswith('-gencode') or flag.startswith('arch='):
 
 Review comment:
   L104 is added for the use-case that the `arch` parameter in `get_cuda_arch(arch)` is based on cmake's `CUDA_SELECT_NVCC_ARCH_FLAGS`. But that should always have a semicolon. Is the example input arch string based on the Makefile setup?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] leezu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation

Posted by GitBox <gi...@apache.org>.
leezu commented on a change in pull request #17214: [tvmop] support cuda multi-arch compilation
URL: https://github.com/apache/incubator-mxnet/pull/17214#discussion_r363514571
 
 

 ##########
 File path: contrib/tvmop/compile.py
 ##########
 @@ -105,18 +105,13 @@ def get_cuda_arch(arch):
         return arch.split(';')
 
     # the arch string contains '-arch=sm_xx'
+    archs = []
     flags = arch.split()
     for flag in flags:
-        if flag.startswith('-arch='):
-            return flag[len('-arch='):]
+        if flag.startswith('-gencode') or flag.startswith('arch='):
 
 Review comment:
   It seems CMake and make based builds pass inputs of two different formats to the `get_cuda_arch(arch)`. Before removing one condition in `get_cuda_arch(arch)`, the Makefile based build would need to be adapted to use `;` as a separator. `;` is used internally by cmake to represent lists.
   
   For now I think it's fine to keep both, because later we anyways plan to remove the Makefile based build

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services