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/07/09 21:14:25 UTC

[GitHub] [incubator-mxnet] ptrendx opened a new pull request #18683: [WIP] Expand NVTX usage

ptrendx opened a new pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683


   ## Description ##
   This PR improves the experience when profiling MXNet under nvprof or Nsight Systems, by expanding NVTX functionality.
   It was used successfully for some time in the NVIDIA NGC container.
   
   ## Checklist ##
   ### Essentials ###
   Please feel free to remove inapplicable items for your PR.
   - [ ] Changes are complete (i.e. I finished coding on this PR)
   - [ ] Code is well-documented: 
   - For user-facing API changes, API doc string has been updated. 
   - For new C++ functions in header files, their functionalities and arguments are documented. 
   - [x] To the best of my knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change
   
   ### Changes ###
   - [x] Added C API for NVTX ranges push/pop
   - [x] Added C API to start/stop profiling via nvprof/NSight Systems
   - [x] Added Python API corresponding to the C API
   - [ ] Added automatic ranges to MXNet operators
   


----------------------------------------------------------------
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



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#discussion_r707783839



##########
File path: src/common/nvtx.h
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef MXNET_COMMON_NVTX_H_
+#define MXNET_COMMON_NVTX_H_
+
+#if MXNET_USE_CUDA && MXNET_USE_NVTX
+#include <cuda.h>
+#include <cuda_runtime.h>
+#include <nvToolsExtCuda.h>
+#include <vector>
+#include <string>
+#include <cstring>
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+
+class NVTXDuration {
+ public:
+  explicit NVTXDuration(const char *name) noexcept
+      : range_id_(0), name_(name) {}
+
+  inline void start() {
+    range_id_ = nvtxRangeStartA(name_);
+  }
+
+  inline void stop() {
+    nvtxRangeEnd(range_id_);
+  }
+
+ private:
+  nvtxRangeId_t range_id_;
+  const char *name_;
+};
+
+// Utility class for NVTX
+class nvtx {
+ public:
+  // Palette of colors (make sure to add new colors to the vector in nameToColor()).
+  static const uint32_t kRed     = 0xFF0000;
+  static const uint32_t kGreen   = 0x00FF00;
+  static const uint32_t kBlue    = 0x0000FF;
+  static const uint32_t kYellow  = 0xB58900;
+  static const uint32_t kOrange  = 0xCB4B16;
+  static const uint32_t kRed1    = 0xDC322F;
+  static const uint32_t kMagenta = 0xD33682;
+  static const uint32_t kViolet  = 0x6C71C4;
+  static const uint32_t kBlue1   = 0x268BD2;
+  static const uint32_t kCyan    = 0x2AA198;
+  static const uint32_t kGreen1  = 0x859900;
+
+  static void gpuRangeStart(const uint32_t rgb, const std::string& range_name) {

Review comment:
       It is a reference to a string, so there is no copying here (`c_str()` does not copy either). I believe in the threaded engine the nvtx_name is a string anyway, so that is also not doing any copies.




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#issuecomment-925995097


   Jenkins CI successfully triggered : [unix-cpu]


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] DickJC123 commented on a change in pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
DickJC123 commented on a change in pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#discussion_r708761641



##########
File path: python/mxnet/cuda_utils.py
##########
@@ -0,0 +1,37 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Provides python interface to cuda-related functions of the mxnet library."""
+from .base import _LIB, mx_uint, c_str, check_call
+
+def nvtx_range_push(name, color=13323030):

Review comment:
       If you're not fond of the code repetition, at least the following smaller edit explains the magic number:
   ```
   def nvtx_range_push(name, color=0xCB4B16):    # default color is orange
   ```




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#discussion_r707593814



##########
File path: src/common/nvtx.h
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef MXNET_COMMON_NVTX_H_
+#define MXNET_COMMON_NVTX_H_
+
+#if MXNET_USE_CUDA && MXNET_USE_NVTX
+#include <cuda.h>
+#include <cuda_runtime.h>
+#include <nvToolsExtCuda.h>
+#include <vector>
+#include <string>
+#include <cstring>
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+
+class NVTXDuration {
+ public:
+  explicit NVTXDuration(const char *name) noexcept
+      : range_id_(0), name_(name) {}
+
+  inline void start() {
+    range_id_ = nvtxRangeStartA(name_);
+  }
+
+  inline void stop() {
+    nvtxRangeEnd(range_id_);
+  }
+
+ private:
+  nvtxRangeId_t range_id_;
+  const char *name_;
+};
+
+// Utility class for NVTX
+class nvtx {
+ public:
+  // Palette of colors (make sure to add new colors to the vector in nameToColor()).
+  static const uint32_t kRed     = 0xFF0000;
+  static const uint32_t kGreen   = 0x00FF00;
+  static const uint32_t kBlue    = 0x0000FF;
+  static const uint32_t kYellow  = 0xB58900;
+  static const uint32_t kOrange  = 0xCB4B16;
+  static const uint32_t kRed1    = 0xDC322F;
+  static const uint32_t kMagenta = 0xD33682;
+  static const uint32_t kViolet  = 0x6C71C4;
+  static const uint32_t kBlue1   = 0x268BD2;
+  static const uint32_t kCyan    = 0x2AA198;
+  static const uint32_t kGreen1  = 0x859900;
+
+  static void gpuRangeStart(const uint32_t rgb, const std::string& range_name) {

Review comment:
       Not sure I your concern - nvtxRangePush is not an async call. It just puts the name and a timestamp into the database and that's it (and yes, it copies the string in the process).




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on pull request #18683: [WIP] Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
szha commented on pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#issuecomment-673897547


   @mxnet-bot run ci [centos-cpu, miscellaneous]


----------------------------------------------------------------
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



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#issuecomment-924431840


   @mxnet-bot run ci [unix-cpu, website]


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] DickJC123 commented on a change in pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
DickJC123 commented on a change in pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#discussion_r706565838



##########
File path: python/mxnet/cuda_utils.py
##########
@@ -0,0 +1,37 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Provides python interface to cuda-related functions of the mxnet library."""
+from .base import _LIB, mx_uint, c_str, check_call
+
+def nvtx_range_push(name, color=13323030):

Review comment:
       I don't enjoy suggesting a code repetition, but isn't the following an improvement over letting python users have to make their own colors:
   ```
   class Nvtx:
       # Palette of colors
       RED = 0xFF0000
       GREEN = 0x00FF00
       BLUE = 0x0000FF
       YELLOW = 0xB58900
       ORANGE = 0xCB4B16
       RED = 0xDC322F
       MAGENTA = 0xD33682
       VIOLET = 0x6C71C4
       BLUE1 = 0x268BD2
       CYAN = 0x2AA198
       GREEN = 0x859900
   
   def nvtx_range_push(name, color=Nvtx.ORANGE):
   ```




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#discussion_r710555213



##########
File path: src/common/cuda/nvtx.h
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef MXNET_COMMON_CUDA_NVTX_H_
+#define MXNET_COMMON_CUDA_NVTX_H_
+
+#if MXNET_USE_CUDA && MXNET_USE_NVTX
+#include <cuda.h>
+#include <cuda_runtime.h>
+#include <nvToolsExtCuda.h>
+#include <vector>
+#include <string>
+#include <cstring>
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+
+class NVTXDuration {
+ public:
+  explicit NVTXDuration(const char *name) noexcept
+      : range_id_(0), name_(name) {}
+
+  inline void start() {
+    range_id_ = nvtxRangeStartA(name_);
+  }
+
+  inline void stop() {
+    nvtxRangeEnd(range_id_);
+  }
+
+ private:
+  nvtxRangeId_t range_id_;
+  const char *name_;
+};
+
+// Utility class for NVTX
+class nvtx {
+ public:
+  // Palette of colors (make sure to add new colors to the vector in nameToColor()).
+  static const uint32_t kRed     = 0xFF0000;
+  static const uint32_t kGreen   = 0x00FF00;
+  static const uint32_t kBlue    = 0x0000FF;
+  static const uint32_t kYellow  = 0xB58900;
+  static const uint32_t kOrange  = 0xCB4B16;
+  static const uint32_t kRed1    = 0xDC322F;
+  static const uint32_t kMagenta = 0xD33682;
+  static const uint32_t kViolet  = 0x6C71C4;
+  static const uint32_t kBlue1   = 0x268BD2;
+  static const uint32_t kCyan    = 0x2AA198;
+  static const uint32_t kGreen1  = 0x859900;
+
+  static void gpuRangeStart(const uint32_t rgb, const std::string& range_name) {
+    nvtxEventAttributes_t att;
+    att.version = NVTX_VERSION;
+    att.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
+    att.colorType = NVTX_COLOR_ARGB;
+    att.color = rgb | 0xff000000;
+    att.messageType = NVTX_MESSAGE_TYPE_ASCII;
+    att.message.ascii = range_name.c_str();
+    nvtxRangePushEx(&att);
+  }
+
+  // Utility to map a range name prefix to a random color based on its hash
+  static uint32_t nameToColor(const std::string& range_name, int prefix_len) {
+    static std::vector<uint32_t> colors{kRed, kGreen, kBlue, kYellow, kOrange, kRed1, kMagenta,
+                                        kViolet, kBlue1, kCyan, kGreen1};
+    std::string s(range_name, 0, prefix_len);
+    std::hash<std::string> hash_fn;
+    return colors[hash_fn(s) % colors.size()];
+  }
+
+  // Utility to map a range name to a random color based on its hash
+  static uint32_t nameToColor(const char *range_name) {

Review comment:
       :+1:




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] DickJC123 commented on a change in pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
DickJC123 commented on a change in pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#discussion_r708758413



##########
File path: src/common/nvtx.h
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef MXNET_COMMON_NVTX_H_
+#define MXNET_COMMON_NVTX_H_
+
+#if MXNET_USE_CUDA && MXNET_USE_NVTX
+#include <cuda.h>
+#include <cuda_runtime.h>
+#include <nvToolsExtCuda.h>
+#include <vector>
+#include <string>
+#include <cstring>
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+
+class NVTXDuration {
+ public:
+  explicit NVTXDuration(const char *name) noexcept
+      : range_id_(0), name_(name) {}
+
+  inline void start() {
+    range_id_ = nvtxRangeStartA(name_);
+  }
+
+  inline void stop() {
+    nvtxRangeEnd(range_id_);
+  }
+
+ private:
+  nvtxRangeId_t range_id_;
+  const char *name_;
+};
+
+// Utility class for NVTX
+class nvtx {
+ public:
+  // Palette of colors (make sure to add new colors to the vector in nameToColor()).
+  static const uint32_t kRed     = 0xFF0000;
+  static const uint32_t kGreen   = 0x00FF00;
+  static const uint32_t kBlue    = 0x0000FF;
+  static const uint32_t kYellow  = 0xB58900;
+  static const uint32_t kOrange  = 0xCB4B16;
+  static const uint32_t kRed1    = 0xDC322F;
+  static const uint32_t kMagenta = 0xD33682;
+  static const uint32_t kViolet  = 0x6C71C4;
+  static const uint32_t kBlue1   = 0x268BD2;
+  static const uint32_t kCyan    = 0x2AA198;
+  static const uint32_t kGreen1  = 0x859900;
+
+  static void gpuRangeStart(const uint32_t rgb, const std::string& range_name) {

Review comment:
       In threaded engine, the following does a copy that could be avoided if everything was handled as a `const char *`:
   ```
   auto nvtx_name = opr_block->opr->opr_name != "" ? opr_block->opr->opr_name : "Op";
   ```
   so perhaps like:
   ```
   auto nvtx_name = opr_block->opr->opr_name.size() ? opr_block->opr->opr_name.c_str() : "Op";
   ```
   It's a nit as I say, so I'm OK leaving it as: `const std::string& range_name`.  Given that though, the two overloaded nameToColor() signatures should be consistent in their use of std::string (see an additional suggestion).




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] DickJC123 commented on a change in pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
DickJC123 commented on a change in pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#discussion_r713252701



##########
File path: python/mxnet/cuda_utils.py
##########
@@ -0,0 +1,37 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Provides python interface to cuda-related functions of the mxnet library."""
+from .base import _LIB, mx_uint, c_str, check_call
+
+def nvtx_range_push(name, color=13323030):

Review comment:
       Couple of new comments.  First, I somehow miscopied the enums in my suggestion above.  The second 'RED' should be 'RED1' to mirror what's in nvtx.h.  Second, the colors set up in the backend are currently only used to assign colors by default based on a hash of the range name.  Perhaps you'd consider exposing this the same way to Python?  So for example,
   ```
   def nvtx_range_push(name, color=None):    # if color is None, then assign a color based on a hash of name
   ```
   




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#issuecomment-914578669


   @mxnet-bot run ci [unix-cpu]


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18683: [WIP] Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#issuecomment-783618611


   It is currently on hold - I got sidetracked to other things and am not sure exactly when I will have time to finish it - I still intend to do that, though.


----------------------------------------------------------------
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



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #18683: [WIP] Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#issuecomment-673897574


   Jenkins CI successfully triggered : [centos-cpu, miscellaneous]


----------------------------------------------------------------
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



[GitHub] [incubator-mxnet] DickJC123 commented on a change in pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
DickJC123 commented on a change in pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#discussion_r706565838



##########
File path: python/mxnet/cuda_utils.py
##########
@@ -0,0 +1,37 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Provides python interface to cuda-related functions of the mxnet library."""
+from .base import _LIB, mx_uint, c_str, check_call
+
+def nvtx_range_push(name, color=13323030):

Review comment:
       I don't enjoy suggesting a code repetition, but isn't the following an improvement over letting python users have to make their own colors:
   ```
   class Nvtx:
       # Palette of colors
       RED = 0xFF0000
       GREEN = 0x00FF00
       BLUE = 0x0000FF
       YELLOW = 0xB58900
       ORANGE  = 0xCB4B16
       RED = 0xDC322F
       MAGENTA = 0xD33682
       VIOLET = 0x6C71C4
       BLUE1   = 0x268BD2
       CYAN    = 0x2AA198
       GREEN  = 0x859900
   
   def nvtx_range_push(name, color=Nvtx.ORANGE):
   ```

##########
File path: src/common/nvtx.h
##########
@@ -0,0 +1,104 @@
+/*

Review comment:
       Should this new file be ./src/common/cuda/nvtx.h ?

##########
File path: src/common/nvtx.h
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef MXNET_COMMON_NVTX_H_
+#define MXNET_COMMON_NVTX_H_
+
+#if MXNET_USE_CUDA && MXNET_USE_NVTX
+#include <cuda.h>
+#include <cuda_runtime.h>
+#include <nvToolsExtCuda.h>
+#include <vector>
+#include <string>
+#include <cstring>
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+
+class NVTXDuration {
+ public:
+  explicit NVTXDuration(const char *name) noexcept
+      : range_id_(0), name_(name) {}
+
+  inline void start() {
+    range_id_ = nvtxRangeStartA(name_);
+  }
+
+  inline void stop() {
+    nvtxRangeEnd(range_id_);
+  }
+
+ private:
+  nvtxRangeId_t range_id_;
+  const char *name_;
+};
+
+// Utility class for NVTX
+class nvtx {
+ public:
+  // Palette of colors (make sure to add new colors to the vector in nameToColor()).
+  static const uint32_t kRed     = 0xFF0000;
+  static const uint32_t kGreen   = 0x00FF00;
+  static const uint32_t kBlue    = 0x0000FF;
+  static const uint32_t kYellow  = 0xB58900;
+  static const uint32_t kOrange  = 0xCB4B16;
+  static const uint32_t kRed1    = 0xDC322F;
+  static const uint32_t kMagenta = 0xD33682;
+  static const uint32_t kViolet  = 0x6C71C4;
+  static const uint32_t kBlue1   = 0x268BD2;
+  static const uint32_t kCyan    = 0x2AA198;
+  static const uint32_t kGreen1  = 0x859900;
+
+  static void gpuRangeStart(const uint32_t rgb, const std::string& range_name) {

Review comment:
       Do we know if the nvtxRangePushEx(&att) makes a copy of att.message.ascii?  I suspect not, in which case I'm worried about the lifetime of range_name.c_str().
   
   gpuRangeStart() is called with a const char *, so won't that require making a short-lived temporary string (with a copy of the char array) in the caller's environment?
   




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#issuecomment-914578715


   Jenkins CI successfully triggered : [unix-cpu]


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#issuecomment-924431893


   Jenkins CI successfully triggered : [unix-cpu, website]


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on pull request #18683: [WIP] Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
szha commented on pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#issuecomment-782931631


   What's the status for this change?


----------------------------------------------------------------
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



[GitHub] [incubator-mxnet] DickJC123 merged pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
DickJC123 merged pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683


   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#discussion_r707593907



##########
File path: src/common/nvtx.h
##########
@@ -0,0 +1,104 @@
+/*

Review comment:
       Could be, will change that.




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#discussion_r713373830



##########
File path: python/mxnet/cuda_utils.py
##########
@@ -0,0 +1,37 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Provides python interface to cuda-related functions of the mxnet library."""
+from .base import _LIB, mx_uint, c_str, check_call
+
+def nvtx_range_push(name, color=13323030):

Review comment:
       The problem with this is mainly that the standard hash in Python is not deterministic, which would make colors change on subsequent runs. Using a real hashing function like the SHA from Python's hashlib on the other hand seems to be quite a heavy hammer (and most probably introduce additional overheads, which we especially do not want to do when profiling the CPU part of the training).




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #18683: [WIP] Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#issuecomment-656354617


   Hey @ptrendx , Thanks for submitting the PR 
   All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands: 
   - To trigger all jobs: @mxnet-bot run ci [all] 
   - To trigger specific jobs: @mxnet-bot run ci [job1, job2] 
   *** 
   **CI supported jobs**: [windows-cpu, centos-cpu, sanity, website, clang, unix-gpu, centos-gpu, miscellaneous, edge, windows-gpu, unix-cpu]
   *** 
   _Note_: 
    Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin. 
   All CI tests must pass before the PR can be merged. 
   


----------------------------------------------------------------
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



[GitHub] [incubator-mxnet] szha commented on pull request #18683: [WIP] Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
szha commented on pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#issuecomment-677955126


   @ptrendx still WIP?


----------------------------------------------------------------
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



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#issuecomment-925325164


   Jenkins CI successfully triggered : [unix-cpu, website]


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#discussion_r710573448



##########
File path: python/mxnet/cuda_utils.py
##########
@@ -0,0 +1,37 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Provides python interface to cuda-related functions of the mxnet library."""
+from .base import _LIB, mx_uint, c_str, check_call
+
+def nvtx_range_push(name, color=13323030):

Review comment:
       I am refactoring this to be nicer and more Pythonic. Will send an updated version tomorrow, once I test it.




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18683: [WIP] Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#issuecomment-677958920


   Yes, I will return back to it sometime next week probably (@DickJC123 is currently merging 1.7 into our codebase and cherry picking stuff after that merge will be easier).


----------------------------------------------------------------
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



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#issuecomment-925995010


   @mxnet-bot run ci [unix-cpu]


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] DickJC123 commented on a change in pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
DickJC123 commented on a change in pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#discussion_r707617216



##########
File path: src/common/nvtx.h
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef MXNET_COMMON_NVTX_H_
+#define MXNET_COMMON_NVTX_H_
+
+#if MXNET_USE_CUDA && MXNET_USE_NVTX
+#include <cuda.h>
+#include <cuda_runtime.h>
+#include <nvToolsExtCuda.h>
+#include <vector>
+#include <string>
+#include <cstring>
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+
+class NVTXDuration {
+ public:
+  explicit NVTXDuration(const char *name) noexcept
+      : range_id_(0), name_(name) {}
+
+  inline void start() {
+    range_id_ = nvtxRangeStartA(name_);
+  }
+
+  inline void stop() {
+    nvtxRangeEnd(range_id_);
+  }
+
+ private:
+  nvtxRangeId_t range_id_;
+  const char *name_;
+};
+
+// Utility class for NVTX
+class nvtx {
+ public:
+  // Palette of colors (make sure to add new colors to the vector in nameToColor()).
+  static const uint32_t kRed     = 0xFF0000;
+  static const uint32_t kGreen   = 0x00FF00;
+  static const uint32_t kBlue    = 0x0000FF;
+  static const uint32_t kYellow  = 0xB58900;
+  static const uint32_t kOrange  = 0xCB4B16;
+  static const uint32_t kRed1    = 0xDC322F;
+  static const uint32_t kMagenta = 0xD33682;
+  static const uint32_t kViolet  = 0x6C71C4;
+  static const uint32_t kBlue1   = 0x268BD2;
+  static const uint32_t kCyan    = 0x2AA198;
+  static const uint32_t kGreen1  = 0x859900;
+
+  static void gpuRangeStart(const uint32_t rgb, const std::string& range_name) {

Review comment:
       So if nvtxRangePush copies the att.message.ascii string (as opposed to the pointer), that answers my primary concern here.
   
   I'm left with one nit then, why don't you have `const char * range_name` above, which avoids the needless string copy and keeps the type consistent between the callers (in c_api.cc and threaded_engine_perdevice.cc) and what att.message.ascii wants?




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] DickJC123 commented on a change in pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
DickJC123 commented on a change in pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#discussion_r708744937



##########
File path: src/common/cuda/nvtx.h
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef MXNET_COMMON_CUDA_NVTX_H_
+#define MXNET_COMMON_CUDA_NVTX_H_
+
+#if MXNET_USE_CUDA && MXNET_USE_NVTX
+#include <cuda.h>
+#include <cuda_runtime.h>
+#include <nvToolsExtCuda.h>
+#include <vector>
+#include <string>
+#include <cstring>
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+
+class NVTXDuration {
+ public:
+  explicit NVTXDuration(const char *name) noexcept
+      : range_id_(0), name_(name) {}
+
+  inline void start() {
+    range_id_ = nvtxRangeStartA(name_);
+  }
+
+  inline void stop() {
+    nvtxRangeEnd(range_id_);
+  }
+
+ private:
+  nvtxRangeId_t range_id_;
+  const char *name_;
+};
+
+// Utility class for NVTX
+class nvtx {
+ public:
+  // Palette of colors (make sure to add new colors to the vector in nameToColor()).
+  static const uint32_t kRed     = 0xFF0000;
+  static const uint32_t kGreen   = 0x00FF00;
+  static const uint32_t kBlue    = 0x0000FF;
+  static const uint32_t kYellow  = 0xB58900;
+  static const uint32_t kOrange  = 0xCB4B16;
+  static const uint32_t kRed1    = 0xDC322F;
+  static const uint32_t kMagenta = 0xD33682;
+  static const uint32_t kViolet  = 0x6C71C4;
+  static const uint32_t kBlue1   = 0x268BD2;
+  static const uint32_t kCyan    = 0x2AA198;
+  static const uint32_t kGreen1  = 0x859900;
+
+  static void gpuRangeStart(const uint32_t rgb, const std::string& range_name) {
+    nvtxEventAttributes_t att;
+    att.version = NVTX_VERSION;
+    att.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
+    att.colorType = NVTX_COLOR_ARGB;
+    att.color = rgb | 0xff000000;
+    att.messageType = NVTX_MESSAGE_TYPE_ASCII;
+    att.message.ascii = range_name.c_str();
+    nvtxRangePushEx(&att);
+  }
+
+  // Utility to map a range name prefix to a random color based on its hash
+  static uint32_t nameToColor(const std::string& range_name, int prefix_len) {
+    static std::vector<uint32_t> colors{kRed, kGreen, kBlue, kYellow, kOrange, kRed1, kMagenta,
+                                        kViolet, kBlue1, kCyan, kGreen1};
+    std::string s(range_name, 0, prefix_len);
+    std::hash<std::string> hash_fn;
+    return colors[hash_fn(s) % colors.size()];
+  }
+
+  // Utility to map a range name to a random color based on its hash
+  static uint32_t nameToColor(const char *range_name) {

Review comment:
       ```suggestion
     static uint32_t nameToColor(const std::string& range_name) {
   ```




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#issuecomment-925325097


   @mxnet-bot run ci [unix-cpu, website]


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] DickJC123 commented on a change in pull request #18683: Expand NVTX usage

Posted by GitBox <gi...@apache.org>.
DickJC123 commented on a change in pull request #18683:
URL: https://github.com/apache/incubator-mxnet/pull/18683#discussion_r713451003



##########
File path: python/mxnet/cuda_utils.py
##########
@@ -0,0 +1,37 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Provides python interface to cuda-related functions of the mxnet library."""
+from .base import _LIB, mx_uint, c_str, check_call
+
+def nvtx_range_push(name, color=13323030):

Review comment:
       What I tried to suggest was that the 'None' color would be conveyed to the backend (via -1 or alternate API with no color arg), and the backend would assign the color with the existing backend nameToColor() routine.




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org