Skip to content

Commit

Permalink
Add consistent error code for parsing failures
Browse files Browse the repository at this point in the history
  • Loading branch information
jblok27 authored and Beanavil committed May 6, 2024
1 parent 3dbb2f9 commit b47af8c
Show file tree
Hide file tree
Showing 20 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion Applications/bitonic_sort/main.hip
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ int main(int argc, char* argv[])
{
std::cout << "The ordering must be 'dec' or 'inc', the default ordering is 'inc'."
<< std::endl;
return 0;
return error_exit_code;
}
const bool sort_increasing = (sort.compare("inc") == 0);

Expand Down
2 changes: 1 addition & 1 deletion Applications/monte_carlo_pi/main.hip
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ int main(int argc, char* argv[])
if(sample_count <= 0)
{
std::cerr << "Sample count should be greater than 0." << std::endl;
return 0;
return error_exit_code;
}

// The samples have two dimensions, so two random numbers are required per sample.
Expand Down
2 changes: 1 addition & 1 deletion Applications/prefix_sum/main.hip
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ int main(int argc, char* argv[])
if(size <= 0)
{
std::cout << "Size must be at least 1." << std::endl;
exit(0);
return error_exit_code;
}

// 2. Generate input vector.
Expand Down
8 changes: 4 additions & 4 deletions Libraries/hipBLAS/gemm_strided_batched/main.hip
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,25 @@ int main(const int argc, const char** argv)
if(m <= 0)
{
std::cout << "Value of 'm' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

if(n <= 0)
{
std::cout << "Value of 'n' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

if(k <= 0)
{
std::cout << "Value of 'k' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

if(batch_count <= 0)
{
std::cout << "Value of 'c' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Set scalar values used for multiplication.
Expand Down
10 changes: 5 additions & 5 deletions Libraries/hipBLAS/her/main.hip
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -77,23 +77,23 @@ int main(const int argc, const char** argv)
if(incx <= 0)
{
std::cout << "Value of 'x' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Increment between consecutive values of the input vector y.
const int incy = parser.get<int>("y");
if(incx <= 0)
if(incy <= 0)
{
std::cout << "Value of 'y' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Number of elements in the input vectors and dimension of input matrix.
const int n = parser.get<int>("n");
if(n <= 0)
{
std::cout << "Value of 'n' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Scalar multiplier.
Expand Down
6 changes: 3 additions & 3 deletions Libraries/hipBLAS/scal/main.hip
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -49,15 +49,15 @@ int main(const int argc, const char** argv)
if(incx <= 0)
{
std::cout << "Value of 'x' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Number of elements in input vector.
const int n = parser.get<int>("n");
if(n <= 0)
{
std::cout << "Value of 'n' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Scalar value used for multiplication.
Expand Down
4 changes: 2 additions & 2 deletions Libraries/hipSOLVER/gels/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ int main(const int argc, char* argv[])
if(m <= 0)
{
std::cout << "Value of 'm' should be greater than 0." << std::endl;
return 0;
return error_exit_code;
}

const int n = parser.get<int>("n");
if(n <= 0)
{
std::cout << "Value of 'n' should be greater than 0." << std::endl;
return 0;
return error_exit_code;
}

// Initialize leading dimensions of the input- and output matrices,
Expand Down
4 changes: 2 additions & 2 deletions Libraries/hipSOLVER/gesvd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ int main(const int argc, char* argv[])
if(m <= 0)
{
std::cout << "Value of 'm' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

const int n = parser.get<int>("n");
if(n <= 0)
{
std::cout << "Value of 'n' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Initialize leading dimensions of input matrix A and output singular vector matrices.
Expand Down
4 changes: 2 additions & 2 deletions Libraries/hipSOLVER/getrf/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ int main(const int argc, const char* argv[])
if(m <= 0)
{
std::cout << "Value of 'm' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

const int n = parser.get<int>("n");
if(n <= 0)
{
std::cout << "Value of 'n' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Initialize leading dimensions of input matrix A and output matrix LU.
Expand Down
2 changes: 1 addition & 1 deletion Libraries/hipSOLVER/syevj/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int main(const int argc, char* argv[])
if(n <= 0)
{
std::cout << "Value of 'n' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}
const int lda = n;

Expand Down
4 changes: 2 additions & 2 deletions Libraries/hipSOLVER/syevj_batched/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int main(const int argc, char* argv[])
if(n <= 0)
{
std::cout << "Value of 'n' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}
const int lda = n;
const int size_matrix = n * lda;
Expand All @@ -58,7 +58,7 @@ int main(const int argc, char* argv[])
if(batch_count <= 0)
{
std::cout << "Batch size should be at least 1" << std::endl;
return 0;
return error_exit_code;
}

// 2. Allocate and initialize the host side inputs.
Expand Down
8 changes: 4 additions & 4 deletions Libraries/rocBLAS/level_1/axpy/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -49,23 +49,23 @@ int main(const int argc, const char** argv)
if(incx <= 0)
{
std::cout << "Value of 'x' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Stride between consecutive values of input vector y.
const rocblas_int incy = parser.get<int>("y");
if(incy <= 0)
{
std::cout << "Value of 'y' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Number of elements in input vector x and input vector y.
const rocblas_int n = parser.get<int>("n");
if(n <= 0)
{
std::cout << "Value of 'n' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Scalar value used for multiplication.
Expand Down
8 changes: 4 additions & 4 deletions Libraries/rocBLAS/level_1/dot/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -56,19 +56,19 @@ int main(const int argc, const char** argv)
if(incx <= 0)
{
std::cout << "Value of 'x' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

if(incy <= 0)
{
std::cout << "Value of 'y' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

if(n <= 0)
{
std::cout << "Value of 'n' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Adjust the size of input vector x for values of stride (incx) not equal to 1.
Expand Down
6 changes: 3 additions & 3 deletions Libraries/rocBLAS/level_1/nrm2/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -67,13 +67,13 @@ int main(const int argc, const char** argv)
if(incx <= 0)
{
std::cout << "Value of 'x' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

if(n <= 0)
{
std::cout << "Value of 'n' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Adjust the size of input vector for values of stride (incx) not equal to 1.
Expand Down
6 changes: 3 additions & 3 deletions Libraries/rocBLAS/level_1/scal/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -49,15 +49,15 @@ int main(const int argc, const char** argv)
if(incx <= 0)
{
std::cout << "Value of 'x' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Number of elements in input vector.
const rocblas_int n = parser.get<int>("n");
if(n <= 0)
{
std::cout << "Value of 'n' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Scalar value used for multiplication.
Expand Down
6 changes: 3 additions & 3 deletions Libraries/rocBLAS/level_2/gemv/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -108,15 +108,15 @@ int main(const int argc, const char** argv)
if(cols <= 0)
{
std::cout << "Value of 'n' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Number of rows in the matrix.
const rocblas_int rows = parser.get<int>("m");
if(rows <= 0)
{
std::cout << "Value of 'm' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Alpha scalar multiplier.
Expand Down
4 changes: 2 additions & 2 deletions Libraries/rocBLAS/level_2/her/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -79,7 +79,7 @@ int main(const int argc, const char** argv)
if(n <= 0)
{
std::cout << "Value of 'n' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Scalar multiplier.
Expand Down
6 changes: 3 additions & 3 deletions Libraries/rocBLAS/level_3/gemm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ int main(const int argc, const char** argv)
if(m <= 0)
{
std::cout << "Value of 'm' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

if(n <= 0)
{
std::cout << "Value of 'n' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

if(k <= 0)
{
std::cout << "Value of 'k' should be greater than 0" << std::endl;
return 0;
return error_exit_code;
}

// Set scalar values used for multiplication.
Expand Down
Loading

0 comments on commit b47af8c

Please sign in to comment.