Skip to content

Commit

Permalink
fix condition to use nonuniform decoration
Browse files Browse the repository at this point in the history
  • Loading branch information
rjodinchr committed Jul 25, 2023
1 parent 1aa2d55 commit d4e47fa
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Install packages
run: sudo apt-get install -y clang-format
run: sudo apt-get install -y clang-format-15 clang-format
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check format
run: |
./tests/check-format.sh
env:
CLANG_FORMAT_BINARY: clang-format-15
build:
name: Build ${{ matrix.os }} ${{ matrix.android }} ${{ matrix.android-abi }} compiler ${{ matrix.compiler-available }} online ${{ matrix.online-compiler }}
needs: format
Expand Down
5 changes: 5 additions & 0 deletions src/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ void cvk_device::init_features(VkInstance instance) {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES;
m_features_buffer_device_address.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_KHR;
m_features_descriptor_indexing.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES;

std::vector<std::tuple<uint32_t, const char*, VkBaseOutStructure*>>
coreversion_extension_features = {
Expand Down Expand Up @@ -334,6 +336,9 @@ void cvk_device::init_features(VkInstance instance) {
VER_EXT_FEAT(VK_MAKE_VERSION(1, 2, 0),
VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME,
m_features_buffer_device_address),
VER_EXT_FEAT(VK_MAKE_VERSION(1, 2, 0),
VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME,
m_features_descriptor_indexing),

#undef VER_EXT_FEAT
};
Expand Down
28 changes: 25 additions & 3 deletions src/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,31 @@ struct cvk_device : public _cl_device_id,
bool supports_subgroups() const { return m_has_subgroups_support; }

bool supports_non_uniform_decoration() const {
return m_properties.apiVersion >= VK_MAKE_VERSION(1, 2, 0) ||
is_vulkan_extension_enabled(
VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
bool supported = m_properties.apiVersion >= VK_MAKE_VERSION(1, 2, 0) ||
is_vulkan_extension_enabled(
VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);

// This is a hack to work-around a driver bug in mali device using the
// bifrost driver.
if (m_clvk_properties->get_non_uniform_decoration_unsupported()) {
return false;
}

if (supported && !(m_features_descriptor_indexing
.shaderSampledImageArrayNonUniformIndexing &&
m_features_descriptor_indexing
.shaderStorageImageArrayNonUniformIndexing &&
m_features_descriptor_indexing
.shaderUniformBufferArrayNonUniformIndexing &&
m_features_descriptor_indexing
.shaderStorageBufferArrayNonUniformIndexing)) {
cvk_warn_fn("Device should support non-uniform decorations, but "
"some expected features are set to false. This is "
"unexpected and might lead to errors");
}
return supported;
}

bool supports_atomic_order_acq_rel() const {
return m_features_vulkan_memory_model.vulkanMemoryModel;
}
Expand Down Expand Up @@ -588,6 +609,7 @@ struct cvk_device : public _cl_device_id,
m_features_vulkan_memory_model{};
VkPhysicalDeviceBufferDeviceAddressFeaturesKHR
m_features_buffer_device_address{};
VkPhysicalDeviceDescriptorIndexingFeatures m_features_descriptor_indexing{};
VkPhysicalDeviceFloatControlsProperties m_float_controls_properties{};

VkDevice m_dev;
Expand Down
23 changes: 18 additions & 5 deletions src/device_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ struct cvk_device_properties_mali : public cvk_device_properties {
std::string vendor() const override final { return "ARM"; }
cl_uint get_max_first_cmd_batch_size() const override final { return 10; }
cl_uint get_max_cmd_group_size() const override final { return 1; }

cvk_device_properties_mali(const uint32_t deviceID)
: m_deviceID(deviceID) {}

bool get_non_uniform_decoration_unsupported() const override final {
#define GPU_ID2_ARCH_MAJOR_SHIFT 28
#define GPU_ID2_ARCH_MAJOR (0xF << GPU_ID2_ARCH_MAJOR_SHIFT)
const uint32_t bifrost_arch_major = 9 << GPU_ID2_ARCH_MAJOR_SHIFT;
return (m_deviceID & GPU_ID2_ARCH_MAJOR) < bifrost_arch_major;
}

private:
const uint32_t m_deviceID;
};

struct cvk_device_properties_mali_exynos9820
Expand Down Expand Up @@ -235,9 +248,9 @@ static bool isNVIDIADevice(const uint32_t vendorID) {
return vendorID == NVIDIAVendorID;
}

#define RETURN(x) \
#define RETURN(x, ...) \
cvk_info_fn(#x); \
return std::make_unique<x>();
return std::make_unique<x>(__VA_ARGS__);

std::unique_ptr<cvk_device_properties>
create_cvk_device_properties(const char* name, const uint32_t vendorID,
Expand All @@ -251,9 +264,9 @@ create_cvk_device_properties(const char* name, const uint32_t vendorID,
cvk_warn("Unable to query 'ro.hardware' system property, some "
"device properties will be incorrect.");
} else if (strcmp(soc, "exynos9820") == 0) {
RETURN(cvk_device_properties_mali_exynos9820);
RETURN(cvk_device_properties_mali_exynos9820, deviceID);
} else if (strcmp(soc, "exynos990") == 0) {
RETURN(cvk_device_properties_mali_exynos990);
RETURN(cvk_device_properties_mali_exynos990, deviceID);
} else {
cvk_warn("Unrecognized 'ro.hardware' value '%s', some device "
"properties will be incorrect.",
Expand All @@ -263,7 +276,7 @@ create_cvk_device_properties(const char* name, const uint32_t vendorID,
cvk_warn("Unrecognized Mali device, some device properties will be "
"incorrect.");
#endif
RETURN(cvk_device_properties_mali);
RETURN(cvk_device_properties_mali, deviceID);
} else if (strcmp(name, "Adreno (TM) 615") == 0) {
RETURN(cvk_device_properties_adreno_615);
} else if (strcmp(name, "Adreno (TM) 620") == 0) {
Expand Down
6 changes: 6 additions & 0 deletions src/device_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ struct cvk_device_properties {
return std::set<std::string>();
}

// This is a hack to work-around a driver bug in mali device using the
// bifrost driver.
virtual bool get_non_uniform_decoration_unsupported() const {
return false;
}

virtual ~cvk_device_properties() {}
};

Expand Down
6 changes: 5 additions & 1 deletion tests/check-format.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#!/usr/bin/env bash

GIT_CLANG_FORMAT=${GIT_CLANG_FORMAT:-git-clang-format}
if [ ${CLANG_FORMAT_BINARY} ]; then
GIT_CLANG_FORMAT_BINARY="--binary ${CLANG_FORMAT_BINARY}"
fi
GIT_CLANG_FORMAT_BINARY=${GIT_CLANG_FORMAT_BINARY:-}

# Run git-clang-format to check for violations
CLANG_FORMAT_OUTPUT=/tmp/clvk-clang-format-output.txt
${GIT_CLANG_FORMAT} --diff origin/main --extensions cpp,hpp >$CLANG_FORMAT_OUTPUT
${GIT_CLANG_FORMAT} ${GIT_CLANG_FORMAT_BINARY} --diff origin/main --extensions cpp,hpp >$CLANG_FORMAT_OUTPUT

# Check for no-ops
grep '^no modified files to format$' "$CLANG_FORMAT_OUTPUT" && exit 0
Expand Down

0 comments on commit d4e47fa

Please sign in to comment.