Skip to content

Add negative tests for inline asm #2406

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
33 changes: 33 additions & 0 deletions sycl/test/inline-asm/negative_tests/asm_bad_opcode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// UNSUPPORTED: cuda
// REQUIRES: gpu,linux
// RUN: %clangxx -fsycl %s -DINLINE_ASM -o %t.out
Copy link
Contributor

@smaslov-intel smaslov-intel Sep 2, 2020

Choose a reason for hiding this comment

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

Why do you need this INLINE_ASM macro since you seem to always define it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It remained from positive tests, I will delete it.

// RUN: not %t.out 2>&1 | FileCheck %s

// CHECK: syntax error

#include "../include/asmhelper.h"
#include <CL/sycl.hpp>

using dataType = cl::sycl::cl_int;

template <typename T = dataType>
struct KernelFunctor : WithOutputBuffer<T> {
KernelFunctor(size_t problem_size) : WithOutputBuffer<T>(problem_size) {}

void operator()(cl::sycl::handler &cgh) {
cgh.parallel_for<KernelFunctor<T>>(
cl::sycl::range<1>{this->getOutputBufferSize()}, [=](cl::sycl::id<1> wiID) [[cl::intel_reqd_sub_group_size(8)]] {
#if defined(INLINE_ASM) && defined(__SYCL_DEVICE_ONLY__)
asm volatile(".decl tmp1 v_type=G type=d num_elts=16 align=GRF\n"
".decl tmp2 v_type=G type=d num_elts=16 align=GRF\n"
"movi (M1_NM, 8) tmp1(0,1)<1> tmp2(0,0)\n");
#endif
});
}
};

int main() {
KernelFunctor<> f(DEFAULT_PROBLEM_SIZE);
launchInlineASMTest(f);
return 0;
}
33 changes: 33 additions & 0 deletions sycl/test/inline-asm/negative_tests/asm_bad_operand_syntax.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// UNSUPPORTED: cuda
// REQUIRES: gpu,linux
// RUN: %clangxx -fsycl %s -DINLINE_ASM -o %t.out
// RUN: not %t.out 2>&1 | FileCheck %s

// CHECK: syntax error

#include "../include/asmhelper.h"
#include <CL/sycl.hpp>

using dataType = cl::sycl::cl_int;

template <typename T = dataType>
struct KernelFunctor : WithOutputBuffer<T> {
KernelFunctor(size_t problem_size) : WithOutputBuffer<T>(problem_size) {}

void operator()(cl::sycl::handler &cgh) {
cgh.parallel_for<KernelFunctor<T>>(
cl::sycl::range<1>{this->getOutputBufferSize()}, [=](cl::sycl::id<1> wiID) [[cl::intel_reqd_sub_group_size(8)]] {
#if defined(INLINE_ASM) && defined(__SYCL_DEVICE_ONLY__)
asm volatile(".decl tmp1 v_type=G type=d num_elts=16 align=GRF\n"
".decl tmp2 v_type=G type=d num_elts=16 align=GRF\n"
"mov (M1_NM, 8) tmp1(0,1)<1>:f tmp2(0,0)<1;1,0>\n");
#endif
});
}
};

int main() {
KernelFunctor<> f(DEFAULT_PROBLEM_SIZE);
launchInlineASMTest(f);
return 0;
}
33 changes: 33 additions & 0 deletions sycl/test/inline-asm/negative_tests/asm_duplicate_label.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// UNSUPPORTED: cuda
// REQUIRES: gpu,linux
// RUN: %clangxx -fsycl %s -DINLINE_ASM -o %t.out
// RUN: not %t.out 2>&1 | FileCheck %s

// CHECK: label is redefined

#include "../include/asmhelper.h"
#include <CL/sycl.hpp>

using dataType = cl::sycl::cl_int;

