Skip to content

Commit

Permalink
Zero initialize structures and add structure types
Browse files Browse the repository at this point in the history
Signed-off-by: Jemale Lockett <[email protected]>
  • Loading branch information
Jemale authored and bmyates committed Aug 6, 2021
1 parent 19f12d9 commit 6f041ca
Show file tree
Hide file tree
Showing 21 changed files with 65 additions and 55 deletions.
3 changes: 3 additions & 0 deletions conformance_tests/core/test_cmdlist/src/test_cmdlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,11 @@ TEST(
uint32_t idxMemorySize = arraySize * sizeof(uint32_t);

ze_device_mem_alloc_desc_t deviceDesc = {};
deviceDesc.stype = ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC;
deviceDesc.flags = ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED;
deviceDesc.ordinal = 0;
ze_host_mem_alloc_desc_t hostDesc = {};
hostDesc.stype = ZE_STRUCTURE_TYPE_HOST_MEM_ALLOC_DESC;
hostDesc.flags = ZE_HOST_MEM_ALLOC_FLAG_BIAS_UNCACHED;
void *srcBuffer = lzt::allocate_host_memory(srcMemorySize);
void *dstBuffer = lzt::allocate_host_memory(expectedMemorySize);
Expand Down Expand Up @@ -614,6 +616,7 @@ TEST(
ze_kernel_handle_t scratch_function =
lzt::create_function(module_handle, flag, "scratch_kernel");
ze_kernel_properties_t kernelProperties = {};
kernelProperties.stype = ZE_STRUCTURE_TYPE_KERNEL_PROPERTIES;
zeKernelGetProperties(scratch_function, &kernelProperties);
EXPECT_NE(kernelProperties.spillMemSize, 0);
std::cout << "Scratch size = " << kernelProperties.spillMemSize << "\n";
Expand Down
3 changes: 1 addition & 2 deletions conformance_tests/core/test_cmdqueue/src/test_cmdqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ TEST_P(zeCommandQueueCreateTests,
const ze_driver_handle_t driver = lzt::get_default_driver();
const ze_context_handle_t context = lzt::get_default_context();

ze_device_properties_t properties;

ze_device_properties_t properties = {};
properties.pNext = nullptr;
properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGetProperties(device, &properties));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ TEST_F(EventProfilingTests,
auto ep_no_timestamps =
lzt::create_event_pool(context, 10, ZE_EVENT_POOL_FLAG_HOST_VISIBLE);
ze_event_desc_t regular_event_desc = {};
regular_event_desc.stype = ZE_STRUCTURE_TYPE_EVENT_DESC;
regular_event_desc.index = 1;
regular_event_desc.signal = ZE_EVENT_SCOPE_FLAG_HOST;
regular_event_desc.wait = ZE_EVENT_SCOPE_FLAG_HOST;
Expand Down
5 changes: 4 additions & 1 deletion conformance_tests/core/test_ipc/src/test_ipc_p2p_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ inline void init_process(ze_context_handle_t &context,
}

if (concurrency_offset > 0) {
ze_device_p2p_properties_t peerProperties;
ze_device_p2p_properties_t peerProperties = {};
peerProperties.stype = ZE_STRUCTURE_TYPE_DEVICE_P2P_PROPERTIES;

zeDeviceGetP2PProperties(devices[device_x], devices[device_y],
&peerProperties);
Expand Down Expand Up @@ -145,6 +146,7 @@ inline void init_process(ze_context_handle_t &context,

for (uint32_t ordinal : ordinals) {
ze_command_queue_desc_t cmdQueueDesc = {};
cmdQueueDesc.stype = ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC;
cmdQueueDesc.ordinal = ordinal;
cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;

Expand All @@ -155,6 +157,7 @@ inline void init_process(ze_context_handle_t &context,
queues.push_back(queue);

ze_command_list_desc_t listDesc = {};
listDesc.stype = ZE_STRUCTURE_TYPE_COMMAND_LIST_DESC;
listDesc.commandQueueGroupOrdinal = ordinal;
ze_command_list_handle_t list;
zeCommandListCreate(context, device, &listDesc, &list);
Expand Down
2 changes: 1 addition & 1 deletion conformance_tests/core/test_memory/src/test_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ TEST_P(
const size_t size = std::get<0>(GetParam());
const size_t alignment = std::get<1>(GetParam());
void *memory = lzt::allocate_host_memory(size, alignment);
ze_memory_allocation_properties_t mem_properties;
ze_memory_allocation_properties_t mem_properties = {};
auto context = lzt::get_default_context();

mem_properties.stype = ZE_STRUCTURE_TYPE_MEMORY_ALLOCATION_PROPERTIES;
Expand Down
8 changes: 4 additions & 4 deletions conformance_tests/core/test_module/src/test_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,8 @@ TEST_F(zeKernelCreateTests,
TEST_F(
zeKernelCreateTests,
GivenValidFunctionWhenGettingPropertiesThenReturnSuccessfulAndPropertiesAreValid) {
ze_device_compute_properties_t dev_compute_properties;

ze_device_compute_properties_t dev_compute_properties = {};
dev_compute_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_COMPUTE_PROPERTIES;
dev_compute_properties.pNext = nullptr;
EXPECT_EQ(ZE_RESULT_SUCCESS,
zeDeviceGetComputeProperties(device_, &dev_compute_properties));
Expand Down Expand Up @@ -782,8 +782,8 @@ class zeKernelLaunchTests
};

void zeKernelLaunchTests::test_kernel_execution() {
ze_device_compute_properties_t dev_compute_properties;

ze_device_compute_properties_t dev_compute_properties = {};
dev_compute_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_COMPUTE_PROPERTIES;
dev_compute_properties.pNext = nullptr;
EXPECT_EQ(ZE_RESULT_SUCCESS,
zeDeviceGetComputeProperties(device_, &dev_compute_properties));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ TEST_P(
ze_command_queue_mode_t mode = std::get<1>(GetParam()); // mode
ze_command_queue_priority_t priority = std::get<2>(GetParam()); // priority
ze_device_handle_t device = lzt::zeDevice::get_instance()->get_device();
ze_device_properties_t properties;
ze_device_properties_t properties = {};
properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGetProperties(device, &properties));

uint32_t ordinal = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void perform_memory_manipulation() {
ze_device_handle_t device = lzt::zeDevice::get_instance()->get_device();
ze_device_handle_t device_test = device;

ze_memory_allocation_properties_t memory_properties;
ze_memory_allocation_properties_t memory_properties = {};
memory_properties.pNext = nullptr;
memory_properties.stype = ZE_STRUCTURE_TYPE_MEMORY_ALLOCATION_PROPERTIES;
lzt::get_mem_alloc_properties(context, device_ptr, &memory_properties,
Expand Down
4 changes: 2 additions & 2 deletions conformance_tests/core/test_p2p/src/test_p2p_mem_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ class zeP2PMemAccessTests : public lzt::zeEventPoolTests,
get_devices_ = devices.size();
LOG_INFO << "Detected " << get_devices_ << " devices";

ze_device_compute_properties_t dev_compute_properties;
ze_device_compute_properties_t dev_compute_properties = {};

for (auto device : devices) {
DevAccess instance;
DevAccess instance = {};
instance.dev = device;
instance.dev_grp = driver;
instance.device_mem_local = nullptr;
Expand Down
21 changes: 11 additions & 10 deletions conformance_tests/tools/tracing/src/test_api_tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,19 @@ class TracingPrologueEpilogueTests : public ::testing::Test {
ze_driver_handle_t driver;

ze_device_handle_t device;
ze_device_properties_t properties;
ze_device_compute_properties_t compute_properties;
ze_device_properties_t properties = {};
ze_device_compute_properties_t compute_properties = {};

ze_device_memory_properties_t memory_properties;
ze_device_memory_properties_t memory_properties = {};

ze_device_memory_access_properties_t memory_access_properties;
ze_device_memory_access_properties_t memory_access_properties = {};

ze_device_cache_properties_t cache_properties;
ze_device_image_properties_t device_image_properties;
ze_device_p2p_properties_t p2p_properties;
ze_device_cache_properties_t cache_properties = {};
ze_device_image_properties_t device_image_properties = {};
ze_device_p2p_properties_t p2p_properties = {};

ze_api_version_t api_version;
ze_driver_ipc_properties_t ipc_properties;
ze_driver_ipc_properties_t ipc_properties = {};

ze_command_queue_desc_t command_queue_desc = {
ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC, nullptr};
Expand Down Expand Up @@ -273,7 +273,7 @@ class TracingPrologueEpilogueTests : public ::testing::Test {

void *device_memory, *host_memory, *shared_memory, *memory = nullptr;

ze_memory_allocation_properties_t mem_alloc_properties;
ze_memory_allocation_properties_t mem_alloc_properties = {};

std::vector<uint8_t> binary_file =
level_zero_tests::load_binary_file("module_add.spv");
Expand All @@ -297,7 +297,7 @@ class TracingPrologueEpilogueTests : public ::testing::Test {
ze_sampler_handle_t sampler = nullptr;

uint32_t num = 0, version;
ze_driver_properties_t driver_properties;
ze_driver_properties_t driver_properties = {};
ze_bool_t can_access;
};

Expand Down Expand Up @@ -1785,6 +1785,7 @@ TEST_F(
init_kernel();

ze_kernel_properties_t kernel_properties = {};
kernel_properties.stype = ZE_STRUCTURE_TYPE_KERNEL_PROPERTIES;
ze_result_t initial_result =
zeKernelGetProperties(kernel, &kernel_properties);
ready_tracer(tracer_handle, prologues, epilogues);
Expand Down
23 changes: 12 additions & 11 deletions layer_tests/tracing/src/test_api_ltracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,19 @@ class LTracingPrologueEpilogueTests : public ::testing::Test {
ze_driver_handle_t driver;

ze_device_handle_t device;
ze_device_properties_t properties;
ze_device_compute_properties_t compute_properties;
ze_device_properties_t properties = {};
ze_device_compute_properties_t compute_properties = {};

ze_device_memory_properties_t memory_properties;
ze_device_memory_properties_t memory_properties = {};

ze_device_memory_access_properties_t memory_access_properties;
ze_device_memory_access_properties_t memory_access_properties = {};

ze_device_cache_properties_t cache_properties;
ze_device_image_properties_t device_image_properties;
ze_device_p2p_properties_t p2p_properties;
ze_device_cache_properties_t cache_properties = {};
ze_device_image_properties_t device_image_properties = {};
ze_device_p2p_properties_t p2p_properties = {};

ze_api_version_t api_version;
ze_driver_ipc_properties_t ipc_properties;
ze_driver_ipc_properties_t ipc_properties = {};

ze_command_queue_desc_t command_queue_desc = {
ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC, nullptr};
Expand Down Expand Up @@ -267,11 +267,11 @@ class LTracingPrologueEpilogueTests : public ::testing::Test {
0,
0};
ze_image_handle_t image = nullptr;
ze_image_properties_t image_properties;
ze_image_properties_t image_properties = {};

void *device_memory, *host_memory, *shared_memory, *memory = nullptr;

ze_memory_allocation_properties_t mem_alloc_properties;
ze_memory_allocation_properties_t mem_alloc_properties = {};

std::vector<uint8_t> binary_file =
level_zero_tests::load_binary_file("module_add.spv");
Expand All @@ -295,7 +295,7 @@ class LTracingPrologueEpilogueTests : public ::testing::Test {
ze_sampler_handle_t sampler = nullptr;

uint32_t num = 0, version;
ze_driver_properties_t driver_properties;
ze_driver_properties_t driver_properties = {};
ze_bool_t can_access;
};

Expand Down Expand Up @@ -1788,6 +1788,7 @@ TEST_F(
init_kernel();

ze_kernel_properties_t kernel_properties = {};
kernel_properties.stype = ZE_STRUCTURE_TYPE_KERNEL_PROPERTIES;
ze_result_t initial_result =
zeKernelGetProperties(kernel, &kernel_properties);
ready_ltracer(tracer_handle, prologues, epilogues);
Expand Down
23 changes: 12 additions & 11 deletions layer_tests/tracing/src/test_api_ltracing_compat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,19 @@ class LCTracingPrologueEpilogueTests : public ::testing::Test {
ze_driver_handle_t driver;

ze_device_handle_t device;
ze_device_properties_t properties;
ze_device_compute_properties_t compute_properties;
ze_device_properties_t properties = {};
ze_device_compute_properties_t compute_properties = {};

ze_device_memory_properties_t memory_properties;
ze_device_memory_properties_t memory_properties = {};

ze_device_memory_access_properties_t memory_access_properties;
ze_device_memory_access_properties_t memory_access_properties = {};

ze_device_cache_properties_t cache_properties;
ze_device_image_properties_t device_image_properties;
ze_device_p2p_properties_t p2p_properties;
ze_device_cache_properties_t cache_properties = {};
ze_device_image_properties_t device_image_properties = {};
ze_device_p2p_properties_t p2p_properties = {};

ze_api_version_t api_version;
ze_driver_ipc_properties_t ipc_properties;
ze_driver_ipc_properties_t ipc_properties = {};

ze_command_queue_desc_t command_queue_desc = {
ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC, nullptr};
Expand Down Expand Up @@ -267,11 +267,11 @@ class LCTracingPrologueEpilogueTests : public ::testing::Test {
0,
0};
ze_image_handle_t image = nullptr;
ze_image_properties_t image_properties;
ze_image_properties_t image_properties = {};

void *device_memory, *host_memory, *shared_memory, *memory = nullptr;

ze_memory_allocation_properties_t mem_alloc_properties;
ze_memory_allocation_properties_t mem_alloc_properties = {};

std::vector<uint8_t> binary_file =
level_zero_tests::load_binary_file("module_add.spv");
Expand All @@ -295,7 +295,7 @@ class LCTracingPrologueEpilogueTests : public ::testing::Test {
ze_sampler_handle_t sampler = nullptr;

uint32_t num = 0, version;
ze_driver_properties_t driver_properties;
ze_driver_properties_t driver_properties = {};
ze_bool_t can_access;
};

Expand Down Expand Up @@ -2012,6 +2012,7 @@ TEST_F(
init_kernel();

ze_kernel_properties_t kernel_properties = {};
kernel_properties.stype = ZE_STRUCTURE_TYPE_KERNEL_PROPERTIES;
ze_result_t initial_result =
zeKernelGetProperties(kernel, &kernel_properties);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ TEST(
CommandListCreateImmediateNegativeTests,
GivenInvalidDeviceHandleWhileCreatingCommandListImmediateThenInvalidNullHandleIsReturned) {
ze_command_queue_desc_t descriptor = {};
descriptor.stype = ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC;
descriptor.flags = 0;

descriptor.pNext = nullptr;
descriptor.ordinal = 0;
descriptor.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS;
Expand Down
1 change: 1 addition & 0 deletions perf_tests/ze_cabe/src/level-zero/ze_blackscholes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ template <class T> void ZeBlackScholes<T>::build_program() {

template <class T> void ZeBlackScholes<T>::create_buffers() {
ze_device_mem_alloc_desc_t device_desc = {};
device_desc.stype = ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC;
device_desc.ordinal = 0;
device_desc.flags = 0;
ZE_CHECK_RESULT(zeMemAllocDevice(context, &device_desc, buffer_size, 1,
Expand Down
3 changes: 2 additions & 1 deletion perf_tests/ze_cabe/src/level-zero/ze_mandelbrot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void ZeMandelbrot::build_program() {

void ZeMandelbrot::create_buffers() {
ze_device_mem_alloc_desc_t device_desc = {};
device_desc.stype = ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC;
device_desc.ordinal = 0;
device_desc.flags = 0;
ZE_CHECK_RESULT(zeMemAllocDevice(context, &device_desc,
Expand All @@ -66,7 +67,7 @@ void ZeMandelbrot::create_cmdlist() {
ZE_CHECK_RESULT(zeKernelSetArgumentValue(function, 2, sizeof(int), &width));

ze_command_list_desc_t command_list_description = {};

command_list_description.stype = ZE_STRUCTURE_TYPE_COMMAND_LIST_DESC;
command_list_description.pNext = nullptr;
ZE_CHECK_RESULT(zeCommandListCreate(
context, device, &command_list_description, &command_list));
Expand Down
1 change: 1 addition & 0 deletions perf_tests/ze_cabe/src/level-zero/ze_sobel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void ZeSobel::build_program() {

void ZeSobel::create_buffers() {
ze_device_mem_alloc_desc_t device_desc = {};
device_desc.stype = ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC;
device_desc.ordinal = 0;
device_desc.flags = 0;
ZE_CHECK_RESULT(zeMemAllocDevice(context, &device_desc, image_buffer_size, 1,
Expand Down
4 changes: 2 additions & 2 deletions perf_tests/ze_pingpong/include/ze_pingpong.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ struct L0Context {
uint32_t device_count = 0;
const uint32_t default_device = 0;
const uint32_t command_queue_id = 0;
ze_device_properties_t device_property;
ze_device_compute_properties_t device_compute_property;
ze_device_properties_t device_property = {};
ze_device_compute_properties_t device_compute_property = {};
void init();
void destroy();
void print_ze_device_properties(const ze_device_properties_t &props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ TEST_P(
auto context = lzt::create_context(driver);
auto device = lzt::get_default_device(driver);

ze_device_properties_t device_properties;
ze_device_properties_t device_properties = {};
device_properties.pNext = nullptr;
device_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
EXPECT_EQ(ZE_RESULT_SUCCESS,
Expand Down
3 changes: 0 additions & 3 deletions utils/test_harness/src/test_harness_cmdqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ ze_command_queue_handle_t create_command_queue(
descriptor.flags = flags;
descriptor.mode = mode;
descriptor.priority = priority;
ze_device_properties_t properties;
EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGetProperties(device, &properties));

descriptor.ordinal = ordinal;
descriptor.index = index;
ze_command_queue_handle_t command_queue = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion utils/test_harness/src/test_harness_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ ze_device_properties_t get_device_properties(ze_device_handle_t device) {
ze_device_properties_t get_device_properties(ze_device_handle_t device,
ze_structure_type_t stype) {
auto device_initial = device;
ze_device_properties_t properties;
ze_device_properties_t properties = {};
if (stype == ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES_1_2) {
properties.stype = stype;
} else {
Expand Down
4 changes: 2 additions & 2 deletions utils/utils/src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ std::string to_string(const ze_native_kernel_uuid_t uuid) {
}

void print_driver_version(ze_driver_handle_t driver) {
ze_driver_properties_t properties;
ze_driver_properties_t properties = {};

properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES;
properties.pNext = nullptr;
Expand All @@ -735,7 +735,7 @@ void print_driver_version(ze_driver_handle_t driver) {
void print_driver_overview(const ze_driver_handle_t driver) {
ze_result_t result = ZE_RESULT_SUCCESS;

ze_device_properties_t device_properties;
ze_device_properties_t device_properties = {};
device_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
device_properties.pNext = nullptr;
auto devices = get_devices(driver);
Expand Down

0 comments on commit 6f041ca

Please sign in to comment.