Skip to content

Commit

Permalink
[ATen-VK] Resolve compiler_flags to allow Mac build (#125361)
Browse files Browse the repository at this point in the history
Summary:
## `-Wmissing-prototypes`

In ATen-Vulkan, we often define functions in `.cpp` files without declaring them in `.h` files without hiding them in an anonymous namespace.

Example: [`Packing.cpp`'s channel_image_repacking()](https://github.com/pytorch/pytorch/blob/f1f142c44f81384afbdba5e451fc15744868bf26/aten/src/ATen/native/vulkan/impl/Packing.cpp#L299-L348)

On Mac, this results in a `-Wmissing-prototypes` warning, which is disabled in this change.

## `-Wshadow`

In `Adapter.cpp`, we overwrite a variable called `properties`, which we fix in this change as opposed to disabling the warning.

Test Plan: CI

Differential Revision: D56850324

Pull Request resolved: #125361
Approved by: https://github.com/SS-JIA
  • Loading branch information
jorgep31415 authored and pytorchmergebot committed May 2, 2024
1 parent 55c705b commit 2c8237c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions aten/src/ATen/native/vulkan/api/Adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ PhysicalDevice::PhysicalDevice(VkPhysicalDevice physical_device_handle)
handle, &queue_family_count, queue_families.data());

// Find the total number of compute queues
for (const VkQueueFamilyProperties& properties : queue_families) {
for (const VkQueueFamilyProperties& p : queue_families) {
// Check if this family has compute capability
if (properties.queueFlags & VK_QUEUE_COMPUTE_BIT) {
num_compute_queues += properties.queueCount;
if (p.queueFlags & VK_QUEUE_COMPUTE_BIT) {
num_compute_queues += p.queueCount;
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions c2_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ C2_FBOBJC_EXTRA_TARGET_CONFIG = {
"MTL_LANGUAGE_REVISION": "Metal12",
}

def get_c2_torch_vulkan_compiler_flags():
return ["-Wno-missing-prototypes"]

def get_c2_default_cxx_args():
return dict(
header_namespace = "",
Expand Down

0 comments on commit 2c8237c

Please sign in to comment.