template <typename T = dataType>
struct KernelFunctor : WithOutputBuffer<T> {
KernelFunctor(size_t problem_size) : WithOutputBuffer<T>(problem_size) {}

void operator()(cl::sycl::handler &cgh) {
cgh.parallel_for<KernelFunctor<T>>(
cl::sycl::range<1>{this->getOutputBufferSize()}, [=](cl::sycl::id<1> wiID) [[cl::intel_reqd_sub_group_size(8)]] {
#if defined(INLINE_ASM) && defined(__SYCL_DEVICE_ONLY__)
asm volatile(".decl tmp1 v_type=G type=d num_elts=16 align=GRF\n"
".decl tmp2 v_type=G type=d num_elts=16 align=GRF\n"
"check_label0:\\ncheck_label0:\n");
#endif
});
}
};

int main() {
KernelFunctor<> f(DEFAULT_PROBLEM_SIZE);
launchInlineASMTest(f);
return 0;
}
33 changes: 33 additions & 0 deletions sycl/test/inline-asm/negative_tests/asm_illegal_exec_size.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// UNSUPPORTED: cuda
// REQUIRES: gpu,linux
// RUN: %clangxx -fsycl %s -DINLINE_ASM -o %t.out
// RUN: not %t.out 2>&1 | FileCheck %s

// CHECK: invalid execution size

#include "../include/asmhelper.h"
#include <CL/sycl.hpp>

using dataType = cl::sycl::cl_int;

template <typename T = dataType>
struct KernelFunctor : WithOutputBuffer<T> {
KernelFunctor(size_t problem_size) : WithOutputBuffer<T>(problem_size) {}

void operator()(cl::sycl::handler &cgh) {
cgh.parallel_for<KernelFunctor<T>>(
cl::sycl::range<1>{this->getOutputBufferSize()}, [=](cl::sycl::id<1> wiID) [[cl::intel_reqd_sub_group_size(8)]] {
#if defined(INLINE_ASM) && defined(__SYCL_DEVICE_ONLY__)
asm volatile(".decl tmp1 v_type=G type=d num_elts=16 align=GRF\n"
".decl tmp2 v_type=G type=d num_elts=16 align=GRF\n"
"mov (M1_NM, 6) tmp1(0,1)<1> tmp2(0,0)<1;1,0>\n");
#endif
});
}
};

int main() {
KernelFunctor<> f(DEFAULT_PROBLEM_SIZE);
launchInlineASMTest(f);
return 0;
}
33 changes: 33 additions & 0 deletions sycl/test/inline-asm/negative_tests/asm_missing_label.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// UNSUPPORTED: cuda
// REQUIRES: gpu,linux
// RUN: %clangxx -fsycl %s -DINLINE_ASM -o %t.out
// RUN: not %t.out 2>&1 | FileCheck %s

// CHECK: undefined label: check_label0

#include "../include/asmhelper.h"
#include <CL/sycl.hpp>

using dataType = cl::sycl::cl_int;

template <typename T = dataType>
struct KernelFunctor : WithOutputBuffer<T> {
KernelFunctor(size_t problem_size) : WithOutputBuffer<T>(problem_size) {}

void operator()(cl::sycl::handler &cgh) {
cgh.parallel_for<KernelFunctor<T>>(
cl::sycl::range<1>{this->getOutputBufferSize()}, [=](cl::sycl::id<1> wiID) [[cl::intel_reqd_sub_group_size(8)]] {
#if defined(INLINE_ASM) && defined(__SYCL_DEVICE_ONLY__)
asm volatile(".decl tmp1 v_type=G type=d num_elts=16 align=GRF\n"
".decl tmp2 v_type=G type=d num_elts=16 align=GRF\n"
"goto (M1, 16) check_label0\n");
#endif
});
}
};

int main() {
KernelFunctor<> f(DEFAULT_PROBLEM_SIZE);
launchInlineASMTest(f);
return 0;
}
33 changes: 33 additions & 0 deletions sycl/test/inline-asm/negative_tests/asm_missing_region.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// UNSUPPORTED: cuda
// REQUIRES: gpu,linux
// RUN: %clangxx -fsycl %s -DINLINE_ASM -o %t.out
// RUN: not %t.out 2>&1 | FileCheck %s

// CHECK: syntax error

#include "../include/asmhelper.h"
#include <CL/sycl.hpp>

using dataType = cl::sycl::cl_int;

