Skip to content

Commit

Permalink
Test simd_length attribute and kernel property for dpcpp.
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-rowe committed Dec 8, 2023
1 parent fd31d43 commit 3c1a0e4
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/src/internal/lang/modes/dpcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ void testSharedAnnotation();
void testBarriers();
void testAtomic();
void testSource();
void testSimdLength();

int main(const int argc, const char **argv) {
parser.settings["okl/validate"] = true;
Expand All @@ -38,6 +39,7 @@ int main(const int argc, const char **argv) {
testSharedAnnotation();
testBarriers();
testSource();
testSimdLength();

return 0;
}
Expand Down Expand Up @@ -163,3 +165,57 @@ void testSource() {
"}\n"
);
}

void testSimdLengthAttribute() {
const std::string kernel_source = R"(
@kernel void f() {
@outer @simd_length(16)
for (int o = 0; o < 1; ++o) {
@inner for (int i = 0; i < 32; ++i) {
int j = i + o;
}
}
}
)";

parser.parseSource(kernel_source);
ASSERT_TRUE(parser.success);

printer pout;
parser.root.print(pout);
const std::string translated_source = pout.str();

auto pos = translated_source.find("[[intel::reqd_sub_group_size(16)]]");
ASSERT_TRUE(std::string::npos != pos);
}

void testSimdLengthProperty() {
const std::string kernel_source = R"(
@kernel void f() {
@outer for (int o = 0; o < 1; ++o) {
@inner for (int i = 0; i < 32; ++i) {
int j = i + o;
}
}
}
)";

occa::json properties;
properties["simd_length"] = 16;
occa::lang::okl::dpcppParser dpcpp_parser(properties);

dpcpp_parser.parseSource(kernel_source);
ASSERT_TRUE(parser.success);

printer pout;
dpcpp_parser.root.print(pout);
const std::string translated_source = pout.str();

auto pos = translated_source.find("[[intel::reqd_sub_group_size(16)]]");
ASSERT_TRUE(std::string::npos != pos);
}

void testSimdLength() {
testSimdLengthAttribute();
testSimdLengthProperty();
}

0 comments on commit 3c1a0e4

Please sign in to comment.