[Mlir-commits] [mlir] 9c2cd6e - Fix clang-tidy warning "modernize-use-nullptr" in MLIR VulkanRuntime (NFC)

Mehdi Amini llvmlistbot at llvm.org
Sun Sep 26 15:06:08 PDT 2021


Author: Mehdi Amini
Date: 2021-09-26T22:06:00Z
New Revision: 9c2cd6e7c803eabbee652f9477c23aeda8ce02c8

URL: https://github.com/llvm/llvm-project/commit/9c2cd6e7c803eabbee652f9477c23aeda8ce02c8
DIFF: https://github.com/llvm/llvm-project/commit/9c2cd6e7c803eabbee652f9477c23aeda8ce02c8.diff

LOG: Fix clang-tidy warning "modernize-use-nullptr" in MLIR VulkanRuntime (NFC)

Added: 
    

Modified: 
    mlir/tools/mlir-vulkan-runner/VulkanRuntime.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/tools/mlir-vulkan-runner/VulkanRuntime.cpp b/mlir/tools/mlir-vulkan-runner/VulkanRuntime.cpp
index db9f47938fc28..8f1d238110632 100644
--- a/mlir/tools/mlir-vulkan-runner/VulkanRuntime.cpp
+++ b/mlir/tools/mlir-vulkan-runner/VulkanRuntime.cpp
@@ -237,19 +237,20 @@ LogicalResult VulkanRuntime::createInstance() {
   instanceCreateInfo.flags = 0;
   instanceCreateInfo.pApplicationInfo = &applicationInfo;
   instanceCreateInfo.enabledLayerCount = 0;
-  instanceCreateInfo.ppEnabledLayerNames = 0;
+  instanceCreateInfo.ppEnabledLayerNames = nullptr;
   instanceCreateInfo.enabledExtensionCount = 0;
-  instanceCreateInfo.ppEnabledExtensionNames = 0;
+  instanceCreateInfo.ppEnabledExtensionNames = nullptr;
 
-  RETURN_ON_VULKAN_ERROR(vkCreateInstance(&instanceCreateInfo, 0, &instance),
-                         "vkCreateInstance");
+  RETURN_ON_VULKAN_ERROR(
+      vkCreateInstance(&instanceCreateInfo, nullptr, &instance),
+      "vkCreateInstance");
   return success();
 }
 
 LogicalResult VulkanRuntime::createDevice() {
   uint32_t physicalDeviceCount = 0;
   RETURN_ON_VULKAN_ERROR(
-      vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, 0),
+      vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, nullptr),
       "vkEnumeratePhysicalDevices");
 
   std::vector<VkPhysicalDevice> physicalDevices(physicalDeviceCount);
