ChaiBapchya commented on a change in pull request #17376: [MXNET-1404] 
Implement storage tagging, the first half of the memory profiler
URL: https://github.com/apache/incubator-mxnet/pull/17376#discussion_r368257888
 
 

 ##########
 File path: src/profiler/gpu_memory_profiler.cc
 ##########
 @@ -0,0 +1,129 @@
+/*
+ * 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.
+ */
+#include <dmlc/parameter.h>
+#include "./gpu_memory_profiler.h"
+
+#ifdef _WIN32
+#include <windows.h>
+#include <tchar.h>
+#endif
+#include <ctime>
+#include <string>
+
+namespace mxnet {
+namespace profiler {
+
+/// \brief Return the path to the temporary directory.
+///        The implementation is taken from `boost::temp_directory_path`
+static std::string temp_dir_path() {
+#ifdef _WIN32
+#define TEMP_DIR_MAX_LEN 1024
+  TCHAR temp_dir_c_str[TEMP_DIR_MAX_LEN];
+  GetTempPath(TEMP_DIR_MAX_LEN,
+      temp_dir_c_str);
+  return std::string(temp_dir_c_str);
+#undef MAX_PATH
+#else  // !_WIN32
+  const char* temp_dir_c_str = NULL;
+
+  (temp_dir_c_str = std::getenv("TMPDIR")) ||
+  (temp_dir_c_str = std::getenv("TMP")) ||
+  (temp_dir_c_str = std::getenv("TEMP")) ||
+  (temp_dir_c_str = std::getenv("TEMPDIR"));
+#ifdef __ANDROID__
+  const char* default_temp_dir_c_str = "/data/local/tmp";
+#else
+  const char* default_temp_dir_c_str = "/tmp";
+#endif
+  std::string temp_dir = std::string(temp_dir_c_str == NULL ?
+      default_temp_dir_c_str : temp_dir_c_str);
+  return temp_dir;
+#endif  // _WIN32
+}
+
+/// \brief Convert a `Storage::DataStruct` to string.
+static std::string data_struct_to_str(
+    const Storage::DataStruct data_struct) {
+  switch (data_struct) {
+    case Storage::DataStruct::kDataEntry:      return "data entry";
+    case Storage::DataStruct::kTempSpace:      return "temp space";
+    case Storage::DataStruct::kParameter:      return "param";
+    case Storage::DataStruct::kParameterGrad:  return "param grad";
+    case Storage::DataStruct::kOptimizerState: return "optimizer state";
+    case Storage::DataStruct::kAuxState:       return "aux state";
+    case Storage::DataStruct::kEphemeral:      return "ephemeral";
+    default: return "unknown";
+  }
+}
+
+GpuMemoryProfiler*
 
 Review comment:
   why on a separate line?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to