template <typename T = dataType>
struct KernelFunctor : WithOutputBuffer<T> {
KernelFunctor(size_t problem_size) : WithOutputBuffer<T>(problem_size) {}

void operator()(cl::sycl::handler &cgh) {
cgh.parallel_for<KernelFunctor<T>>(
cl::sycl::range<1>{this->getOutputBufferSize()}, [=](cl::sycl::id<1> wiID) [[cl::intel_reqd_sub_group_size(8)]] {
#if defined(INLINE_ASM) && defined(__SYCL_DEVICE_ONLY__)
asm volatile(".decl tmp1 v_type=G type=d num_elts=16 align=GRF\n"
".decl tmp2 v_type=G type=d num_elts=16 align=GRF\n"
"mov (M1_NM, 8) tmp1(0,1)<1> tmp2(0,0)\n");
#endif
});
}
};

int main() {
KernelFunctor<> f(DEFAULT_PROBLEM_SIZE);
launchInlineASMTest(f);
return 0;
}
33 changes: 33 additions & 0 deletions sycl/test/inline-asm/negative_tests/asm_simple.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// UNSUPPORTED: cuda
// REQUIRES: gpu,linux
// RUN: %clangxx -fsycl %s -DINLINE_ASM -o %t.out
// RUN: not %t.out 2>&1 | FileCheck %s

// CHECK: syntax error

#include "../include/asmhelper.h"
#include <CL/sycl.hpp>

using dataType = cl::sycl::cl_int;

template <typename T = dataType>
struct KernelFunctor : WithOutputBuffer<T> {
KernelFunctor(size_t problem_size) : WithOutputBuffer<T>(problem_size) {}

void operator()(cl::sycl::handler &cgh) {
cgh.parallel_for<KernelFunctor<T>>(
cl::sycl::range<1>{this->getOutputBufferSize()}, [=](cl::sycl::id<1> wiID) [[cl::intel_reqd_sub_group_size(8)]] {
#if defined(INLINE_ASM) && defined(__SYCL_DEVICE_ONLY__)
asm volatile(".decl tmp1 v_type=G type=d num_elts=16 align=GRF\n"
".decl tmp2 v_type=G type=d num_elts=16 align=GRF\n"
"@@\n");
#endif
});
}
};

int main() {
KernelFunctor<> f(DEFAULT_PROBLEM_SIZE);
launchInlineASMTest(f);
return 0;
}
33 changes: 33 additions & 0 deletions sycl/test/inline-asm/negative_tests/asm_undefined_decl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// UNSUPPORTED: cuda
// REQUIRES: gpu,linux
// RUN: %clangxx -fsycl %s -DINLINE_ASM -o %t.out
// RUN: not %t.out 2>&1 | FileCheck %s

// CHECK: syntax error

#include "../include/asmhelper.h"
#include <CL/sycl.hpp>

using dataType = cl::sycl::cl_int;

template <typename T = dataType>
struct KernelFunctor : WithOutputBuffer<T> {
KernelFunctor(size_t problem_size) : WithOutputBuffer<T>(problem_size) {}

void operator()(cl::sycl::handler &cgh) {
cgh.parallel_for<KernelFunctor<T>>(
cl::sycl::range<1>{this->getOutputBufferSize()}, [=](cl::sycl::id<1> wiID) [[cl::intel_reqd_sub_group_size(8)]] {
#if defined(INLINE_ASM) && defined(__SYCL_DEVICE_ONLY__)
asm volatile(".decl tmp1 v_type=G type=d num_elts=16 align=GRF\n"
".decl tmp2 v_type=G type=d num_elts=16 align=GRF\n"
"mov (M1_NM, 8) tmp1(0,1)<1> my_super_var(0,0)\n");
#endif
});
}
};

int main() {
KernelFunctor<> f(DEFAULT_PROBLEM_SIZE);
launchInlineASMTest(f);
return 0;
}
33 changes: 33 additions & 0 deletions sycl/test/inline-asm/negative_tests/asm_undefined_pred.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// UNSUPPORTED: cuda
// REQUIRES: gpu,linux
// RUN: %clangxx -fsycl %s -DINLINE_ASM -o %t.out
// RUN: not %t.out 2>&1 | FileCheck %s

