Skip to content

Commit

Permalink
Add proper error checking to example
Browse files Browse the repository at this point in the history
  • Loading branch information
joeatodd committed Jan 14, 2025
1 parent 2494cb1 commit 47e05b1
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions examples/sycl/pvc/pvc_gemm_with_per_row_bias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "cutlass/coord.h"

#include "common.hpp"
#include "helper.h"

using namespace cute;

Expand Down Expand Up @@ -228,7 +229,7 @@ struct ExampleRunner {
initialize_block(block_bias, seed + 2020);
}

void run(const Options& options, const cutlass::KernelHardwareInfo& hw_info) {
cutlass::Status run(const Options& options, const cutlass::KernelHardwareInfo& hw_info) {
ProblemShapeType problem_size = ProblemShapeType{options.m, options.n, options.k, options.l};

initialize(problem_size);
Expand All @@ -255,23 +256,22 @@ struct ExampleRunner {
size_t workspace_size = Gemm::get_workspace_size(arguments);
cutlass::device_memory::allocation<uint8_t> workspace(workspace_size);

if (gemm_op.can_implement(arguments) != cutlass::Status::kSuccess){
std::cout << "Invalid Problem Size: " << options.m << 'x' << options.n << 'x' << options.k << 'x' << options.l << std::endl;
std::exit(1);
}
CUTLASS_CHECK(gemm_op.can_implement(arguments))

gemm_op.initialize(arguments, workspace.get());
CUTLASS_CHECK(gemm_op.initialize(arguments, workspace.get()));

// Run the GEMM
gemm_op.run();
CUTLASS_CHECK(gemm_op.run());

syclcompat::wait();

// Verify that the result is correct
bool passed = verify(problem_size, options.alpha, options.beta);
std::cout << "Disposition: " << (passed ? "Passed" : "Failed") << std::endl;

if (passed && options.iterations > 0) {
if(!passed) return cutlass::Status::kErrorInternal;

if (options.iterations > 0) {
GPU_Clock timer;
timer.start();
for (int i = 0; i < options.iterations; ++i) {
Expand All @@ -284,6 +284,7 @@ struct ExampleRunner {
std::cout << "Problem Size: " << options.m << 'x' << options.n << 'x' << options.k << 'x' << options.l << std::endl;
printf("Cutlass GEMM Performance: [%4.3f]TFlop/s (%6.4f)ms\n", tflops / cute_time, cute_time*1000);
}
return cutlass::Status::kSuccess;
}
};

Expand Down Expand Up @@ -386,7 +387,7 @@ int main(int argc, const char** argv)

ExampleRunner<Gemm> runner;

runner.run(options, hw_info);
CUTLASS_CHECK(runner.run(options, hw_info));

return 0;
}

0 comments on commit 47e05b1

Please sign in to comment.