From e217e193f8648fe0bce4c721f7d93f094fc84630 Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Sun, 31 Mar 2024 23:24:48 -0700 Subject: [PATCH] Use `nullptr` in glow/glow/lib/Backends/NNPI/Importer.cpp Reviewed By: dmm-fb Differential Revision: D54835716 --- lib/Backends/NNPI/Importer.cpp | 6 +++--- lib/Backends/NNPI/InferenceContext.cpp | 2 +- lib/Backends/NNPI/InferencePool.cpp | 4 ++-- lib/Backends/NNPI/NNPICompiledFunction.cpp | 8 ++++---- lib/Backends/NNPI/NNPIOptions.cpp | 2 +- lib/Backends/OpenCL/OpenCL.cpp | 2 +- lib/Backends/OpenCL/OpenCLDeviceManager.cpp | 16 ++++++++-------- lib/Base/NumpyReader.cpp | 4 ++-- lib/LLVMIRCodeGen/LLVMCompiledFunction.cpp | 2 +- lib/Support/Support.cpp | 4 ++-- 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/Backends/NNPI/Importer.cpp b/lib/Backends/NNPI/Importer.cpp index 38e8f64015..9a73303026 100644 --- a/lib/Backends/NNPI/Importer.cpp +++ b/lib/Backends/NNPI/Importer.cpp @@ -949,7 +949,7 @@ class PoolNodeImporter : public INNPINodeImporter { return nnpiNetworkAddPoolingOp( importer.getNetwork(), glowPool->getName().begin(), nodeValueName(glowPool->getInput()).c_str(), - nodeValueName(glowPool->getResult()).c_str(), NULL, kernel.data(), + nodeValueName(glowPool->getResult()).c_str(), nullptr, kernel.data(), paddingStart.data(), paddingEnd.data(), stride.data(), numDims, poolType, !countIncludePads, 0); } @@ -1735,7 +1735,7 @@ class SLSNodeImporter : public INNPINodeImporter { return nnpiNetworkAddSparseLengthsWeightedSumOp( importer.getNetwork(), glowSLS->getName().begin(), nodeValueName(glowSLS->getData()).c_str(), - nodeValueName(glowSLS->getResult()).c_str(), NULL, + nodeValueName(glowSLS->getResult()).c_str(), nullptr, nodeValueName(glowSLS->getIndices()).c_str(), nodeValueName(glowSLS->getLengths()).c_str(), 0, 0, glowSLS->getAvgLength(), lengthType); @@ -2294,7 +2294,7 @@ class FRQSLSNodeImporter : public INNPINodeImporter { return nnpiNetworkAddSparseLengthsWeightedSumOp( importer.getNetwork(), glowSLWS->getName().begin(), nodeValueName(glowSLWS->getData()).c_str(), - nodeValueName(glowSLWS->getResult()).c_str(), NULL, + nodeValueName(glowSLWS->getResult()).c_str(), nullptr, nodeValueName(glowSLWS->getIndices()).c_str(), nodeValueName(glowSLWS->getLengths()).c_str(), usFp32Accum, 0, glowSLWS->getAvgLength(), lengthType); diff --git a/lib/Backends/NNPI/InferenceContext.cpp b/lib/Backends/NNPI/InferenceContext.cpp index 4c0421621e..cbc0a9fb25 100644 --- a/lib/Backends/NNPI/InferenceContext.cpp +++ b/lib/Backends/NNPI/InferenceContext.cpp @@ -451,7 +451,7 @@ void InferenceContext::execute(RunIdentifierTy runId, uint32_t numErrors(0); // First wait for the command list to complete. NNPIInferenceErrorCode res = nnpiCommandListWait( - commandList_, deviceOptions_->inferTimeoutUs, NULL, 0, &numErrors); + commandList_, deviceOptions_->inferTimeoutUs, nullptr, 0, &numErrors); uint64_t completeTime = TraceEvent::now(); // Set batchDeviceTimestamps. auto *requestDataRun = ::glow::runtime::RequestData::get(); diff --git a/lib/Backends/NNPI/InferencePool.cpp b/lib/Backends/NNPI/InferencePool.cpp index a571e1b161..9d7da59ee5 100644 --- a/lib/Backends/NNPI/InferencePool.cpp +++ b/lib/Backends/NNPI/InferencePool.cpp @@ -143,8 +143,8 @@ Error InferencePoolEnv::init(NNPIAdapterContainer *adapter, size_t readSize = ss->read(static_cast(ptr), size * count); return readSize; }; - inputStream.writeCallback = NULL; - inputStream.seekCallback = NULL; + inputStream.writeCallback = nullptr; + inputStream.seekCallback = nullptr; DBG_MEM_USAGE("call nnpiHostNetworkCreateFromStream"); LOG_NNPI_INF_IF_ERROR_RETURN_LLVMERROR( nnpiHostNetworkCreateFromStream(pAdapter_->getHandle(), &inputStream, diff --git a/lib/Backends/NNPI/NNPICompiledFunction.cpp b/lib/Backends/NNPI/NNPICompiledFunction.cpp index 1cf9603ace..c33c5a25d2 100644 --- a/lib/Backends/NNPI/NNPICompiledFunction.cpp +++ b/lib/Backends/NNPI/NNPICompiledFunction.cpp @@ -429,8 +429,8 @@ Error NNPICompiledFunction::compile(Function *F, const BackendOptions &opts) { { NNPIStream outFileStream; outFileStream.userData = &compiledStream_; - outFileStream.readCallback = NULL; - outFileStream.seekCallback = NULL; + outFileStream.readCallback = nullptr; + outFileStream.seekCallback = nullptr; outFileStream.writeCallback = [](const void *ptr, uint64_t size, uint64_t count, void *userData) -> uint64_t { @@ -452,7 +452,7 @@ Error NNPICompiledFunction::compile(Function *F, const BackendOptions &opts) { LOG_NNPI_IF_ERROR_RETURN_LLVMERROR( nnpiNetworkCompileToStream(network_, &config_, &outFileStream, - NULL), + nullptr), "Failed NNPI Compile"); } DBG_MEM_USAGE("NNPICompiledFunction done compile <<"); @@ -460,7 +460,7 @@ Error NNPICompiledFunction::compile(Function *F, const BackendOptions &opts) { { LOG_NNPI_IF_ERROR_RETURN_LLVMERROR( nnpiNetworkCompileToFile(network_, &config_, - compilationFileName_.c_str(), NULL), + compilationFileName_.c_str(), nullptr), "Failed NNPI Compile"); } diff --git a/lib/Backends/NNPI/NNPIOptions.cpp b/lib/Backends/NNPI/NNPIOptions.cpp index 0b32382efa..8f2b4c9a30 100644 --- a/lib/Backends/NNPI/NNPIOptions.cpp +++ b/lib/Backends/NNPI/NNPIOptions.cpp @@ -83,7 +83,7 @@ template <> unsigned NNPIOptions::getStringAsType(std::string sVal) { template <> uint64_t NNPIOptions::getStringAsType(std::string sVal) { if (isUInt(sVal)) { - return (uint64_t)std::strtoull(sVal.c_str(), NULL, 0); + return (uint64_t)std::strtoull(sVal.c_str(), nullptr, 0); } return 0; } diff --git a/lib/Backends/OpenCL/OpenCL.cpp b/lib/Backends/OpenCL/OpenCL.cpp index 506ee62577..69f9e425e9 100644 --- a/lib/Backends/OpenCL/OpenCL.cpp +++ b/lib/Backends/OpenCL/OpenCL.cpp @@ -417,7 +417,7 @@ static unsigned getPreferredVectorWidth(cl_device_id device, LOG(FATAL) << "Unsupported vector data type: " << Type::getElementName(elementType).str(); } - clGetDeviceInfo(device, paramName, sizeof(width), &width, NULL); + clGetDeviceInfo(device, paramName, sizeof(width), &width, nullptr); return width; } diff --git a/lib/Backends/OpenCL/OpenCLDeviceManager.cpp b/lib/Backends/OpenCL/OpenCLDeviceManager.cpp index 9bb6a17c8e..8d62f08cc0 100644 --- a/lib/Backends/OpenCL/OpenCLDeviceManager.cpp +++ b/lib/Backends/OpenCL/OpenCLDeviceManager.cpp @@ -245,7 +245,7 @@ Error OpenCLDeviceManager::init() { RETURN_IF_ERR(parseConfig()); cl_uint numPlatforms{0}; - cl_int err = clGetPlatformIDs(0, NULL, &numPlatforms); + cl_int err = clGetPlatformIDs(0, nullptr, &numPlatforms); if (err != CL_SUCCESS) { return MAKE_ERR("clGetPlatformIDs Failed."); } @@ -255,7 +255,7 @@ Error OpenCLDeviceManager::init() { } std::vector platform_ids(numPlatforms); - err = clGetPlatformIDs(numPlatforms, platform_ids.data(), NULL); + err = clGetPlatformIDs(numPlatforms, platform_ids.data(), nullptr); cl_platform_id platform_id_used = platform_ids[clPlatformId]; @@ -270,7 +270,7 @@ Error OpenCLDeviceManager::init() { cl_ulong mem_size; err = clGetDeviceInfo(deviceId_, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(cl_ulong), - &mem_size, NULL); + &mem_size, nullptr); if (err != CL_SUCCESS) { return MAKE_ERR("Error getting device memory limit"); } @@ -285,14 +285,14 @@ Error OpenCLDeviceManager::init() { localMemSize_ = 0; cl_device_local_mem_type localMemType; err = clGetDeviceInfo(deviceId_, CL_DEVICE_LOCAL_MEM_TYPE, - sizeof(localMemType), &localMemType, NULL); + sizeof(localMemType), &localMemType, nullptr); if (err != CL_SUCCESS) { return MAKE_ERR("Error getting device local memory type."); } if (localMemType == CL_LOCAL) { cl_ulong localMemSize; err = clGetDeviceInfo(deviceId_, CL_DEVICE_LOCAL_MEM_SIZE, - sizeof(localMemSize), &localMemSize, NULL); + sizeof(localMemSize), &localMemSize, nullptr); if (err != CL_SUCCESS) { return MAKE_ERR("Error getting device local memory type."); } @@ -668,7 +668,7 @@ void OpenCLDeviceManager::translateTraceEvents( auto &event = devBindings->kernelLaunches.back().event_; cl_ulong time_end; clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END, sizeof(time_end), - &time_end, NULL); + &time_end, nullptr); // Get the difference between the last event's end and the tsOffset // timestamp. @@ -694,12 +694,12 @@ void OpenCLDeviceManager::translateTraceEvents( if (clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_START, sizeof(timeStart), &timeStart, - NULL) != CL_SUCCESS) { + nullptr) != CL_SUCCESS) { continue; } if (clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END, sizeof(timeEnd), &timeEnd, - NULL) != CL_SUCCESS) { + nullptr) != CL_SUCCESS) { continue; } diff --git a/lib/Base/NumpyReader.cpp b/lib/Base/NumpyReader.cpp index 3dc3adbadf..e706213cb9 100644 --- a/lib/Base/NumpyReader.cpp +++ b/lib/Base/NumpyReader.cpp @@ -144,7 +144,7 @@ void numpyReader(const std::string &filename, NpyData &npyData) { npyData.type = npyType[typestr]; - npyData.elemSize = strtol(&typestr[1], NULL, 10); + npyData.elemSize = strtol(&typestr[1], nullptr, 10); CHECK(npyData.elemSize > 0 && npyData.elemSize <= 8) << "NPY loader: Element size wrong: " << npyData.elemSize; @@ -165,7 +165,7 @@ void numpyReader(const std::string &filename, NpyData &npyData) { std::string token; npyData.nvals = 1; while (std::getline(ss, token, ',')) { - size_t val = strtol(&token[0], NULL, 10); + size_t val = strtol(&token[0], nullptr, 10); CHECK(val > 0) << "NPY loader: Element size wrong: " << val; npyData.shape.push_back(val); npyData.nvals *= val; diff --git a/lib/LLVMIRCodeGen/LLVMCompiledFunction.cpp b/lib/LLVMIRCodeGen/LLVMCompiledFunction.cpp index 4d74c7ff68..88bb1fa468 100644 --- a/lib/LLVMIRCodeGen/LLVMCompiledFunction.cpp +++ b/lib/LLVMIRCodeGen/LLVMCompiledFunction.cpp @@ -98,7 +98,7 @@ Error LLVMCompiledFunction::execute(ExecutionContext *context) { auto *traceContext = context->getTraceContext(); TRACE_EVENT_SCOPE_NAMED(traceContext, TraceLevel::RUNTIME, "findJitmainSymbol", fjEvent); - Expected address = NULL; + Expected address = 0; { std::lock_guard lock(JITLock_); auto sym = JIT_->findSymbol("jitmain"); diff --git a/lib/Support/Support.cpp b/lib/Support/Support.cpp index fe35e92914..78dc5b986d 100644 --- a/lib/Support/Support.cpp +++ b/lib/Support/Support.cpp @@ -161,7 +161,7 @@ const std::string strFormat(const char *format, ...) { // Compute the length of the output to be produced. // The vsnprintf call does not actually write anything, but properly computes // the amount of characters that would be written. - const int len = vsnprintf(NULL, 0, format, vaArgsCopy); + const int len = vsnprintf(nullptr, 0, format, vaArgsCopy); va_end(vaArgsCopy); // Create a formatted string without any risk of memory issues. @@ -185,7 +185,7 @@ const std::string &staticStrFormat(const char *format, ...) { // Compute the length of the output to be produced. // The vsnprintf call does not actually write anything, but properly computes // the amount of characters that would be written. - const int len = vsnprintf(NULL, 0, format, vaArgsCopy); + const int len = vsnprintf(nullptr, 0, format, vaArgsCopy); va_end(vaArgsCopy); // Create a formatted string without any risk of memory issues.