Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

[ESIMD] Fix stencil tests timeouts #244

Merged
merged 2 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
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
23 changes: 11 additions & 12 deletions SYCL/ESIMD/Stencil.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//==---------------- stencil.cpp - DPC++ ESIMD on-device test ------------==//
//==---------------- Stencil.cpp - DPC++ ESIMD on-device test ------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand All @@ -17,13 +17,6 @@
#include <CL/sycl/INTEL/esimd.hpp>
#include <iostream>

//
// test smaller input size
// test 8x16 block size
//
#define DIM_SIZE (1 << 13)
#define SQUARE_SZ (DIM_SIZE * DIM_SIZE + 16)

#define WIDTH 16
#define HEIGHT 16

Expand All @@ -41,8 +34,7 @@ void InitializeSquareMatrix(float *matrix, size_t const Dim,
}
}

bool CheckResults(float *out, float *in) {
unsigned int n = DIM_SIZE;
bool CheckResults(float *out, float *in, unsigned n) {
for (unsigned int i = 0; i < n; i++) {
for (unsigned int j = 0; j < n; j++) {
if ((5 <= i) && (i < n - 5) && (5 <= j) && (j < n - 5)) {
Expand Down Expand Up @@ -79,7 +71,14 @@ bool CheckResults(float *out, float *in) {
return true;
}

int main(void) {
int main(int argc, char *argv[]) {
if (argc > 2) {
std::cerr << "Usage: stencil.exe [dim_size]" << std::endl;
exit(1);
}
// Default dimension size is 1024
const unsigned DIM_SIZE = (argc == 2) ? atoi(argv[1]) : 1 << 10;
const unsigned SQUARE_SZ = DIM_SIZE * DIM_SIZE + 16;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like code duplication. Can we move common part to header?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do that as a separate patch.

uint range_width =
(DIM_SIZE - 10) / WIDTH + (((DIM_SIZE - 10) % WIDTH == 0) ? 0 : 1);
uint range_height =
Expand Down Expand Up @@ -182,7 +181,7 @@ int main(void) {
}

// check result
bool passed = CheckResults(outputMatrix, inputMatrix);
bool passed = CheckResults(outputMatrix, inputMatrix, DIM_SIZE);
if (passed) {
std::cout << "PASSED" << std::endl;
} else {
Expand Down
21 changes: 10 additions & 11 deletions SYCL/ESIMD/stencil2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
#include <CL/sycl/INTEL/esimd.hpp>
#include <iostream>

//
// test smaller input size
// test 8x16 block size
//
#define DIM_SIZE (1 << 13)
#define SQUARE_SZ (DIM_SIZE * DIM_SIZE + 16)

#define WIDTH 16
#define HEIGHT 16

Expand All @@ -43,8 +36,7 @@ void InitializeSquareMatrix(float *matrix, size_t const Dim,
}
}

bool CheckResults(float *out, float *in) {
unsigned int n = DIM_SIZE;
bool CheckResults(float *out, float *in, unsigned n) {
for (unsigned int i = 0; i < n; i++) {
for (unsigned int j = 0; j < n; j++) {
if ((5 <= i) && (i < n - 5) && (5 <= j) && (j < n - 5)) {
Expand Down Expand Up @@ -81,7 +73,14 @@ bool CheckResults(float *out, float *in) {
return true;
}

int main(void) {
int main(int argc, char *argv[]) {
if (argc > 2) {
std::cerr << "Usage: stencil.exe [dim_size]" << std::endl;
exit(1);
}
// Default dimension size is 1024
const unsigned DIM_SIZE = (argc == 2) ? atoi(argv[1]) : 1 << 10;
const unsigned SQUARE_SZ = DIM_SIZE * DIM_SIZE + 16;
uint range_width =
(DIM_SIZE - 10) / WIDTH + (((DIM_SIZE - 10) % WIDTH == 0) ? 0 : 1);
uint range_height =
Expand Down Expand Up @@ -184,7 +183,7 @@ int main(void) {
}

// check result
bool passed = CheckResults(outputMatrix, inputMatrix);
bool passed = CheckResults(outputMatrix, inputMatrix, DIM_SIZE);
if (passed) {
std::cout << "PASSED" << std::endl;
} else {
Expand Down