Skip to content

Commit

Permalink
[Minor] Fix compilation warnings (apache#15007)
Browse files Browse the repository at this point in the history
* [Minor] Fix compilation warnings

This PR fixes the following compilation warnings:
- use `nullptr` instead of `NULL` and `0`
- unused variable at `src/tir/schedule/primitive/blockize_tensorize.cc`

* lint
  • Loading branch information
Hzfengsy authored and junrushao committed Jun 22, 2023
1 parent 408517f commit 84f7b49
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
8 changes: 5 additions & 3 deletions src/runtime/vulkan/vulkan_amdrgp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ void AmdRgpProfiler::capture() {
// Trigger RGP capture by using dummy present and switch state from READY to RUNNING
if (curr_state_ == READY) {
VkDebugUtilsLabelEXT frame_end_label = {
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, NULL, "AmdFrameEnd", {0.0f, 0.0f, 0.0f, 0.0f}};
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, nullptr, "AmdFrameEnd", {0.0f, 0.0f, 0.0f, 0.0f}};
device_->queue_insert_debug_utils_label_functions->vkQueueInsertDebugUtilsLabelEXT(
device_->Queue(), &frame_end_label);

VkDebugUtilsLabelEXT frame_begin_label = {
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, NULL, "AmdFrameBegin", {0.0f, 0.0f, 0.0f, 0.0f}};
VkDebugUtilsLabelEXT frame_begin_label = {VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT,
nullptr,
"AmdFrameBegin",
{0.0f, 0.0f, 0.0f, 0.0f}};
device_->queue_insert_debug_utils_label_functions->vkQueueInsertDebugUtilsLabelEXT(
device_->Queue(), &frame_begin_label);

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/vulkan/vulkan_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ bool VulkanBuffer::UseDedicatedAllocation(const VulkanDevice& device, VkBuffer b
// What information to request
VkMemoryDedicatedRequirementsKHR dedicated_req;
dedicated_req.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR;
dedicated_req.pNext = 0;
dedicated_req.pNext = nullptr;

VkMemoryRequirements2KHR req2 = {VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR};
req2.pNext = &dedicated_req;
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/vulkan/vulkan_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ VulkanInstance::VulkanInstance() {
{
// Result from vkGetInstanceProcAddr is NULL if driver only
// supports vulkan 1.0.
auto vkEnumerateInstanceVersion =
(PFN_vkEnumerateInstanceVersion)vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion");
auto vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion)vkGetInstanceProcAddr(
nullptr, "vkEnumerateInstanceVersion");
if (vkEnumerateInstanceVersion) {
vkEnumerateInstanceVersion(&api_version);
}
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/vulkan/vulkan_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ VulkanStream::VulkanStream(const VulkanDevice* device)
cb_begin.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
cb_begin.pNext = nullptr;
cb_begin.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
cb_begin.pInheritanceInfo = 0;
cb_begin.pInheritanceInfo = nullptr;
VULKAN_CALL(vkBeginCommandBuffer(state_->cmd_buffer_, &cb_begin));

if (support::BoolEnvironmentVar("TVM_USE_AMD_RGP")) {
Expand Down Expand Up @@ -135,7 +135,7 @@ void VulkanStream::Synchronize() {
cb_submit.pNext = nullptr;
cb_submit.waitSemaphoreCount = 0;
cb_submit.pWaitSemaphores = nullptr;
cb_submit.pWaitDstStageMask = 0;
cb_submit.pWaitDstStageMask = nullptr;
cb_submit.commandBufferCount = 1;
cb_submit.pCommandBuffers = &(state_->cmd_buffer_);
cb_submit.signalSemaphoreCount = 0;
Expand All @@ -161,7 +161,7 @@ void VulkanStream::Synchronize() {
cb_begin.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
cb_begin.pNext = nullptr;
cb_begin.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
cb_begin.pInheritanceInfo = 0;
cb_begin.pInheritanceInfo = nullptr;
VULKAN_CALL(vkBeginCommandBuffer(state_->cmd_buffer_, &cb_begin));
}

Expand Down
16 changes: 8 additions & 8 deletions src/runtime/vulkan/vulkan_wrapped_func.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void VulkanWrappedFunc::operator()(TVMArgs args, TVMRetValue* rv,

if (device.UseDebugUtilsLabel()) {
VkDebugUtilsLabelEXT dispatch_label = {VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT,
NULL,
nullptr,
func_name_.c_str(),
{0.0f, 0.0f, 0.0f, 0.0f}};
device.queue_insert_debug_utils_label_functions->vkQueueInsertDebugUtilsLabelEXT(
Expand All @@ -118,14 +118,14 @@ void VulkanWrappedFunc::operator()(TVMArgs args, TVMRetValue* rv,
write_descriptor_sets.resize(descriptor_buffers.size());
for (size_t i = 0; i < write_descriptor_sets.size(); i++) {
write_descriptor_sets[i].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
write_descriptor_sets[i].pNext = 0;
write_descriptor_sets[i].pNext = nullptr;
write_descriptor_sets[i].dstSet = pipeline->descriptor_set;
write_descriptor_sets[i].dstBinding = i;
write_descriptor_sets[i].dstArrayElement = 0;
write_descriptor_sets[i].descriptorCount = 1;
write_descriptor_sets[i].pImageInfo = 0;
write_descriptor_sets[i].pImageInfo = nullptr;
write_descriptor_sets[i].pBufferInfo = &(descriptor_buffers[i]);
write_descriptor_sets[i].pTexelBufferView = 0;
write_descriptor_sets[i].pTexelBufferView = nullptr;

if (pipeline->use_ubo && i == write_descriptor_sets.size() - 1) {
// The last binding is for UBO
Expand All @@ -135,7 +135,7 @@ void VulkanWrappedFunc::operator()(TVMArgs args, TVMRetValue* rv,
}
}
vkUpdateDescriptorSets(device, write_descriptor_sets.size(), write_descriptor_sets.data(), 0,
0);
nullptr);
};
const auto& deferred_kernel = [this, pipeline, wl, pack_args_storage, nbytes_scalars,
device_id](VulkanStreamState* state) {
Expand Down Expand Up @@ -176,7 +176,7 @@ void VulkanWrappedFunc::operator()(TVMArgs args, TVMRetValue* rv,

if (device.UseDebugUtilsLabel()) {
VkDebugUtilsLabelEXT dispatch_label = {VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT,
NULL,
nullptr,
func_name_.c_str(),
{0.0f, 0.0f, 0.0f, 0.0f}};
device.queue_insert_debug_utils_label_functions->vkQueueInsertDebugUtilsLabelEXT(
Expand Down Expand Up @@ -388,7 +388,7 @@ std::shared_ptr<VulkanPipeline> VulkanModuleNode::GetPipeline(size_t device_id,
if (device.UseImmediate()) {
VkDescriptorUpdateTemplateCreateInfoKHR descrip_template_cinfo;
descrip_template_cinfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO_KHR;
descrip_template_cinfo.pNext = 0;
descrip_template_cinfo.pNext = nullptr;
descrip_template_cinfo.flags = 0;
descrip_template_cinfo.descriptorUpdateEntryCount = arg_template.size();
descrip_template_cinfo.pDescriptorUpdateEntries = arg_template.data();
Expand All @@ -398,7 +398,7 @@ std::shared_ptr<VulkanPipeline> VulkanModuleNode::GetPipeline(size_t device_id,
descrip_template_cinfo.pipelineLayout = pe->pipeline_layout;
descrip_template_cinfo.set = 0;
VULKAN_CALL(device.descriptor_template_khr_functions->vkCreateDescriptorUpdateTemplateKHR(
device, &descrip_template_cinfo, 0, &(pe->descriptor_update_template)));
device, &descrip_template_cinfo, nullptr, &(pe->descriptor_update_template)));
}
ecache_[device_id][func_name] = pe;
return pe;
Expand Down
2 changes: 1 addition & 1 deletion src/target/llvm/codegen_cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ CodeGenCPU::PackedCall CodeGenCPU::MakeCallPackedLowered(const Array<PrimExpr>&

llvm::BasicBlock* end_block = CheckCallSuccess(call);

PackedCall pc = {0};
PackedCall pc = {nullptr};

if (!r_type.is_void()) {
// Load the return value and cast it to the designated type (r_type).
Expand Down
2 changes: 0 additions & 2 deletions src/tir/schedule/primitive/blockize_tensorize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,6 @@ class BlockizeRewriter : public StmtMutator {
const SeqStmtNode* seq = stmt.as<SeqStmtNode>();
ICHECK(seq) << "Target blocks must not be nested with each other!";
int idx_start = -1;
int found_cnt = 0;
int last_found_idx = -1;
size_t cur_idx = 0;
Array<Stmt> new_seq;
Expand All @@ -688,7 +687,6 @@ class BlockizeRewriter : public StmtMutator {
ICHECK_EQ(last_found_idx, cur_idx - 1) << "Target blocks must be consecutive!";
}
last_found_idx = cur_idx;
++found_cnt;
} else {
new_seq.push_back(it);
}
Expand Down

0 comments on commit 84f7b49

Please sign in to comment.