@@ -289,7 +290,7 @@ LogicalResult VulkanRuntime::createDevice() {
   deviceCreateInfo.pEnabledFeatures = nullptr;
 
   RETURN_ON_VULKAN_ERROR(
-      vkCreateDevice(physicalDevice, &deviceCreateInfo, 0, &device),
+      vkCreateDevice(physicalDevice, &deviceCreateInfo, nullptr, &device),
       "vkCreateDevice");
 
   VkPhysicalDeviceMemoryProperties properties = {};
@@ -337,8 +338,8 @@ LogicalResult VulkanRuntime::createDevice() {
 
 LogicalResult VulkanRuntime::getBestComputeQueue() {
   uint32_t queueFamilyPropertiesCount = 0;
-  vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice,
-                                           &queueFamilyPropertiesCount, 0);
+  vkGetPhysicalDeviceQueueFamilyProperties(
+      physicalDevice, &queueFamilyPropertiesCount, nullptr);
 
   std::vector<VkQueueFamilyProperties> familyProperties(
       queueFamilyPropertiesCount);
@@ -430,11 +431,13 @@ LogicalResult VulkanRuntime::createMemoryBuffers() {
       memoryAllocateInfo.memoryTypeIndex = hostMemoryTypeIndex;
 
       // Allocate device memory.
-      RETURN_ON_VULKAN_ERROR(vkAllocateMemory(device, &memoryAllocateInfo, 0,
+      RETURN_ON_VULKAN_ERROR(vkAllocateMemory(device, &memoryAllocateInfo,
+                                              nullptr,
                                               &memoryBuffer.hostMemory),
                              "vkAllocateMemory");
       memoryAllocateInfo.memoryTypeIndex = deviceMemoryTypeIndex;
-      RETURN_ON_VULKAN_ERROR(vkAllocateMemory(device, &memoryAllocateInfo, 0,
+      RETURN_ON_VULKAN_ERROR(vkAllocateMemory(device, &memoryAllocateInfo,
+                                              nullptr,
                                               &memoryBuffer.deviceMemory),
                              "vkAllocateMemory");
       void *payload;
@@ -457,10 +460,10 @@ LogicalResult VulkanRuntime::createMemoryBuffers() {
       bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
       bufferCreateInfo.queueFamilyIndexCount = 1;
       bufferCreateInfo.pQueueFamilyIndices = &queueFamilyIndex;
-      RETURN_ON_VULKAN_ERROR(vkCreateBuffer(device, &bufferCreateInfo, 0,
+      RETURN_ON_VULKAN_ERROR(vkCreateBuffer(device, &bufferCreateInfo, nullptr,
                                             &memoryBuffer.hostBuffer),
                              "vkCreateBuffer");
-      RETURN_ON_VULKAN_ERROR(vkCreateBuffer(device, &bufferCreateInfo, 0,
+      RETURN_ON_VULKAN_ERROR(vkCreateBuffer(device, &bufferCreateInfo, nullptr,
                                             &memoryBuffer.deviceBuffer),
                              "vkCreateBuffer");
 
@@ -489,7 +492,7 @@ LogicalResult VulkanRuntime::createMemoryBuffers() {
 LogicalResult VulkanRuntime::copyResource(bool deviceToHost) {
   VkCommandBufferAllocateInfo commandBufferAllocateInfo = {
       VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
-      NULL,
+      nullptr,
       commandPool,
       VK_COMMAND_BUFFER_LEVEL_PRIMARY,
       1,
@@ -502,9 +505,9 @@ LogicalResult VulkanRuntime::copyResource(bool deviceToHost) {
 
   VkCommandBufferBeginInfo commandBufferBeginInfo = {
       VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
-      NULL,
+      nullptr,
       0,
-      NULL,
+      nullptr,
   };
   RETURN_ON_VULKAN_ERROR(
       vkBeginCommandBuffer(commandBuffer, &commandBufferBeginInfo),
@@ -528,14 +531,14 @@ LogicalResult VulkanRuntime::copyResource(bool deviceToHost) {
                          "vkEndCommandBuffer");
   VkSubmitInfo submitInfo = {
       VK_STRUCTURE_TYPE_SUBMIT_INFO,
-      NULL,
+      nullptr,
       0,
-      NULL,
-      NULL,
+      nullptr,
+      nullptr,
       1,
       &commandBuffer,
       0,
-      NULL,
+      nullptr,
   };
   submitInfo.pCommandBuffers = &commandBuffer;
   RETURN_ON_VULKAN_ERROR(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE),
@@ -555,9 +558,9 @@ LogicalResult VulkanRuntime::createShaderModule() {
   shaderModuleCreateInfo.codeSize = binarySize;
   // Set pointer to the binary shader.
   shaderModuleCreateInfo.pCode = reinterpret_cast<uint32_t *>(binary);
-  RETURN_ON_VULKAN_ERROR(
-      vkCreateShaderModule(device, &shaderModuleCreateInfo, 0, &shaderModule),
-      "vkCreateShaderModule");
+  RETURN_ON_VULKAN_ERROR(vkCreateShaderModule(device, &shaderModuleCreateInfo,
+                                              nullptr, &shaderModule),
+                         "vkCreateShaderModule");
   return success();
 }
 
@@ -574,7 +577,7 @@ void VulkanRuntime::initDescriptorSetLayoutBindingMap() {
       descriptorSetLayoutBinding.descriptorType = memBuffer.descriptorType;
       descriptorSetLayoutBinding.descriptorCount = 1;
       descriptorSetLayoutBinding.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
-      descriptorSetLayoutBinding.pImmutableSamplers = 0;
+      descriptorSetLayoutBinding.pImmutableSamplers = nullptr;
       descriptorSetLayoutBindings.push_back(descriptorSetLayoutBinding);
     }
     descriptorSetLayoutBindingMap[descriptorSetIndex] =
@@ -615,8 +618,8 @@ LogicalResult VulkanRuntime::createDescriptorSetLayout() {
     descriptorSetLayoutCreateInfo.pBindings =
         descriptorSetLayoutBindings.data();
     RETURN_ON_VULKAN_ERROR(
-        vkCreateDescriptorSetLayout(device, &descriptorSetLayoutCreateInfo, 0,
-                                    &descriptorSetLayout),
+        vkCreateDescriptorSetLayout(device, &descriptorSetLayoutCreateInfo,
+                                    nullptr, &descriptorSetLayout),
         "vkCreateDescriptorSetLayout");
 
     descriptorSetLayouts.push_back(descriptorSetLayout);
@@ -636,10 +639,10 @@ LogicalResult VulkanRuntime::createPipelineLayout() {
   pipelineLayoutCreateInfo.setLayoutCount = descriptorSetLayouts.size();
   pipelineLayoutCreateInfo.pSetLayouts = descriptorSetLayouts.data();
   pipelineLayoutCreateInfo.pushConstantRangeCount = 0;
-  pipelineLayoutCreateInfo.pPushConstantRanges = 0;
+  pipelineLayoutCreateInfo.pPushConstantRanges = nullptr;
   RETURN_ON_VULKAN_ERROR(vkCreatePipelineLayout(device,
-                                                &pipelineLayoutCreateInfo, 0,
-                                                &pipelineLayout),
+                                                &pipelineLayoutCreateInfo,
+                                                nullptr, &pipelineLayout),
                          "vkCreatePipelineLayout");
   return success();
 }
@@ -653,7 +656,7 @@ LogicalResult VulkanRuntime::createComputePipeline() {
   stageInfo.module = shaderModule;
   // Set entry point.
   stageInfo.pName = entryPoint;
-  stageInfo.pSpecializationInfo = 0;
+  stageInfo.pSpecializationInfo = nullptr;
 
   VkComputePipelineCreateInfo computePipelineCreateInfo = {};
   computePipelineCreateInfo.sType =
@@ -662,11 +665,11 @@ LogicalResult VulkanRuntime::createComputePipeline() {
   computePipelineCreateInfo.flags = 0;
   computePipelineCreateInfo.stage = stageInfo;
   computePipelineCreateInfo.layout = pipelineLayout;
-  computePipelineCreateInfo.basePipelineHandle = 0;
+  computePipelineCreateInfo.basePipelineHandle = nullptr;
   computePipelineCreateInfo.basePipelineIndex = 0;
-  RETURN_ON_VULKAN_ERROR(vkCreateComputePipelines(device, 0, 1,
-                                                  &computePipelineCreateInfo, 0,
-                                                  &pipeline),
+  RETURN_ON_VULKAN_ERROR(vkCreateComputePipelines(device, nullptr, 1,
+                                                  &computePipelineCreateInfo,
+                                                  nullptr, &pipeline),
                          "vkCreateComputePipelines");
   return success();
 }
@@ -690,8 +693,8 @@ LogicalResult VulkanRuntime::createDescriptorPool() {
   descriptorPoolCreateInfo.poolSizeCount = descriptorPoolSizes.size();
   descriptorPoolCreateInfo.pPoolSizes = descriptorPoolSizes.data();
   RETURN_ON_VULKAN_ERROR(vkCreateDescriptorPool(device,
-                                                &descriptorPoolCreateInfo, 0,
-                                                &descriptorPool),
+                                                &descriptorPoolCreateInfo,
+                                                nullptr, &descriptorPool),
                          "vkCreateDescriptorPool");
   return success();
 }
@@ -817,7 +820,7 @@ LogicalResult VulkanRuntime::createComputeCommandBuffer() {
   vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
   vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE,
                           pipelineLayout, 0, descriptorSets.size(),
-                          descriptorSets.data(), 0, 0);
+                          descriptorSets.data(), 0, nullptr);
   // Get a timestamp before invoking the compute shader.
   if (queryPool != VK_NULL_HANDLE)
     vkCmdWriteTimestamp(commandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
@@ -842,13 +845,13 @@ LogicalResult VulkanRuntime::submitCommandBuffersToQueue() {
   submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
   submitInfo.pNext = nullptr;
   submitInfo.waitSemaphoreCount = 0;
-  submitInfo.pWaitSemaphores = 0;
-  submitInfo.pWaitDstStageMask = 0;
+  submitInfo.pWaitSemaphores = nullptr;
+  submitInfo.pWaitDstStageMask = nullptr;
   submitInfo.commandBufferCount = commandBuffers.size();
   submitInfo.pCommandBuffers = commandBuffers.data();
   submitInfo.signalSemaphoreCount = 0;
   submitInfo.pSignalSemaphores = nullptr;
-  RETURN_ON_VULKAN_ERROR(vkQueueSubmit(queue, 1, &submitInfo, 0),
+  RETURN_ON_VULKAN_ERROR(vkQueueSubmit(queue, 1, &submitInfo, nullptr),
                          "vkQueueSubmit");
   return success();
 }


        


More information about the Mlir-commits mailing list