Skip to content

Add default input values for stream-triad-modified-*.cpp and spec-con…st3.cpp so they don't need to take user interaction for inputs by default if no arguments are specified and added default input values for stream-triad-modified-*.cpp and spec-const3.cpp so they don't need to take user interaction for inputs by default if no arguments are specified #2138

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 2 commits into from
Jan 22, 2024
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
33 changes: 27 additions & 6 deletions Publications/GPU-Opt-Guide/exec-model/vaddsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,36 +114,57 @@ int main() {

std::cout << "Running on device: "
<< q.get_device().get_info<sycl::info::device::name>() << "\n";

auto sgsizes = q.get_device().get_info<sycl::info::device::sub_group_sizes>();

constexpr int sgsize = 16;
bool supported = false;
std::cout << "Sub-group sizes supported:";
for (auto sz : sgsizes) {
std::cout << " " << sz;
if (sz == sgsize) {
supported = true;
}
}
std::cout << std::endl;

if (!supported) {
std::cout << "Sub-group size " << sgsize << " is not supported. Please change sgsize to one of the supported sizes"
<< std::endl;
return 0;
}

std::cout << "Using sub-group size " << sgsize << std::endl;
std::cout << "Vector size: " << a.size() << "\n";

// check results
Initialize(sum);
VectorAdd3<6, 320, 8>(q, a, b, sum, 1);
VectorAdd3<6, 320, sgsize>(q, a, b, sum, 1);

for (int i = 0; i < mysize; i++)
if (sum[i] != 2 * i) {
std::cout << "add3 Did not match\n";
}

Initialize(sum);
VectorAdd4<6, 320, 8>(q, a, b, sum, 1);
VectorAdd4<6, 320, sgsize>(q, a, b, sum, 1);
for (int i = 0; i < mysize; i++)
if (sum[i] != 2 * i) {
std::cout << "add4 Did not match\n";
}

// group1
Initialize(sum);
VectorAdd3<8, 320, 8>(q, a, b, sum, 10000);
VectorAdd3<8, 320, sgsize>(q, a, b, sum, 10000);
Initialize(sum);
VectorAdd4<8, 320, 8>(q, a, b, sum, 10000);
VectorAdd4<8, 320, sgsize>(q, a, b, sum, 10000);
// end group1

// group2
Initialize(sum);
VectorAdd3<24, 224, 8>(q, a, b, sum, 10000);
VectorAdd3<24, 224, sgsize>(q, a, b, sum, 10000);
Initialize(sum);
VectorAdd4<24, 224, 8>(q, a, b, sum, 10000);
VectorAdd4<24, 224, sgsize>(q, a, b, sum, 10000);
// end group2
return 0;
}
11 changes: 8 additions & 3 deletions Publications/GPU-Opt-Guide/jitting/spec-const3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SpecializedKernel;
// Identify the specialization constant.
constexpr sycl::specialization_id<int> nx_sc;

int main() {
int main(int argc, char *argv[]) {
sycl::queue queue;

std::cout << "Running on "
Expand All @@ -23,8 +23,13 @@ int main() {

// Application execution stops here asking for input from user
int Nx;
std::cout << "Enter input number ..." << std::endl;
std::cin >> Nx;
if (argc > 1) {
Nx = std::stoi(argv[1]);
} else {
Nx = 1024;
}

std::cout << "Nx = " << Nx << std::endl;

queue.submit([&](sycl::handler &h) {
sycl::accessor acc(buf, h, sycl::write_only, sycl::no_init);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ int main(int argc, char *argv[]) {
array_size = std::stoi(argv[1]);
inner_loop_size = std::stoi(argv[2]);
} else {
std::cout
<< "Run as ./<progname> <arraysize in elements> <inner loop size>\n";
return 1;
array_size = 134217728;
inner_loop_size = 10;
}
std::cout << "Running with stream size of " << array_size << " elements ("
<< (array_size * sizeof(double)) / (double)1024 / 1024 << "MB)\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ int main(int argc, char *argv[]) {
array_size = std::stoi(argv[1]);
inner_loop_size = std::stoi(argv[2]);
} else {
std::cout
<< "Run as ./<progname> <arraysize in elements> <inner loop size>\n";
return 1;
array_size = 134217728;
inner_loop_size = 10;
}
std::cout << "Running with stream size of " << array_size << " elements ("
<< (array_size * sizeof(double)) / (double)1024 / 1024 << "MB)\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,8 @@ int main(int argc, char *argv[]) {
array_size = std::stoi(argv[1]);
inner_loop_size = std::stoi(argv[2]);
} else {
std::cout
<< "Run as ./<progname> <arraysize in elements> <inner loop size>\n";
return 1;
array_size = 134217728;
inner_loop_size = 10;
}
std::cout << "Running with stream size of " << array_size << " elements ("
<< (array_size * sizeof(double)) / (double)1024 / 1024 << "MB)\n";
Expand Down