// CHECK: undefined predicate variable

#include "../include/asmhelper.h"
#include <CL/sycl.hpp>

using dataType = cl::sycl::cl_int;

template <typename T = dataType>
struct KernelFunctor : WithOutputBuffer<T> {
KernelFunctor(size_t problem_size) : WithOutputBuffer<T>(problem_size) {}

void operator()(cl::sycl::handler &cgh) {
cgh.parallel_for<KernelFunctor<T>>(
cl::sycl::range<1>{this->getOutputBufferSize()}, [=](cl::sycl::id<1> wiID) [[cl::intel_reqd_sub_group_size(8)]] {
#if defined(INLINE_ASM) && defined(__SYCL_DEVICE_ONLY__)
asm volatile(".decl tmp1 v_type=G type=d num_elts=16 align=GRF\n"
".decl tmp2 v_type=G type=d num_elts=16 align=GRF\n"
"cmp.lt (M1_NM, 8) P3 tmp1(0,0)<0;1,0> 0x3:ud\n");
#endif
});
}
};

int main() {
KernelFunctor<> f(DEFAULT_PROBLEM_SIZE);
launchInlineASMTest(f);
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// UNSUPPORTED: cuda
// REQUIRES: gpu,linux
// RUN: %clangxx -fsycl %s -DINLINE_ASM -o %t.out
// RUN: not %t.out 2>&1 | FileCheck %s

// CHECK: Build succeeded
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder why do we have tests that expected to be successfully built in negative_tests directory?

If these tests require particular HW to catch device program build error, than I suggest to remove them as they are too fragile, IMHO


#include "../include/asmhelper.h"
#include <CL/sycl.hpp>

using dataType = cl::sycl::cl_int;

template <typename T = dataType>
struct KernelFunctor : WithOutputBuffer<T> {
KernelFunctor(size_t problem_size) : WithOutputBuffer<T>(problem_size) {}

void operator()(cl::sycl::handler &cgh) {
cgh.parallel_for<KernelFunctor<T>>(
cl::sycl::range<1>{this->getOutputBufferSize()}, [=](cl::sycl::id<1> wiID) [[cl::intel_reqd_sub_group_size(8)]] {
#if defined(INLINE_ASM) && defined(__SYCL_DEVICE_ONLY__)
asm volatile(".decl tmp1 v_type=G type=d num_elts=16 align=GRF\n"
".decl tmp2 v_type=G type=d num_elts=16 align=GRF\n"
"divm (M1, 8) tmp1(0,0)<1> tmp2(0,0)<1;1,0> 0x2:f\n");
#endif
});
}
};

int main() {
KernelFunctor<> f(DEFAULT_PROBLEM_SIZE);
launchInlineASMTest(f);
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// UNSUPPORTED: cuda
// REQUIRES: gpu,linux
// RUN: %clangxx -fsycl %s -DINLINE_ASM -o %t.out
// RUN: not %t.out 2>&1 | FileCheck %s

// CHECK: Build succeeded

#include "../include/asmhelper.h"
#include <CL/sycl.hpp>

using dataType = cl::sycl::cl_int;

template <typename T = dataType>
struct KernelFunctor : WithOutputBuffer<T> {
KernelFunctor(size_t problem_size) : WithOutputBuffer<T>(problem_size) {}

void operator()(cl::sycl::handler &cgh) {
cgh.parallel_for<KernelFunctor<T>>(
cl::sycl::range<1>{this->getOutputBufferSize()}, [=](cl::sycl::id<1> wiID) [[cl::intel_reqd_sub_group_size(8)]] {
#if defined(INLINE_ASM) && defined(__SYCL_DEVICE_ONLY__)
asm volatile(".decl tmp1 v_type=G type=d num_elts=16 align=GRF\n"
".decl tmp2 v_type=G type=d num_elts=16 align=GRF\n"
"rol (M1, 8) tmp1(0,0)<1> tmp2(0,0)<1;1,0> 0x2:d\n");
#endif
});
}
};

int main() {
KernelFunctor<> f(DEFAULT_PROBLEM_SIZE);
launchInlineASMTest(f);
return 0;
}
Loading