Skip to content

Commit

Permalink
[XLA:GPU] Fix crash in nccl_utils under C++17.
Browse files Browse the repository at this point in the history
It appears std::string_view is not happy accepting nullptr as its argument, whereas absl::string_view handled nullptr gracefully. Fixes crash when using XLA:GPU collectives under C++17.

PiperOrigin-RevId: 450573148
  • Loading branch information
hawkinsp authored and tensorflower-gardener committed May 24, 2022
1 parent 800c8af commit 4bd51c0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tensorflow/compiler/xla/service/gpu/nccl_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/gpu/nccl_utils.h"

#include <memory>
#include <string_view>
#include <utility>

#include "absl/container/flat_hash_map.h"
Expand All @@ -38,8 +39,10 @@ bool IsGlobalNcclConfig() {
}

bool IsNcclLaunchModeParallel() {
static const bool is_launch_mode_parallel =
absl::string_view(std::getenv("NCCL_LAUNCH_MODE")) == "PARALLEL";
static const bool is_launch_mode_parallel = []() {
const char* launch_mode = std::getenv("NCCL_LAUNCH_MODE");
return launch_mode && std::string_view(launch_mode) == "PARALLEL";
}();
return is_launch_mode_parallel;
}

Expand Down

0 comments on commit 4bd51c0

Please sign in to comment.