Skip to content

Commit 260aad7

Browse files
committed
updated cmath function for 2025.0
1 parent c4f43a4 commit 260aad7

File tree

6 files changed

+26
-20
lines changed

6 files changed

+26
-20
lines changed

DirectProgramming/C++SYCL/Jupyter/sycl-performance-portability-training/lab/mm_dpcpp_basic_full.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111
#include <ctime>
1212
#include <chrono>
1313
#include <getopt.h>
14+
#include <cmath>
1415

1516
using namespace sycl;
1617

1718
//# floating point error verification function
1819
bool almost_equal(float a, float b){
1920
float tolerance = 1e-6;
20-
float diff = fabs(a - b);
21-
a = fabs(a);
22-
b = fabs(b);
21+
float diff = std::fabs(a - b);
22+
a = std::fabs(a);
23+
b = std::fabs(b);
2324
float bigger = (b > a) ? b : a;
2425
if(diff <= bigger * tolerance) return true;
2526
return false;

DirectProgramming/C++SYCL/Jupyter/sycl-performance-portability-training/lab/mm_dpcpp_common.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <getopt.h>
1212
#include <ctime>
1313
#include <chrono>
14+
#include <cmath>
1415

1516
using namespace sycl;
1617

@@ -20,9 +21,9 @@ void mm_kernel(queue &q, std::vector<float> &matrix_a, std::vector<float> &matri
2021
//# floating point error verification function
2122
bool almost_equal(float a, float b){
2223
float tolerance = 1e-6;
23-
float diff = fabs(a - b);
24-
a = fabs(a);
25-
b = fabs(b);
24+
float diff = std::fabs(a - b);
25+
a = std::fabs(a);
26+
b = std::fabs(b);
2627
float bigger = (b > a) ? b : a;
2728
if(diff <= bigger * tolerance) return true;
2829
return false;

DirectProgramming/C++SYCL/Jupyter/sycl-performance-portability-training/lab/mm_dpcpp_common_wg.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <getopt.h>
1212
#include <ctime>
1313
#include <chrono>
14+
#include <cmath>
1415

1516
using namespace sycl;
1617

@@ -20,9 +21,9 @@ void mm_kernel(queue &q, std::vector<float> &matrix_a, std::vector<float> &matri
2021
//# floating point error verification function
2122
bool almost_equal(float a, float b){
2223
float tolerance = 1e-6;
23-
float diff = fabs(a - b);
24-
a = fabs(a);
25-
b = fabs(b);
24+
float diff = std::fabs(a - b);
25+
a = std::fabs(a);
26+
b = std::fabs(b);
2627
float bigger = (b > a) ? b : a;
2728
if(diff <= bigger * tolerance) return true;
2829
return false;
@@ -89,7 +90,7 @@ int main(int argc, char *argv[]) {
8990
// find valid work-group sizes to try for performance.
9091
std::vector<int> work_group_sizes;
9192
auto max_work_group_size = q.get_device().get_info<info::device::max_work_group_size>();
92-
int work_group_dim_size = sqrt(max_work_group_size);
93+
int work_group_dim_size = std::sqrt(max_work_group_size);
9394
work_group_dim_size = work_group_dim_size - work_group_dim_size % 2;
9495
while (work_group_dim_size >= 2){
9596
if (N % work_group_dim_size == 0) work_group_sizes.push_back(work_group_dim_size);

DirectProgramming/C++SYCL/Jupyter/sycl-performance-portability-training/src/mm_dpcpp_basic_full.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111
#include <ctime>
1212
#include <chrono>
1313
#include <getopt.h>
14+
#include <cmath>
1415

1516
using namespace sycl;
1617

1718
//# floating point error verification function
1819
bool almost_equal(float a, float b){
1920
float tolerance = 1e-6;
20-
float diff = fabs(a - b);
21-
a = fabs(a);
22-
b = fabs(b);
21+
float diff = std::fabs(a - b);
22+
a = std::fabs(a);
23+
b = std::fabs(b);
2324
float bigger = (b > a) ? b : a;
2425
if(diff <= bigger * tolerance) return true;
2526
return false;

DirectProgramming/C++SYCL/Jupyter/sycl-performance-portability-training/src/mm_dpcpp_common.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <getopt.h>
1212
#include <ctime>
1313
#include <chrono>
14+
#include <cmath>
1415

1516
using namespace sycl;
1617

@@ -20,9 +21,9 @@ void mm_kernel(queue &q, std::vector<float> &matrix_a, std::vector<float> &matri
2021
//# floating point error verification function
2122
bool almost_equal(float a, float b){
2223
float tolerance = 1e-6;
23-
float diff = fabs(a - b);
24-
a = fabs(a);
25-
b = fabs(b);
24+
float diff = std::fabs(a - b);
25+
a = std::fabs(a);
26+
b = std::fabs(b);
2627
float bigger = (b > a) ? b : a;
2728
if(diff <= bigger * tolerance) return true;
2829
return false;

DirectProgramming/C++SYCL/Jupyter/sycl-performance-portability-training/src/mm_dpcpp_common_wg.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <getopt.h>
1212
#include <ctime>
1313
#include <chrono>
14+
#include <cmath>
1415

1516
using namespace sycl;
1617

@@ -20,9 +21,9 @@ void mm_kernel(queue &q, std::vector<float> &matrix_a, std::vector<float> &matri
2021
//# floating point error verification function
2122
bool almost_equal(float a, float b){
2223
float tolerance = 1e-6;
23-
float diff = fabs(a - b);
24-
a = fabs(a);
25-
b = fabs(b);
24+
float diff = std::fabs(a - b);
25+
a = std::fabs(a);
26+
b = std::fabs(b);
2627
float bigger = (b > a) ? b : a;
2728
if(diff <= bigger * tolerance) return true;
2829
return false;
@@ -89,7 +90,7 @@ int main(int argc, char *argv[]) {
8990
// find valid work-group sizes to try for performance.
9091
std::vector<int> work_group_sizes;
9192
auto max_work_group_size = q.get_device().get_info<info::device::max_work_group_size>();
92-
int work_group_dim_size = sqrt(max_work_group_size);
93+
int work_group_dim_size = std::sqrt(max_work_group_size);
9394
work_group_dim_size = work_group_dim_size - work_group_dim_size % 2;
9495
while (work_group_dim_size >= 2){
9596
if (N % work_group_dim_size == 0) work_group_sizes.push_back(work_group_dim_size);

0 commit comments

Comments
 (0)