Skip to content

Commit e261d9c

Browse files
committed
a few more fixes
1 parent cdee85b commit e261d9c

6 files changed

Lines changed: 37 additions & 25 deletions

File tree

samples/20_matrixexperiments-bf16/main.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <algorithm>
1212
#include <chrono>
13+
#include <iostream>
1314
#include <sstream>
1415
#include <string>
1516
#include <random>
@@ -68,18 +69,23 @@ std::string makeTestName(
6869

6970
static size_t findMinSubGroupSize(cl::Device& device)
7071
{
71-
auto s = device.getInfo<CL_DEVICE_SUB_GROUP_SIZES_INTEL>();
72-
auto it = std::min_element(std::begin(s), std::end(s));
73-
if (it != std::end(s)) {
74-
return *it;
72+
if (checkDeviceForExtension(device, CL_INTEL_REQUIRED_SUBGROUP_SIZE_EXTENSION_NAME)) {
73+
auto s = device.getInfo<CL_DEVICE_SUB_GROUP_SIZES_INTEL>();
74+
auto it = std::min_element(std::begin(s), std::end(s));
75+
if (it != std::end(s)) {
76+
return *it;
77+
}
7578
}
7679
return 0;
7780
}
7881

7982
static bool supportsSubgroupSize(cl::Device& device, size_t subgroupSize)
8083
{
81-
auto s = device.getInfo<CL_DEVICE_SUB_GROUP_SIZES_INTEL>();
82-
return std::find(std::begin(s), std::end(s), subgroupSize) != std::end(s);
84+
if (checkDeviceForExtension(device, CL_INTEL_REQUIRED_SUBGROUP_SIZE_EXTENSION_NAME)) {
85+
auto s = device.getInfo<CL_DEVICE_SUB_GROUP_SIZES_INTEL>();
86+
return std::find(std::begin(s), std::end(s), subgroupSize) != std::end(s);
87+
}
88+
return false;
8389
}
8490

8591
static void setRoundRobin(cl::Kernel& kernel)

samples/20_matrixexperiments-bf16/matrix_helpers_bf16.cl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ float8 activation(float8 f)
6161
#ifndef __has_builtin
6262
#define __has_builtin(x) 0
6363
#endif
64-
#if __has_builtin(__builtin_expect) == 0
65-
#define __builtin_expect(x)
64+
#if __has_builtin(__builtin_assume) == 0
65+
#define __builtin_assume(x)
6666
#endif
6767

6868
#if defined(cl_intel_subgroups) && defined(cl_intel_subgroups_short)

samples/20_matrixexperiments-i8/main.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <algorithm>
1212
#include <chrono>
13-
#include <cstdint>
13+
#include <iostream>
1414
#include <sstream>
1515
#include <string>
1616
#include <random>
@@ -68,18 +68,23 @@ std::string makeTestName(
6868

6969
static size_t findMinSubGroupSize(cl::Device& device)
7070
{
71-
auto s = device.getInfo<CL_DEVICE_SUB_GROUP_SIZES_INTEL>();
72-
auto it = std::min_element(std::begin(s), std::end(s));
73-
if (it != std::end(s)) {
74-
return *it;
71+
if (checkDeviceForExtension(device, CL_INTEL_REQUIRED_SUBGROUP_SIZE_EXTENSION_NAME)) {
72+
auto s = device.getInfo<CL_DEVICE_SUB_GROUP_SIZES_INTEL>();
73+
auto it = std::min_element(std::begin(s), std::end(s));
74+
if (it != std::end(s)) {
75+
return *it;
76+
}
7577
}
7678
return 0;
7779
}
7880

7981
static bool supportsSubgroupSize(cl::Device& device, size_t subgroupSize)
8082
{
81-
auto s = device.getInfo<CL_DEVICE_SUB_GROUP_SIZES_INTEL>();
82-
return std::find(std::begin(s), std::end(s), subgroupSize) != std::end(s);
83+
if (checkDeviceForExtension(device, CL_INTEL_REQUIRED_SUBGROUP_SIZE_EXTENSION_NAME)) {
84+
auto s = device.getInfo<CL_DEVICE_SUB_GROUP_SIZES_INTEL>();
85+
return std::find(std::begin(s), std::end(s), subgroupSize) != std::end(s);
86+
}
87+
return false;
8388
}
8489

8590
static void setRoundRobin(cl::Kernel& kernel)

samples/20_matrixexperiments-i8/matrix_helpers_i8.cl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ int8 activation(int8 i)
5252
#ifndef __has_builtin
5353
#define __has_builtin(x) 0
5454
#endif
55-
#if __has_builtin(__builtin_expect) == 0
56-
#define __builtin_expect(x)
55+
#if __has_builtin(__builtin_assume) == 0
56+
#define __builtin_assume(x)
5757
#endif
5858

5959
#if defined(__opencl_c_integer_dot_product_input_4x8bit_packed)

samples/20_matrixexperiments-tf32/main.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
#include <algorithm>
1212
#include <chrono>
13-
#include <cmath>
14-
#include <limits>
13+
#include <iostream>
1514
#include <sstream>
1615
#include <string>
1716
#include <random>
@@ -69,10 +68,12 @@ std::string makeTestName(
6968

7069
static size_t findMinSubGroupSize(cl::Device& device)
7170
{
72-
auto s = device.getInfo<CL_DEVICE_SUB_GROUP_SIZES_INTEL>();
73-
auto it = std::min_element(std::begin(s), std::end(s));
74-
if (it != std::end(s)) {
75-
return *it;
71+
if (checkDeviceForExtension(device, CL_INTEL_REQUIRED_SUBGROUP_SIZE_EXTENSION_NAME)) {
72+
auto s = device.getInfo<CL_DEVICE_SUB_GROUP_SIZES_INTEL>();
73+
auto it = std::min_element(std::begin(s), std::end(s));
74+
if (it != std::end(s)) {
75+
return *it;
76+
}
7677
}
7778
return 0;
7879
}

samples/20_matrixexperiments-tf32/matrix_helpers_tf32.cl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ float8 activation(float8 f)
5252
#ifndef __has_builtin
5353
#define __has_builtin(x) 0
5454
#endif
55-
#if __has_builtin(__builtin_expect) == 0
56-
#define __builtin_expect(x)
55+
#if __has_builtin(__builtin_assume) == 0
56+
#define __builtin_assume(x)
5757
#endif
5858

5959
#if defined(cl_intel_subgroups)

0 commit comments

Comments
 (0)