From 69bc455e699ba5d3b3227aff1932b556c93974d8 Mon Sep 17 00:00:00 2001 From: Smit Hinsu Date: Wed, 9 May 2018 12:07:05 -0700 Subject: [PATCH] Use parenthesis based construction instead of brace initialization Updates all the construction calls for Status, ScopedActivateContext and mutexes withing stream_executor to follow the recommendation in https://abseil.io/tips/88 PiperOrigin-RevId: 196007931 --- tensorflow/stream_executor/cuda/cuda_blas.cc | 2 +- .../stream_executor/cuda/cuda_diagnostics.cc | 60 ++++---- tensorflow/stream_executor/cuda/cuda_driver.cc | 152 ++++++++++----------- tensorflow/stream_executor/cuda/cuda_fft.cc | 60 ++++---- .../stream_executor/cuda/cuda_gpu_executor.cc | 4 +- tensorflow/stream_executor/cuda/cuda_platform.cc | 8 +- tensorflow/stream_executor/cuda/cuda_rng.cc | 8 +- tensorflow/stream_executor/dnn.h | 16 +-- .../stream_executor/host/host_gpu_executor.h | 10 +- tensorflow/stream_executor/host/host_platform.cc | 4 +- tensorflow/stream_executor/kernel_spec.cc | 4 +- tensorflow/stream_executor/plugin_registry.cc | 21 +-- tensorflow/stream_executor/stream.cc | 8 +- tensorflow/stream_executor/stream.h | 4 +- .../stream_executor/stream_executor_pimpl.cc | 32 ++--- 15 files changed, 197 insertions(+), 196 deletions(-) diff --git a/tensorflow/stream_executor/cuda/cuda_blas.cc b/tensorflow/stream_executor/cuda/cuda_blas.cc index 3c1353a..dcc3f7a 100644 --- a/tensorflow/stream_executor/cuda/cuda_blas.cc +++ b/tensorflow/stream_executor/cuda/cuda_blas.cc @@ -628,7 +628,7 @@ template bool CUDABlas::DoBlasInternalImpl(FuncT cublas_func, Stream *stream, bool pointer_mode_host, bool err_on_failure, bool use_tensor_op_math, Args... args) { - mutex_lock lock{mu_}; + mutex_lock lock(mu_); CHECK(blas_ != nullptr); if (!SetStream(stream)) { diff --git a/tensorflow/stream_executor/cuda/cuda_diagnostics.cc b/tensorflow/stream_executor/cuda/cuda_diagnostics.cc index feb5292..46e5dee 100644 --- a/tensorflow/stream_executor/cuda/cuda_diagnostics.cc +++ b/tensorflow/stream_executor/cuda/cuda_diagnostics.cc @@ -76,35 +76,36 @@ string DriverVersionStatusToString(port::StatusOr version) { port::StatusOr StringToDriverVersion(const string &value) { std::vector pieces = port::Split(value, '.'); if (pieces.size() < 2 || pieces.size() > 4) { - return port::Status{ + return port::Status( port::error::INVALID_ARGUMENT, - port::Printf("expected %%d.%%d, %%d.%%d.%%d, or %%d.%%d.%%d.%%d form for driver version; got \"%s\"", - value.c_str())}; + port::Printf("expected %%d.%%d, %%d.%%d.%%d, or %%d.%%d.%%d.%%d form " + "for driver version; got \"%s\"", + value.c_str())); } int major; int minor; int patch = 0; if (!port::safe_strto32(pieces[0], &major)) { - return port::Status{ + return port::Status( port::error::INVALID_ARGUMENT, port::Printf("could not parse major version number \"%s\" as an " "integer from string \"%s\"", - pieces[0].c_str(), value.c_str())}; + pieces[0].c_str(), value.c_str())); } if (!port::safe_strto32(pieces[1], &minor)) { - return port::Status{ + return port::Status( port::error::INVALID_ARGUMENT, port::Printf("could not parse minor version number \"%s\" as an " "integer from string \"%s\"", - pieces[1].c_str(), value.c_str())}; + pieces[1].c_str(), value.c_str())); } if (pieces.size() == 3 && !port::safe_strto32(pieces[2], &patch)) { - return port::Status{ - port::error::INVALID_ARGUMENT, - port::Printf("could not parse patch version number \"%s\" as an " + return port::Status( + port::error::INVALID_ARGUMENT, + port::Printf("could not parse patch version number \"%s\" as an " "integer from string \"%s\"", - pieces[2].c_str(), value.c_str())}; + pieces[2].c_str(), value.c_str())); } DriverVersion result{major, minor, patch}; @@ -204,9 +205,9 @@ void Diagnostician::LogDiagnosticInformation() { // Iterates through loaded DSOs with DlIteratePhdrCallback to find the // driver-interfacing DSO version number. Returns it as a string. port::StatusOr Diagnostician::FindDsoVersion() { - port::StatusOr result{port::Status{ + port::StatusOr result(port::Status( port::error::NOT_FOUND, - "was unable to find libcuda.so DSO loaded into this program"}}; + "was unable to find libcuda.so DSO loaded into this program")); #if defined(__APPLE__) // OSX CUDA libraries have names like: libcuda_310.41.15_mercury.dylib @@ -274,11 +275,11 @@ port::StatusOr Diagnostician::FindKernelModuleVersion( static const char *kDriverFilePrelude = "Kernel Module "; size_t offset = driver_version_file_contents.find(kDriverFilePrelude); if (offset == string::npos) { - return port::Status{ + return port::Status( port::error::NOT_FOUND, port::StrCat("could not find kernel module information in " "driver version file contents: \"", - driver_version_file_contents, "\"")}; + driver_version_file_contents, "\"")); } string version_and_rest = driver_version_file_contents.substr( @@ -334,25 +335,24 @@ port::StatusOr Diagnostician::FindKernelDriverVersion() { return StringToDriverVersion(version); } CFRelease(kext_infos); - auto status = - port::Status{port::error::INTERNAL, - port::StrCat("failed to read driver bundle version: ", - CFStringGetCStringPtr(kDriverKextIdentifier, kCFStringEncodingUTF8)) - }; + auto status = port::Status( + port::error::INTERNAL, + port::StrCat( + "failed to read driver bundle version: ", + CFStringGetCStringPtr(kDriverKextIdentifier, kCFStringEncodingUTF8))); return status; #elif defined(PLATFORM_WINDOWS) auto status = - port::Status{port::error::UNIMPLEMENTED, - "kernel reported driver version not implemented on Windows" - }; + port::Status(port::error::UNIMPLEMENTED, + "kernel reported driver version not implemented on Windows"); return status; #else FILE *driver_version_file = fopen(kDriverVersionPath, "r"); if (driver_version_file == nullptr) { - return port::Status{ + return port::Status( port::error::PERMISSION_DENIED, port::StrCat("could not open driver version path for reading: ", - kDriverVersionPath)}; + kDriverVersionPath)); } static const int kContentsSize = 1024; @@ -371,11 +371,11 @@ port::StatusOr Diagnostician::FindKernelDriverVersion() { return FindKernelModuleVersion(contents.begin()); } - auto status = - port::Status{port::error::INTERNAL, - port::StrCat("failed to read driver version file contents: ", - kDriverVersionPath, "; ferror: ", - ferror(driver_version_file))}; + auto status = port::Status( + port::error::INTERNAL, + port::StrCat( + "failed to read driver version file contents: ", kDriverVersionPath, + "; ferror: ", ferror(driver_version_file))); fclose(driver_version_file); return status; #endif diff --git a/tensorflow/stream_executor/cuda/cuda_driver.cc b/tensorflow/stream_executor/cuda/cuda_driver.cc index 71cab14..e7e4192 100644 --- a/tensorflow/stream_executor/cuda/cuda_driver.cc +++ b/tensorflow/stream_executor/cuda/cuda_driver.cc @@ -62,14 +62,14 @@ class CreatedContexts { public: // Returns whether context is a member of the live set. static bool Has(CUcontext context) { - tf_shared_lock lock{mu_}; + tf_shared_lock lock(mu_); return Live()->find(context) != Live()->end(); } // Adds context to the live set. static CudaContext* Add(CUcontext context) { CHECK(context != nullptr); - mutex_lock lock{mu_}; + mutex_lock lock(mu_); auto cuda_context = new CudaContext(context, next_id_++); Live()->insert( std::make_pair(context, std::unique_ptr(cuda_context))); @@ -79,7 +79,7 @@ class CreatedContexts { // Removes context from the live set. static void Remove(CUcontext context) { CHECK(context != nullptr); - mutex_lock lock{mu_}; + mutex_lock lock(mu_); auto it = Live()->find(context); CHECK(it != Live()->end()) << context; Live()->erase(it); @@ -396,8 +396,8 @@ static port::Status InternalInit() { LOG(ERROR) << "failed call to cuInit: " << ToString(res); Diagnostician::LogDiagnosticInformation(); - return port::Status{port::error::ABORTED, - port::StrCat("failed call to cuInit: ", ToString(res))}; + return port::Status(port::error::ABORTED, + port::StrCat("failed call to cuInit: ", ToString(res))); } } // namespace @@ -425,9 +425,9 @@ static port::Status InternalInit() { return port::Status::OK(); } - return port::Status{ + return port::Status( port::error::INTERNAL, - port::StrCat("failed call to cuDeviceGet: ", ToString(res))}; + port::StrCat("failed call to cuDeviceGet: ", ToString(res))); } /* static */ bool CUDADriver::GetDeviceName(CUdevice device, @@ -562,7 +562,7 @@ bool DeviceOptionsToContextFlags(const DeviceOptions &device_options, } } - return port::Status{port::error::INTERNAL, message}; + return port::Status(port::error::INTERNAL, message); } /* static */ void CUDADriver::DestroyContext(CudaContext* context) { @@ -615,7 +615,7 @@ bool DeviceOptionsToContextFlags(const DeviceOptions &device_options, /* static */ port::StatusOr CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { CUsharedconfig shared_mem_config; - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult result = cuCtxGetSharedMemConfig(&shared_mem_config); if (result != CUDA_SUCCESS) { CUdevice device; @@ -623,16 +623,16 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { LOG(ERROR) << "failed to get CUDA device shared memory config. " << "Context device ID: " << device << ", result: " << ToString(result); - return port::Status{ + return port::Status( port::error::INTERNAL, - port::StrCat("failed to get shared memory config: ", ToString(result))}; + port::StrCat("failed to get shared memory config: ", ToString(result))); } return shared_mem_config; } /* static */ port::Status CUDADriver::ContextSetSharedMemConfig( CudaContext* context, CUsharedconfig shared_mem_config) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult result = cuCtxSetSharedMemConfig(shared_mem_config); if (result != CUDA_SUCCESS) { CUdevice device; @@ -641,9 +641,9 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { << "Context device ID: " << device << ", config: " << shared_mem_config << ", result: " << ToString(result); - return port::Status{ + return port::Status( port::error::INTERNAL, - port::StrCat("failed to set shared memory config: ", ToString(result))}; + port::StrCat("failed to set shared memory config: ", ToString(result))); } return port::Status::OK(); } @@ -654,7 +654,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { unsigned int block_dim_y, unsigned int block_dim_z, unsigned int shared_mem_bytes, CUstream stream, void **kernel_params, void **extra) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); VLOG(2) << "launching kernel: " << function << "; gdx: " << grid_dim_x << " gdy: " << grid_dim_y << " gdz: " << grid_dim_z << " bdx: " << block_dim_x << " bdy: " << block_dim_y @@ -674,11 +674,11 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { /* static */ port::Status CUDADriver::LoadCubin(CudaContext* context, const char *cubin_bytes, CUmodule *module) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult result = cuModuleLoadFatBinary(module, cubin_bytes); if (result != CUDA_SUCCESS) { - return port::Status{port::error::INTERNAL, - "failed to load in-memory CUBIN: " + ToString(result)}; + return port::Status(port::error::INTERNAL, + "failed to load in-memory CUBIN: " + ToString(result)); } return port::Status::OK(); @@ -691,7 +691,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { bool ret = true; GetDriverExecutor()->Schedule([context, ptx_contents, module, &ret, ¬ification]() { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); void *ptx_data = const_cast(ptx_contents); static const unsigned int kLogBufferBytesLimit = 1024; unsigned int error_log_buffer_bytes = kLogBufferBytesLimit; @@ -757,7 +757,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { /* static */ bool CUDADriver::SynchronousMemsetUint8(CudaContext* context, CUdeviceptr location, uint8 value, size_t size) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult res = cuMemsetD8(location, value, size); if (res != CUDA_SUCCESS) { LOG(ERROR) << "failed to memset memory: " << ToString(res); @@ -770,7 +770,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { CUdeviceptr location, uint32 value, size_t uint32_count) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult res = cuMemsetD32(location, value, uint32_count); if (res != CUDA_SUCCESS) { LOG(ERROR) << "failed to memset memory: " << ToString(res); @@ -784,7 +784,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { uint8 value, size_t uint32_count, CUstream stream) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult res = cuMemsetD8Async(location, value, uint32_count, stream); if (res != CUDA_SUCCESS) { LOG(ERROR) << "failed to enqueue async memset operation: " << ToString(res); @@ -799,7 +799,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { uint32 value, size_t uint32_count, CUstream stream) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult res = cuMemsetD32Async(location, value, uint32_count, stream); if (res != CUDA_SUCCESS) { LOG(ERROR) << "failed to enqueue async memset operation: " << ToString(res); @@ -877,9 +877,9 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { return device; } - return port::Status{ + return port::Status( port::error::INTERNAL, - port::StrCat("failed to get device for context: ", ToString(result))}; + port::StrCat("failed to get device for context: ", ToString(result))); } /* static */ bool CUDADriver::CreateStream(CudaContext *context, @@ -937,7 +937,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { /* static */ void CUDADriver::DeviceDeallocate(CudaContext* context, void *location) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUdeviceptr pointer = port::bit_cast(location); CUresult res = cuMemFree(pointer); if (res != CUDA_SUCCESS) { @@ -950,7 +950,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { /* static */ void *CUDADriver::HostAllocate(CudaContext *context, uint64 bytes) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); void *host_mem = nullptr; // "Portable" memory is visible to all CUDA contexts. Safe for our use model. CUresult res = cuMemHostAlloc(&host_mem, bytes, CU_MEMHOSTALLOC_PORTABLE); @@ -963,7 +963,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { /* static */ void CUDADriver::HostDeallocate(CudaContext* context, void *location) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult res = cuMemFreeHost(location); if (res != CUDA_SUCCESS) { LOG(ERROR) << "error deallocating host memory at " << location << ": " @@ -973,7 +973,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { /* static */ bool CUDADriver::HostRegister(CudaContext* context, void *location, uint64 bytes) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); // "Portable" memory is visible to all CUDA contexts. Safe for our use model. CUresult res = cuMemHostRegister(location, bytes, CU_MEMHOSTREGISTER_PORTABLE); @@ -987,7 +987,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { /* static */ bool CUDADriver::HostUnregister(CudaContext* context, void *location) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult res = cuMemHostUnregister(location); if (res != CUDA_SUCCESS) { LOG(ERROR) << "error unregistering host memory at " << location << ": " @@ -1000,8 +1000,8 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { /* static */ port::Status CUDADriver::DestroyEvent(CudaContext* context, CUevent *event) { if (*event == nullptr) { - return port::Status{port::error::INVALID_ARGUMENT, - "input event cannot be null"}; + return port::Status(port::error::INVALID_ARGUMENT, + "input event cannot be null"); } ScopedActivateContext activated{context}; @@ -1013,15 +1013,15 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { return port::Status::OK(); case CUDA_ERROR_DEINITIALIZED: case CUDA_ERROR_NOT_INITIALIZED: - return port::Status{ + return port::Status( port::error::FAILED_PRECONDITION, port::Printf("error destroying CUDA event in context %p: %s", context, - ToString(res).c_str())}; + ToString(res).c_str())); default: - return port::Status{ + return port::Status( port::error::INTERNAL, port::Printf("error destroying CUDA event in context %p: %s", context, - ToString(res).c_str())}; + ToString(res).c_str())); } } @@ -1035,15 +1035,15 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { return port::Status::OK(); case CUDA_ERROR_DEINITIALIZED: case CUDA_ERROR_NOT_INITIALIZED: - return port::Status{ + return port::Status( port::error::FAILED_PRECONDITION, port::Printf("error recording CUDA event on stream %p: %s", stream, - ToString(res).c_str())}; + ToString(res).c_str())); default: - return port::Status{ + return port::Status( port::error::INVALID_ARGUMENT, port::Printf("error recording CUDA event on stream %p: %s", stream, - ToString(res).c_str())}; + ToString(res).c_str())); } } @@ -1052,9 +1052,9 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { ScopedActivateContext activated{context}; CUresult res = cuEventQuery(event); if (res != CUDA_SUCCESS && res != CUDA_ERROR_NOT_READY) { - return port::Status{ + return port::Status( port::error::INTERNAL, - port::Printf("failed to query event: %s", ToString(res).c_str())}; + port::Printf("failed to query event: %s", ToString(res).c_str())); } return res; @@ -1084,7 +1084,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { /* static */ bool CUDADriver::WaitStreamOnEvent(CudaContext* context, CUstream stream, CUevent event) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult res = cuStreamWaitEvent(stream, event, 0 /* = flags */); if (res != CUDA_SUCCESS) { LOG(ERROR) << "could not wait stream on event: " << ToString(res); @@ -1095,7 +1095,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { } /* static */ bool CUDADriver::SynchronizeContext(CudaContext* context) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult res = cuCtxSynchronize(); if (res != CUDA_SUCCESS) { LOG(ERROR) << "could not synchronize on CUDA context: " << ToString(res) @@ -1141,7 +1141,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { void *host_dst, CUdeviceptr gpu_src, uint64 size) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult res = cuMemcpyDtoH(host_dst, gpu_src, size); if (res != CUDA_SUCCESS) { return port::InternalError( @@ -1159,7 +1159,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { CUdeviceptr gpu_dst, const void *host_src, uint64 size) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult res = cuMemcpyHtoD(gpu_dst, host_src, size); if (res != CUDA_SUCCESS) { return port::InternalError(port::Printf( @@ -1176,7 +1176,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { CUdeviceptr gpu_dst, CUdeviceptr gpu_src, uint64 size) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult res = cuMemcpyDtoD(gpu_dst, gpu_src, size); if (res != CUDA_SUCCESS) { return port::InternalError(port::Printf( @@ -1194,7 +1194,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { CUdeviceptr gpu_src, uint64 size, CUstream stream) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult res = cuMemcpyDtoHAsync(host_dst, gpu_src, size, stream); if (res != CUDA_SUCCESS) { LOG(ERROR) << port::Printf( @@ -1214,7 +1214,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { const void *host_src, uint64 size, CUstream stream) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult res = cuMemcpyHtoDAsync(gpu_dst, host_src, size, stream); if (res != CUDA_SUCCESS) { LOG(ERROR) << port::Printf( @@ -1233,7 +1233,7 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { CUdeviceptr gpu_src, uint64 size, CUstream stream) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); CUresult result = cuMemcpyDtoDAsync(gpu_dst, gpu_src, size, stream); if (result != CUDA_SUCCESS) { LOG(ERROR) << port::Printf( @@ -1275,12 +1275,12 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { if (res == CUDA_SUCCESS) { return port::Status::OK(); } else if (res == CUDA_ERROR_OUT_OF_MEMORY) { - return port::Status{port::error::RESOURCE_EXHAUSTED, - "could not create CUDA event: out of device memory"}; + return port::Status(port::error::RESOURCE_EXHAUSTED, + "could not create CUDA event: out of device memory"); } else { - return port::Status{ + return port::Status( port::error::FAILED_PRECONDITION, - port::StrCat("could not create CUDA event: ", ToString(res))}; + port::StrCat("could not create CUDA event: ", ToString(res))); } } @@ -1308,10 +1308,10 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { return context; } - return port::Status{ + return port::Status( port::error::INTERNAL, port::StrCat("failed to query device pointer for context: ", - ToString(result))}; + ToString(result))); } /* static */ port::StatusOr CUDADriver::GetPointerMemorySpace( @@ -1326,16 +1326,16 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { case CU_MEMORYTYPE_HOST: return MemorySpace::kHost; default: - return port::Status{ + return port::Status( port::error::INTERNAL, - port::StrCat("unknown memory space provided by CUDA API: ", value)}; + port::StrCat("unknown memory space provided by CUDA API: ", value)); } } - return port::Status{ + return port::Status( port::error::INTERNAL, port::StrCat("failed to query device pointer for memory space: ", - ToString(result))}; + ToString(result))); } /* static */ port::Status CUDADriver::GetPointerAddressRange(CUdeviceptr dptr, @@ -1348,16 +1348,16 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { // We differentiate between "this pointer is unknown" (return here) and // "there was an internal error while performing this operation" (return // below). - return port::Status{ + return port::Status( port::error::NOT_FOUND, port::Printf("not a device pointer %p; %s", - reinterpret_cast(dptr), ToString(result).c_str())}; + reinterpret_cast(dptr), ToString(result).c_str())); } - return port::Status{ + return port::Status( port::error::INTERNAL, port::Printf("failed to get pointer into for device pointer %p; %s", - reinterpret_cast(dptr), ToString(result).c_str())}; + reinterpret_cast(dptr), ToString(result).c_str())); } /* static */ port::StatusOr CUDADriver::GetPointerDevice( @@ -1380,10 +1380,10 @@ CUDADriver::ContextGetSharedMemConfig(CudaContext* context) { return port::Status::OK(); } - return port::Status{ + return port::Status( port::error::INTERNAL, port::Printf("failed to get compute capability for device: %s; %d", - ToString(result).c_str(), device)}; + ToString(result).c_str(), device)); } // Helper function that turns the integer output of cuDeviceGetAttribute to type @@ -1394,10 +1394,10 @@ static port::StatusOr GetSimpleAttribute(CUdevice device, int value = -1; CUresult result = cuDeviceGetAttribute(&value, attribute, device); if (result != CUDA_SUCCESS) { - return port::Status{ + return port::Status( port::error::NOT_FOUND, port::StrCat("could not retrieve CUDA device attribute (", attribute, - "): ", ToString(result))}; + "): ", ToString(result))); } T converted = value; return converted; @@ -1499,10 +1499,10 @@ static port::StatusOr GetSimpleAttribute(CUdevice device, int val; CUresult res = cuDeviceGetAttribute(&val, attribute, device); if (res != CUDA_SUCCESS) { - return port::Status{ + return port::Status( port::error::INTERNAL, port::Printf("failed to get device attribute %d for device %d: %s", - attribute, device, ToString(res).c_str())}; + attribute, device, ToString(res).c_str())); } return val; } @@ -1523,7 +1523,7 @@ static port::StatusOr GetSimpleAttribute(CUdevice device, /* static */ bool CUDADriver::GetDeviceMemoryInfo(CudaContext* context, int64 *free_out, int64 *total_out) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); size_t free = 0; size_t total = 0; CUresult res = cuMemGetInfo(&free, &total); @@ -1603,10 +1603,10 @@ static port::StatusOr GetSimpleAttribute(CUdevice device, CUresult result = cuCtxEnablePeerAccess(to->context(), 0 /* = flags */); if (result != CUDA_SUCCESS && result != CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED) { - return port::Status{ + return port::Status( port::error::INTERNAL, port::Printf("failed to enable peer access from %p to %p: %s", from, to, - ToString(result).c_str())}; + ToString(result).c_str())); } return port::Status::OK(); @@ -1615,16 +1615,16 @@ static port::StatusOr GetSimpleAttribute(CUdevice device, /* static */ port::StatusOr CUDADriver::GetMaxOccupiedBlocksPerCore( CudaContext* context, CUfunction kernel, int threads_per_block, size_t dynamic_shared_memory_bytes) { - ScopedActivateContext activation{context}; + ScopedActivateContext activation(context); int max_blocks; CUresult result = cuOccupancyMaxActiveBlocksPerMultiprocessor( &max_blocks, kernel, threads_per_block, dynamic_shared_memory_bytes); if (result != CUDA_SUCCESS) { - return port::Status{ + return port::Status( port::error::INTERNAL, port::Printf("failed to calculate occupancy of kernel %p: %s", kernel, - ToString(result).c_str())}; + ToString(result).c_str())); } return max_blocks; diff --git a/tensorflow/stream_executor/cuda/cuda_fft.cc b/tensorflow/stream_executor/cuda/cuda_fft.cc index 5b34740..013ca2d 100644 --- a/tensorflow/stream_executor/cuda/cuda_fft.cc +++ b/tensorflow/stream_executor/cuda/cuda_fft.cc @@ -138,8 +138,8 @@ port::Status CUDAFftPlan::Initialize( CUDAFftType(type), 1 /* = batch */); if (ret != CUFFT_SUCCESS) { LOG(ERROR) << "failed to create cuFFT 1d plan:" << ret; - return port::Status{port::error::INTERNAL, - "Failed to create cuFFT 1d plan."}; + return port::Status(port::error::INTERNAL, + "Failed to create cuFFT 1d plan."); } return port::Status::OK(); case 2: @@ -148,8 +148,8 @@ port::Status CUDAFftPlan::Initialize( elem_count_[1], CUDAFftType(type)); if (ret != CUFFT_SUCCESS) { LOG(ERROR) << "failed to create cuFFT 2d plan:" << ret; - return port::Status{port::error::INTERNAL, - "Failed to create cuFFT 2d plan."}; + return port::Status(port::error::INTERNAL, + "Failed to create cuFFT 2d plan."); } return port::Status::OK(); case 3: @@ -159,29 +159,29 @@ port::Status CUDAFftPlan::Initialize( elem_count_[2], CUDAFftType(type)); if (ret != CUFFT_SUCCESS) { LOG(ERROR) << "failed to create cuFFT 3d plan:" << ret; - return port::Status{port::error::INTERNAL, - "Failed to create cuFFT 3d plan."}; + return port::Status(port::error::INTERNAL, + "Failed to create cuFFT 3d plan."); } return port::Status::OK(); default: LOG(ERROR) << "Invalid rank value for cufftPlan. " "Requested 1, 2, or 3, given: " << rank; - return port::Status{port::error::INVALID_ARGUMENT, - "cufftPlan only takes rank 1, 2, or 3."}; + return port::Status(port::error::INVALID_ARGUMENT, + "cufftPlan only takes rank 1, 2, or 3."); } } else { ret = wrap::cufftCreate(parent, &plan_); if (ret != CUFFT_SUCCESS) { LOG(ERROR) << "failed to create cuFFT plan:" << ret; - return port::Status{port::error::INTERNAL, - "Failed to create cuFFT plan."}; + return port::Status(port::error::INTERNAL, + "Failed to create cuFFT plan."); } ret = wrap::cufftSetAutoAllocation(parent, plan_, 0); if (ret != CUFFT_SUCCESS) { LOG(ERROR) << "failed to set auto allocation for cuFFT plan:" << ret; - return port::Status{port::error::INTERNAL, - "Failed to set auto allocation for cuFFT plan."}; + return port::Status(port::error::INTERNAL, + "Failed to set auto allocation for cuFFT plan."); } switch (rank) { case 1: @@ -190,8 +190,8 @@ port::Status CUDAFftPlan::Initialize( &scratch_size_bytes_); if (ret != CUFFT_SUCCESS) { LOG(ERROR) << "failed to make cuFFT 1d plan:" << ret; - return port::Status{port::error::INTERNAL, - "Failed to make cuFFT 1d plan."}; + return port::Status(port::error::INTERNAL, + "Failed to make cuFFT 1d plan."); } break; case 2: @@ -200,8 +200,8 @@ port::Status CUDAFftPlan::Initialize( &scratch_size_bytes_); if (ret != CUFFT_SUCCESS) { LOG(ERROR) << "failed to make cuFFT 2d plan:" << ret; - return port::Status{port::error::INTERNAL, - "Failed to make cuFFT 2d plan."}; + return port::Status(port::error::INTERNAL, + "Failed to make cuFFT 2d plan."); } break; case 3: @@ -210,16 +210,16 @@ port::Status CUDAFftPlan::Initialize( CUDAFftType(type), &scratch_size_bytes_); if (ret != CUFFT_SUCCESS) { LOG(ERROR) << "failed to make cuFFT 3d plan:" << ret; - return port::Status{port::error::INTERNAL, - "Failed to make cuFFT 3d plan."}; + return port::Status(port::error::INTERNAL, + "Failed to make cuFFT 3d plan."); } break; default: LOG(ERROR) << "Invalid rank value for cufftPlan. " "Requested 1, 2, or 3, given: " << rank; - return port::Status{port::error::INVALID_ARGUMENT, - "cufftPlan only takes rank 1, 2, or 3."}; + return port::Status(port::error::INVALID_ARGUMENT, + "cufftPlan only takes rank 1, 2, or 3."); } return UpdateScratchAllocator(stream, scratch_allocator); } @@ -233,23 +233,23 @@ port::Status CUDAFftPlan::Initialize( output_distance, CUDAFftType(type), batch_count); if (ret != CUFFT_SUCCESS) { LOG(ERROR) << "failed to create cuFFT batched plan:" << ret; - return port::Status{port::error::INTERNAL, - "Failed to create cuFFT batched plan."}; + return port::Status(port::error::INTERNAL, + "Failed to create cuFFT batched plan."); } } else { auto ret = wrap::cufftCreate(parent, &plan_); if (ret != CUFFT_SUCCESS) { LOG(ERROR) << "failed to create cuFFT batched plan:" << ret; - return port::Status{port::error::INTERNAL, - "Failed to create cuFFT batched plan."}; + return port::Status(port::error::INTERNAL, + "Failed to create cuFFT batched plan."); } ret = wrap::cufftSetAutoAllocation(parent, plan_, 0); if (ret != CUFFT_SUCCESS) { LOG(ERROR) << "failed to set auto allocation for cuFFT batched plan:" << ret; - return port::Status{ + return port::Status( port::error::INTERNAL, - "Failed to set auto allocation for cuFFT batched plan."}; + "Failed to set auto allocation for cuFFT batched plan."); } ret = wrap::cufftMakePlanMany( parent, plan_, rank, elem_count_, @@ -259,8 +259,8 @@ port::Status CUDAFftPlan::Initialize( &scratch_size_bytes_); if (ret != CUFFT_SUCCESS) { LOG(ERROR) << "failed to make cuFFT batched plan:" << ret; - return port::Status{port::error::INTERNAL, - "Failed to make cuFFT batched plan."}; + return port::Status(port::error::INTERNAL, + "Failed to make cuFFT batched plan."); } return UpdateScratchAllocator(stream, scratch_allocator); } @@ -293,8 +293,8 @@ port::Status CUDAFftPlan::UpdateScratchAllocator( cufftResult_t ret = wrap::cufftSetWorkArea(parent_, plan_, scratch_.opaque()); if (ret != CUFFT_SUCCESS) { LOG(ERROR) << "failed to set work area for cuFFT plan:" << ret; - return port::Status{port::error::INTERNAL, - "Failed to set work area for cuFFT plan."}; + return port::Status(port::error::INTERNAL, + "Failed to set work area for cuFFT plan."); } return port::Status::OK(); } diff --git a/tensorflow/stream_executor/cuda/cuda_gpu_executor.cc b/tensorflow/stream_executor/cuda/cuda_gpu_executor.cc index 7c87d33..f2be68b 100644 --- a/tensorflow/stream_executor/cuda/cuda_gpu_executor.cc +++ b/tensorflow/stream_executor/cuda/cuda_gpu_executor.cc @@ -609,10 +609,10 @@ port::Status CUDAExecutor::WaitForEvent(Stream *stream, Event *event) { AsCUDAEvent(event)->cuda_event())) { return port::Status::OK(); } else { - return port::Status{ + return port::Status( port::error::INTERNAL, port::Printf("error recording waiting for CUDA event on stream %p", - stream)}; + stream)); } } diff --git a/tensorflow/stream_executor/cuda/cuda_platform.cc b/tensorflow/stream_executor/cuda/cuda_platform.cc index 649224a..ebe4dcc 100644 --- a/tensorflow/stream_executor/cuda/cuda_platform.cc +++ b/tensorflow/stream_executor/cuda/cuda_platform.cc @@ -124,9 +124,9 @@ port::StatusOr CudaPlatform::FirstExecutorForBus( } } - return port::Status{ + return port::Status( port::error::NOT_FOUND, - port::Printf("Executor for bus %d not found.", bus_ordinal)}; + port::Printf("Executor for bus %d not found.", bus_ordinal)); } Platform::Id CudaPlatform::id() const { return kCudaPlatformId; } @@ -172,11 +172,11 @@ CudaPlatform::GetUncachedExecutor(const StreamExecutorConfig& config) { this, MakeUnique(config.plugin_config)); auto init_status = executor->Init(config.ordinal, config.device_options); if (!init_status.ok()) { - return port::Status{ + return port::Status( port::error::INTERNAL, port::Printf( "failed initializing StreamExecutor for CUDA device ordinal %d: %s", - config.ordinal, init_status.ToString().c_str())}; + config.ordinal, init_status.ToString().c_str())); } return std::move(executor); diff --git a/tensorflow/stream_executor/cuda/cuda_rng.cc b/tensorflow/stream_executor/cuda/cuda_rng.cc index e289e7c..88c4f15 100644 --- a/tensorflow/stream_executor/cuda/cuda_rng.cc +++ b/tensorflow/stream_executor/cuda/cuda_rng.cc @@ -114,7 +114,7 @@ CUDARng::~CUDARng() { } bool CUDARng::Init() { - mutex_lock lock{mu_}; + mutex_lock lock(mu_); CHECK(rng_ == nullptr); curandStatus_t ret = @@ -150,7 +150,7 @@ constexpr bool ComplexIsConsecutiveFloats() { template bool CUDARng::DoPopulateRandUniformInternal(Stream *stream, DeviceMemory *v) { - mutex_lock lock{mu_}; + mutex_lock lock(mu_); static_assert(ComplexIsConsecutiveFloats(), "std::complex values are not stored as consecutive values"); @@ -209,7 +209,7 @@ bool CUDARng::DoPopulateRandGaussianInternal(Stream *stream, ElemT mean, ElemT stddev, DeviceMemory *v, FuncT func) { - mutex_lock lock{mu_}; + mutex_lock lock(mu_); if (!SetStream(stream)) { return false; @@ -241,7 +241,7 @@ bool CUDARng::DoPopulateRandGaussian(Stream *stream, double mean, double stddev, } bool CUDARng::SetSeed(Stream *stream, const uint8 *seed, uint64 seed_bytes) { - mutex_lock lock{mu_}; + mutex_lock lock(mu_); CHECK(rng_ != nullptr); if (!CheckSeed(seed, seed_bytes)) { diff --git a/tensorflow/stream_executor/dnn.h b/tensorflow/stream_executor/dnn.h index 18606eb..5b533de 100644 --- a/tensorflow/stream_executor/dnn.h +++ b/tensorflow/stream_executor/dnn.h @@ -882,8 +882,8 @@ enum class ElementwiseOperation { kAdd, kMultiply }; string ElementwiseOperationString(ElementwiseOperation op); -// A simple class representing the version of the backing library, to -// workaround the "too perfect forwarding" issue in gcc6+ compilers. +// A simple class representing the version of the backing library, to +// workaround the "too perfect forwarding" issue in gcc6+ compilers. // See PR#16309 and issue #18402 for links discussing the issue. class VersionInfo { public: @@ -2036,8 +2036,8 @@ class DnnSupport { const dnn::AlgorithmConfig& algorithm_config, float dropout, uint64 seed, ScratchAllocator* state_allocator) { - return port::Status{port::error::UNIMPLEMENTED, - "createRnnDescriptor is unimplemented"}; + return port::Status(port::error::UNIMPLEMENTED, + "createRnnDescriptor is unimplemented"); } // Create a RNN sequence descriptor that specifies either the input or output @@ -2051,8 +2051,8 @@ class DnnSupport { virtual port::StatusOr> createRnnSequenceTensorDescriptor(int seq_length, int batch_size, int data_size, dnn::DataType data_type) { - return port::Status{port::error::UNIMPLEMENTED, - "createRnnSequenceTensorDescriptor is unimplemented"}; + return port::Status(port::error::UNIMPLEMENTED, + "createRnnSequenceTensorDescriptor is unimplemented"); } // Create an RNN state descriptor that specifies the input or hidden state. @@ -2060,8 +2060,8 @@ class DnnSupport { virtual port::StatusOr> createRnnStateTensorDescriptor(int num_layer, int batch_size, int data_size, dnn::DataType data_type) { - return port::Status{port::error::UNIMPLEMENTED, - "createRnnStateTensorDescriptor is unimplemented"}; + return port::Status(port::error::UNIMPLEMENTED, + "createRnnStateTensorDescriptor is unimplemented"); } // Enqueue a forward operation of the RNN model onto the stream. diff --git a/tensorflow/stream_executor/host/host_gpu_executor.h b/tensorflow/stream_executor/host/host_gpu_executor.h index 0c3991c..e82f575 100644 --- a/tensorflow/stream_executor/host/host_gpu_executor.h +++ b/tensorflow/stream_executor/host/host_gpu_executor.h @@ -106,19 +106,19 @@ class HostExecutor : public internal::StreamExecutorInterface { bool HostCallback(Stream *stream, std::function callback) override; port::Status AllocateEvent(Event *event) override { - return port::Status{port::error::UNIMPLEMENTED, ""}; + return port::Status(port::error::UNIMPLEMENTED, ""); } port::Status DeallocateEvent(Event *event) override { - return port::Status{port::error::UNIMPLEMENTED, ""}; + return port::Status(port::error::UNIMPLEMENTED, ""); } port::Status RecordEvent(Stream *stream, Event *event) override { - return port::Status{port::error::UNIMPLEMENTED, ""}; + return port::Status(port::error::UNIMPLEMENTED, ""); } port::Status WaitForEvent(Stream *stream, Event *event) override { - return port::Status{port::error::UNIMPLEMENTED, ""}; + return port::Status(port::error::UNIMPLEMENTED, ""); } Event::Status PollForEventStatus(Event *event) override { @@ -167,7 +167,7 @@ class HostExecutor : public internal::StreamExecutorInterface { "Shared memory configuration is unsupported for host " "executors."}; LOG(INFO) << error_msg; - return port::Status{port::error::UNIMPLEMENTED, error_msg}; + return port::Status(port::error::UNIMPLEMENTED, error_msg); } bool SupportsBlas() const override; diff --git a/tensorflow/stream_executor/host/host_platform.cc b/tensorflow/stream_executor/host/host_platform.cc index a652b08..eeb6a06 100644 --- a/tensorflow/stream_executor/host/host_platform.cc +++ b/tensorflow/stream_executor/host/host_platform.cc @@ -70,11 +70,11 @@ HostPlatform::GetUncachedExecutor(const StreamExecutorConfig& config) { this, MakeUnique(config.plugin_config)); auto init_status = executor->Init(config.ordinal, config.device_options); if (!init_status.ok()) { - return port::Status{ + return port::Status( port::error::INTERNAL, port::Printf( "failed initializing StreamExecutor for device ordinal %d: %s", - config.ordinal, init_status.ToString().c_str())}; + config.ordinal, init_status.ToString().c_str())); } return std::move(executor); diff --git a/tensorflow/stream_executor/kernel_spec.cc b/tensorflow/stream_executor/kernel_spec.cc index f0a5785..902892a 100644 --- a/tensorflow/stream_executor/kernel_spec.cc +++ b/tensorflow/stream_executor/kernel_spec.cc @@ -93,7 +93,7 @@ const char *CudaPtxInMemory::default_text() const { return nullptr; } - mutex_lock lock{mu_}; + mutex_lock lock(mu_); auto ptx = ptx_by_compute_capability_.begin()->second; // Check if there is an entry in decompressed ptx table. @@ -127,7 +127,7 @@ const char *CudaPtxInMemory::text(int compute_capability_major, return nullptr; } - mutex_lock lock{mu_}; + mutex_lock lock(mu_); // Check if there is an entry in decompressed ptx table. auto decompressed_ptx_iter = decompressed_ptx_.find(ptx_iter->second); diff --git a/tensorflow/stream_executor/plugin_registry.cc b/tensorflow/stream_executor/plugin_registry.cc index 7812703..c53685c 100644 --- a/tensorflow/stream_executor/plugin_registry.cc +++ b/tensorflow/stream_executor/plugin_registry.cc @@ -72,11 +72,11 @@ port::Status PluginRegistry::RegisterFactoryInternal( mutex_lock lock{GetPluginRegistryMutex()}; if (factories->find(plugin_id) != factories->end()) { - return port::Status{ + return port::Status( port::error::ALREADY_EXISTS, port::Printf("Attempting to register factory for plugin %s when " "one has already been registered", - plugin_name.c_str())}; + plugin_name.c_str())); } (*factories)[plugin_id] = factory; @@ -92,9 +92,9 @@ port::StatusOr PluginRegistry::GetFactoryInternal( if (iter == factories.end()) { iter = generic_factories.find(plugin_id); if (iter == generic_factories.end()) { - return port::Status{ + return port::Status( port::error::NOT_FOUND, - port::Printf("Plugin ID %p not registered.", plugin_id)}; + port::Printf("Plugin ID %p not registered.", plugin_id)); } } @@ -212,10 +212,11 @@ bool PluginRegistry::HasFactory(Platform::Id platform_id, plugin_id = default_factories_[platform_id].FACTORY_VAR; \ \ if (plugin_id == kNullPlugin) { \ - return port::Status{port::error::FAILED_PRECONDITION, \ - "No suitable " PLUGIN_STRING \ - " plugin registered. Have you linked in a " \ - PLUGIN_STRING "-providing plugin?"}; \ + return port::Status( \ + port::error::FAILED_PRECONDITION, \ + "No suitable " PLUGIN_STRING \ + " plugin registered. Have you linked in a " PLUGIN_STRING \ + "-providing plugin?"); \ } else { \ VLOG(2) << "Selecting default " PLUGIN_STRING " plugin, " \ << plugin_names_[plugin_id]; \ @@ -231,9 +232,9 @@ bool PluginRegistry::HasFactory(Platform::Id platform_id, PlatformKind platform_kind, PluginId plugin_id) { \ auto iter = platform_id_by_kind_.find(platform_kind); \ if (iter == platform_id_by_kind_.end()) { \ - return port::Status{port::error::FAILED_PRECONDITION, \ + return port::Status(port::error::FAILED_PRECONDITION, \ port::Printf("Platform kind %d not registered.", \ - static_cast(platform_kind))}; \ + static_cast(platform_kind))); \ } \ return GetFactory(iter->second, plugin_id); \ } diff --git a/tensorflow/stream_executor/stream.cc b/tensorflow/stream_executor/stream.cc index 093f0c9..2bc9b6b 100644 --- a/tensorflow/stream_executor/stream.cc +++ b/tensorflow/stream_executor/stream.cc @@ -276,7 +276,7 @@ Stream::~Stream() { Stream &Stream::Init() { VLOG_CALL(); - mutex_lock lock{mu_}; + mutex_lock lock(mu_); CHECK_EQ(false, allocated_) << "stream appears to already have been initialized"; CHECK(!ok_) << "stream should be in !ok() state pre-initialization"; @@ -1899,7 +1899,7 @@ Stream &Stream::ThenCopyDevice2HostBuffer( } Stream *Stream::GetOrCreateSubStream() { - mutex_lock lock{mu_}; + mutex_lock lock(mu_); for (auto &stream : sub_streams_) { if (stream.second) { stream.second = false; @@ -1916,7 +1916,7 @@ Stream *Stream::GetOrCreateSubStream() { } void Stream::ReturnSubStream(Stream *sub_stream) { - mutex_lock lock{mu_}; + mutex_lock lock(mu_); for (auto &stream : sub_streams_) { if (stream.first.get() == sub_stream) { stream.second = true; @@ -5196,7 +5196,7 @@ port::Status Stream::BlockHostUntilDone() { port::Status first_error; { // Wait until all active sub-streams have done their tasks. - mutex_lock lock{mu_}; + mutex_lock lock(mu_); for (auto &stream : sub_streams_) { if (!stream.second) { first_error.Update(stream.first->BlockHostUntilDone()); diff --git a/tensorflow/stream_executor/stream.h b/tensorflow/stream_executor/stream.h index 3d1b011..2c2879b 100644 --- a/tensorflow/stream_executor/stream.h +++ b/tensorflow/stream_executor/stream.h @@ -2005,7 +2005,7 @@ class Stream { friend class ocl::CLBlas; // for parent_. bool InErrorState() const LOCKS_EXCLUDED(mu_) { - tf_shared_lock lock{mu_}; + tf_shared_lock lock(mu_); return !ok_; } @@ -2015,7 +2015,7 @@ class Stream { if (operation_retcode) { return; } - mutex_lock lock{mu_}; + mutex_lock lock(mu_); ok_ = false; } diff --git a/tensorflow/stream_executor/stream_executor_pimpl.cc b/tensorflow/stream_executor/stream_executor_pimpl.cc index 2057979..eecd5bf 100644 --- a/tensorflow/stream_executor/stream_executor_pimpl.cc +++ b/tensorflow/stream_executor/stream_executor_pimpl.cc @@ -232,7 +232,7 @@ void StreamExecutor::Deallocate(DeviceMemoryBase *mem) { } void StreamExecutor::GetMemAllocs(std::map *records_out) { - tf_shared_lock lock{mu_}; + tf_shared_lock lock(mu_); *records_out = mem_allocs_; } @@ -256,13 +256,13 @@ port::Status StreamExecutor::SetDeviceSharedMemoryConfig( string error_msg = port::Printf( "Invalid shared memory config specified: %d", static_cast(config)); LOG(ERROR) << error_msg; - return port::Status{port::error::INVALID_ARGUMENT, error_msg}; + return port::Status(port::error::INVALID_ARGUMENT, error_msg); } return implementation_->SetDeviceSharedMemoryConfig(config); } const DeviceDescription &StreamExecutor::GetDeviceDescription() const { - mutex_lock lock{mu_}; + mutex_lock lock(mu_); if (device_description_ != nullptr) { return *device_description_; } @@ -393,7 +393,7 @@ StreamExecutor::createRnnStateTensorDescriptor(int num_layer, int batch_size, } dnn::DnnSupport *StreamExecutor::AsDnn() { - mutex_lock lock{mu_}; + mutex_lock lock(mu_); if (dnn_ != nullptr) { return dnn_.get(); } @@ -403,7 +403,7 @@ dnn::DnnSupport *StreamExecutor::AsDnn() { } blas::BlasSupport *StreamExecutor::AsBlas() { - mutex_lock lock{mu_}; + mutex_lock lock(mu_); if (blas_ != nullptr) { return blas_.get(); } @@ -413,7 +413,7 @@ blas::BlasSupport *StreamExecutor::AsBlas() { } fft::FftSupport *StreamExecutor::AsFft() { - mutex_lock lock{mu_}; + mutex_lock lock(mu_); if (fft_ != nullptr) { return fft_.get(); } @@ -423,7 +423,7 @@ fft::FftSupport *StreamExecutor::AsFft() { } rng::RngSupport *StreamExecutor::AsRng() { - mutex_lock lock{mu_}; + mutex_lock lock(mu_); if (rng_ != nullptr) { return rng_.get(); } @@ -582,12 +582,12 @@ port::Status StreamExecutor::SynchronousMemcpyD2H( result = implementation_->SynchronousMemcpy(host_dst, device_src, size); if (!result.ok()) { - result = port::Status{port::error::INTERNAL, + result = port::Status(port::error::INTERNAL, port::Printf("failed to synchronously memcpy " "device-to-host: device %p to host %p " "size %lld: %s", device_src.opaque(), host_dst, size, - result.ToString().c_str())}; + result.ToString().c_str())); } return result; @@ -605,12 +605,12 @@ port::Status StreamExecutor::SynchronousMemcpyH2D( result = implementation_->SynchronousMemcpy(device_dst, host_src, size); if (!result.ok()) { - result = port::Status{ + result = port::Status( port::error::INTERNAL, port::Printf("failed to synchronously memcpy host-to-device: host " "%p to device %p size %lld: %s", host_src, device_dst->opaque(), size, - result.ToString().c_str())}; + result.ToString().c_str())); } return result; @@ -723,7 +723,7 @@ void StreamExecutor::EnqueueOnBackgroundThread(std::function task) { void StreamExecutor::CreateAllocRecord(void *opaque, uint64 bytes) { if (FLAGS_check_device_leaks && opaque != nullptr && bytes != 0) { - mutex_lock lock{mu_}; + mutex_lock lock(mu_); mem_allocs_[opaque] = AllocRecord{ bytes, ""}; } @@ -731,7 +731,7 @@ void StreamExecutor::CreateAllocRecord(void *opaque, uint64 bytes) { void StreamExecutor::EraseAllocRecord(void *opaque) { if (FLAGS_check_device_leaks && opaque != nullptr) { - mutex_lock lock{mu_}; + mutex_lock lock(mu_); if (mem_allocs_.find(opaque) == mem_allocs_.end()) { LOG(ERROR) << "Deallocating unknown pointer: " << port::Printf("0x%p", opaque); @@ -745,7 +745,7 @@ void StreamExecutor::EnableTracing(bool enabled) { tracing_enabled_ = enabled; } void StreamExecutor::RegisterTraceListener(TraceListener *listener) { { - mutex_lock lock{mu_}; + mutex_lock lock(mu_); if (listeners_.find(listener) != listeners_.end()) { LOG(INFO) << "Attempt to register already-registered listener, " << listener; @@ -759,7 +759,7 @@ void StreamExecutor::RegisterTraceListener(TraceListener *listener) { bool StreamExecutor::UnregisterTraceListener(TraceListener *listener) { { - mutex_lock lock{mu_}; + mutex_lock lock(mu_); if (listeners_.find(listener) == listeners_.end()) { LOG(INFO) << "Attempt to unregister unknown listener, " << listener; return false; @@ -776,7 +776,7 @@ void StreamExecutor::SubmitTrace(TraceCallT trace_call, ArgsT &&... args) { if (tracing_enabled_) { { // instance tracers held in a block to limit the lock lifetime. - tf_shared_lock lock{mu_}; + tf_shared_lock lock(mu_); for (TraceListener *listener : listeners_) { (listener->*trace_call)(std::forward(args)...); } -- 2.7.4