Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up of test_sycl_queue_submit_local_accessor_arg.cpp #1990

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@

#include <filesystem>
#include <fstream>
#include <utility>

#include <gtest/gtest.h>
#include <sycl/sycl.hpp>
#include <utility>

namespace
{
constexpr std::size_t SIZE = 100;
constexpr std::size_t SIZE = 320;

static_assert(SIZE % 10 == 0);

using namespace dpctl::syclinterface;

Expand All @@ -69,11 +72,13 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
a_ptr[i] = 0;
}

auto la1 = MDLocalAccessor{1, kernelArgTy, SIZE / 10, 1, 1};
std::size_t lws = SIZE / 10;

auto la1 = MDLocalAccessor{1, kernelArgTy, lws, 1, 1};

// Create kernel args for vector_add
std::size_t gRange[] = {SIZE};
std::size_t lRange[] = {SIZE / 10};
std::size_t lRange[] = {lws};
void *args_1d[NARGS] = {unwrap<void>(a), (void *)&la1};
DPCTLKernelArgType addKernelArgTypes[] = {DPCTL_VOID_PTR,
DPCTL_LOCAL_ACCESSOR};
Expand All @@ -84,7 +89,7 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
ASSERT_TRUE(E1Ref != nullptr);

DPCTLSyclEventRef DepEv1[] = {E1Ref};
auto la2 = MDLocalAccessor{2, kernelArgTy, SIZE / 10, 1, 1};
auto la2 = MDLocalAccessor{2, kernelArgTy, lws, 1, 1};
void *args_2d[NARGS] = {unwrap<void>(a), (void *)&la2};

DPCTLSyclEventRef E2Ref =
Expand All @@ -93,7 +98,7 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
ASSERT_TRUE(E2Ref != nullptr);

DPCTLSyclEventRef DepEv2[] = {E1Ref, E2Ref};
auto la3 = MDLocalAccessor{3, kernelArgTy, SIZE / 10, 1, 1};
auto la3 = MDLocalAccessor{3, kernelArgTy, lws, 1, 1};
void *args_3d[NARGS] = {unwrap<void>(a), (void *)&la3};

DPCTLSyclEventRef E3Ref =
Expand All @@ -103,10 +108,7 @@ void submit_kernel(DPCTLSyclQueueRef QRef,

DPCTLEvent_Wait(E3Ref);

if (kernelArgTy != DPCTL_FLOAT32_T && kernelArgTy != DPCTL_FLOAT64_T)
ASSERT_TRUE(a_ptr[0] == 20);
else
ASSERT_TRUE(a_ptr[0] == 20.0);
ASSERT_TRUE(a_ptr[0] == T(lws * 2));

// clean ups
DPCTLEvent_Delete(E1Ref);
Expand All @@ -133,9 +135,9 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
// figure which SPV file contains the kernels, use `spirv-dis` from the
// spirv-tools package to translate the SPV binary format to a human-readable
// textual format.
#include <CL/sycl.hpp>
#include <iostream>
#include <sstream>
#include <sycl/sycl.hpp>

template <typename T>
class SyclKernel_SLM
Expand Down Expand Up @@ -195,7 +197,7 @@ int main(int argc, const char **argv)
driver<int8_t>(N);
driver<uint8_t>(N);
driver<int16_t>(N);
driver<int32_t>(N);
driver<uint16_t>(N);
driver<int32_t>(N);
driver<uint32_t>(N);
driver<int64_t>(N);
Expand All @@ -220,11 +222,10 @@ struct TestQueueSubmitWithLocalAccessor : public ::testing::Test
{
DPCTLSyclDeviceSelectorRef DSRef = nullptr;
DPCTLSyclDeviceRef DRef = nullptr;
const char *test_spv_fn = "./local_accessor_kernel_inttys_fp32.spv";

spirvFile.open("./local_accessor_kernel_inttys_fp32.spv",
std::ios::binary | std::ios::ate);
spirvFileSize_ = std::filesystem::file_size(
"./local_accessor_kernel_inttys_fp32.spv");
spirvFile.open(test_spv_fn, std::ios::binary | std::ios::ate);
spirvFileSize_ = std::filesystem::file_size(test_spv_fn);
spirvBuffer_.reserve(spirvFileSize_);
spirvFile.seekg(0, std::ios::beg);
spirvFile.read(spirvBuffer_.data(), spirvFileSize_);
Expand Down Expand Up @@ -261,11 +262,10 @@ struct TestQueueSubmitWithLocalAccessorFP64 : public ::testing::Test
TestQueueSubmitWithLocalAccessorFP64()
{
DPCTLSyclDeviceSelectorRef DSRef = nullptr;
const char *test_spv_fn = "./local_accessor_kernel_fp64.spv";

spirvFile.open("./local_accessor_kernel_fp64.spv",
std::ios::binary | std::ios::ate);
spirvFileSize_ =
std::filesystem::file_size("./local_accessor_kernel_fp64.spv");
spirvFile.open(test_spv_fn, std::ios::binary | std::ios::ate);
spirvFileSize_ = std::filesystem::file_size(test_spv_fn);
spirvBuffer_.reserve(spirvFileSize_);
spirvFile.seekg(0, std::ios::beg);
spirvFile.read(spirvBuffer_.data(), spirvFileSize_);
Expand Down
Loading