Skip to content

Commit

Permalink
Merge remote-tracking branch 'github/main' into fp16_conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
EwanC committed Aug 31, 2023
2 parents c6fd096 + c511ac6 commit 4e56757
Show file tree
Hide file tree
Showing 89 changed files with 6,368 additions and 3,390 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ jobs:
fail-fast: false
matrix:
mainmatrix: [true]
os: [ubuntu-20.04, macos-latest, windows-latest]
os: [ubuntu-22.04, macos-latest, windows-latest]
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
mainmatrix: true
gl: 1
extra: " gl"
- os: ubuntu-20.04
- os: ubuntu-22.04
mainmatrix: false
arch: arm
- os: ubuntu-20.04
- os: ubuntu-22.04
mainmatrix: false
arch: aarch64
debug: 1
Expand Down Expand Up @@ -55,10 +55,10 @@ jobs:
run: ./presubmit.sh
formatcheck:
name: Check code format
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Install packages
run: sudo apt install -y clang-format clang-format-9
run: sudo apt install -y clang-format clang-format-11
- uses: actions/checkout@v3
with:
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion check-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Arg used to specify non-'origin/main' comparison branch
ORIGIN_BRANCH=${1:-"origin/main"}
CLANG_BINARY=${2:-"`which clang-format-9`"}
CLANG_BINARY=${2:-"`which clang-format-11`"}

# Run git-clang-format to check for violations
CLANG_FORMAT_OUTPUT=$(git-clang-format --diff $ORIGIN_BRANCH --extensions c,cpp,h,hpp --binary $CLANG_BINARY)
Expand Down
4 changes: 2 additions & 2 deletions test_common/gl/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,7 @@ void * CreateGLRenderbuffer( GLsizei width, GLsizei height,
// Reverse and reorder to validate since in the
// kernel the read_imagef() call always returns RGBA
cl_uchar *p = (cl_uchar *)buffer;
for( size_t i = 0; i < (size_t)width * height; i++ )
for (GLsizei i = 0; i < width * height; i++)
{
cl_uchar uc0 = p[i * 4 + 0];
cl_uchar uc1 = p[i * 4 + 1];
Expand All @@ -1733,7 +1733,7 @@ void * CreateGLRenderbuffer( GLsizei width, GLsizei height,
// Reverse and reorder to validate since in the
// kernel the read_imagef() call always returns RGBA
cl_uchar *p = (cl_uchar *)buffer;
for( size_t i = 0; i < width * height; i++ )
for (GLsizei i = 0; i < width * height; i++)
{
cl_uchar uc0 = p[i * 4 + 0];
cl_uchar uc1 = p[i * 4 + 1];
Expand Down
10 changes: 5 additions & 5 deletions test_common/harness/mt19937.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "harness/alloc.h"

#ifdef __SSE2__
#include <mutex>
#include <emmintrin.h>
#endif

Expand Down Expand Up @@ -107,7 +108,7 @@ cl_uint genrand_int32(MTdata d)
/* mag01[x] = x * MATRIX_A for x=0,1 */
static const cl_uint mag01[2] = { 0x0UL, MATRIX_A };
#ifdef __SSE2__
static volatile int init = 0;
static std::once_flag init_flag;
static union {
__m128i v;
cl_uint s[4];
Expand All @@ -123,8 +124,7 @@ cl_uint genrand_int32(MTdata d)
int kk;

#ifdef __SSE2__
if (0 == init)
{
auto init_fn = []() {
upper_mask.s[0] = upper_mask.s[1] = upper_mask.s[2] =
upper_mask.s[3] = UPPER_MASK;
lower_mask.s[0] = lower_mask.s[1] = lower_mask.s[2] =
Expand All @@ -134,8 +134,8 @@ cl_uint genrand_int32(MTdata d)
MATRIX_A;
c0.s[0] = c0.s[1] = c0.s[2] = c0.s[3] = (cl_uint)0x9d2c5680UL;
c1.s[0] = c1.s[1] = c1.s[2] = c1.s[3] = (cl_uint)0xefc60000UL;
init = 1;
}
};
std::call_once(init_flag, init_fn);
#endif

kk = 0;
Expand Down
7 changes: 4 additions & 3 deletions test_common/harness/stringHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
// limitations under the License.
//

#ifndef BASIC_UTILS_H
#define BASIC_UTILS_H
#ifndef STRING_HELPERS_H
#define STRING_HELPERS_H

#include <memory>
#include <stdexcept>
#include <string>

inline std::string concat_kernel(const char *sstr[], int num)
Expand All @@ -38,4 +39,4 @@ inline std::string str_sprintf(const std::string &str, Args... args)
return std::string(buffer.get(), buffer.get() + s - 1);
}

#endif // BASIC_UTIL_H
#endif // STRING_HELPERS_H
4 changes: 2 additions & 2 deletions test_common/harness/testHarness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,9 +835,9 @@ void callTestFunctions(test_definition testList[],
std::vector<std::thread *> threads;
test_harness_state state = { testList, resultTestList, deviceToUse,
config };
for (int i = 0; i < config.numWorkerThreads; i++)
for (unsigned i = 0; i < config.numWorkerThreads; i++)
{
log_info("Spawning worker thread %i\n", i);
log_info("Spawning worker thread %u\n", i);
threads.push_back(new std::thread(test_function_runner, &state));
}

Expand Down
1 change: 1 addition & 0 deletions test_conformance/allocations/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ int main(int argc, const char *argv[])
else if ( strcmp( argv[i], "--help" ) == 0 || strcmp( argv[i], "-h" ) == 0 )
{
printUsage( argv[0] );
free(argList);
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion test_conformance/api/test_queries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,8 @@ int test_kernel_required_group_size(cl_device_id deviceID, cl_context context, c
test_error(error, "clFinish failed");

if (max_dimensions == 2) {
return 0;
free(source);
return 0;
}

local[1]--; local[2]++;
Expand Down
48 changes: 21 additions & 27 deletions test_conformance/atomics/test_indexed_cases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//

#include <memory>

#include "testBase.h"
#include "harness/conversions.h"

Expand Down Expand Up @@ -226,13 +229,13 @@ int add_index_bin_test(size_t *global_threads, cl_command_queue queue,
(int)global_threads[0], (int)local_threads[0]);

// Allocate our storage
cl_mem bin_counters =
clMemWrapper bin_counters =
clCreateBuffer(context, CL_MEM_READ_WRITE,
sizeof(cl_int) * number_of_bins, NULL, NULL);
cl_mem bins = clCreateBuffer(
clMemWrapper bins = clCreateBuffer(
context, CL_MEM_READ_WRITE,
sizeof(cl_int) * number_of_bins * max_counts_per_bin, NULL, NULL);
cl_mem bin_assignments =
clMemWrapper bin_assignments =
clCreateBuffer(context, CL_MEM_READ_ONLY,
sizeof(cl_int) * number_of_items, NULL, NULL);

Expand All @@ -253,7 +256,7 @@ int add_index_bin_test(size_t *global_threads, cl_command_queue queue,
}

// Initialize our storage
cl_int *l_bin_counts = (cl_int *)malloc(sizeof(cl_int) * number_of_bins);
std::unique_ptr<cl_int[]> l_bin_counts(new cl_int[number_of_bins]);
if (!l_bin_counts)
{
log_error("add_index_bin_test FAILED to allocate initial values for "
Expand All @@ -263,8 +266,8 @@ int add_index_bin_test(size_t *global_threads, cl_command_queue queue,
int i;
for (i = 0; i < number_of_bins; i++) l_bin_counts[i] = 0;
err = clEnqueueWriteBuffer(queue, bin_counters, true, 0,
sizeof(cl_int) * number_of_bins, l_bin_counts, 0,
NULL, NULL);
sizeof(cl_int) * number_of_bins,
l_bin_counts.get(), 0, NULL, NULL);
if (err)
{
log_error("add_index_bin_test FAILED to set initial values for "
Expand All @@ -273,8 +276,8 @@ int add_index_bin_test(size_t *global_threads, cl_command_queue queue,
return -1;
}

cl_int *values =
(cl_int *)malloc(sizeof(cl_int) * number_of_bins * max_counts_per_bin);
std::unique_ptr<cl_int[]> values(
new cl_int[number_of_bins * max_counts_per_bin]);
if (!values)
{
log_error(
Expand All @@ -285,18 +288,16 @@ int add_index_bin_test(size_t *global_threads, cl_command_queue queue,
err = clEnqueueWriteBuffer(queue, bins, true, 0,
sizeof(cl_int) * number_of_bins
* max_counts_per_bin,
values, 0, NULL, NULL);
values.get(), 0, NULL, NULL);
if (err)
{
log_error(
"add_index_bin_test FAILED to set initial values for bins: %d\n",
err);
return -1;
}
free(values);

cl_int *l_bin_assignments =
(cl_int *)malloc(sizeof(cl_int) * number_of_items);
std::unique_ptr<cl_int[]> l_bin_assignments(new cl_int[number_of_items]);
if (!l_bin_assignments)
{
log_error("add_index_bin_test FAILED to allocate initial values for "
Expand Down Expand Up @@ -326,7 +327,7 @@ int add_index_bin_test(size_t *global_threads, cl_command_queue queue,
}
err = clEnqueueWriteBuffer(queue, bin_assignments, true, 0,
sizeof(cl_int) * number_of_items,
l_bin_assignments, 0, NULL, NULL);
l_bin_assignments.get(), 0, NULL, NULL);
if (err)
{
log_error("add_index_bin_test FAILED to set initial values for "
Expand Down Expand Up @@ -355,8 +356,8 @@ int add_index_bin_test(size_t *global_threads, cl_command_queue queue,
return -1;
}

cl_int *final_bin_assignments =
(cl_int *)malloc(sizeof(cl_int) * number_of_bins * max_counts_per_bin);
std::unique_ptr<cl_int[]> final_bin_assignments(
new cl_int[number_of_bins * max_counts_per_bin]);
if (!final_bin_assignments)
{
log_error("add_index_bin_test FAILED to allocate initial values for "
Expand All @@ -366,24 +367,23 @@ int add_index_bin_test(size_t *global_threads, cl_command_queue queue,
err = clEnqueueReadBuffer(queue, bins, true, 0,
sizeof(cl_int) * number_of_bins
* max_counts_per_bin,
final_bin_assignments, 0, NULL, NULL);
final_bin_assignments.get(), 0, NULL, NULL);
if (err)
{
log_error("add_index_bin_test FAILED to read back bins: %d\n", err);
return -1;
}

cl_int *final_bin_counts =
(cl_int *)malloc(sizeof(cl_int) * number_of_bins);
std::unique_ptr<cl_int[]> final_bin_counts(new cl_int[number_of_bins]);
if (!final_bin_counts)
{
log_error("add_index_bin_test FAILED to allocate initial values for "
"final_bin_counts.\n");
return -1;
}
err = clEnqueueReadBuffer(queue, bin_counters, true, 0,
sizeof(cl_int) * number_of_bins, final_bin_counts,
0, NULL, NULL);
sizeof(cl_int) * number_of_bins,
final_bin_counts.get(), 0, NULL, NULL);
if (err)
{
log_error("add_index_bin_test FAILED to read back bin_counters: %d\n",
Expand Down Expand Up @@ -460,13 +460,7 @@ int add_index_bin_test(size_t *global_threads, cl_command_queue queue,
errors++;
}
}
free(l_bin_counts);
free(l_bin_assignments);
free(final_bin_assignments);
free(final_bin_counts);
clReleaseMemObject(bin_counters);
clReleaseMemObject(bins);
clReleaseMemObject(bin_assignments);

if (errors == 0)
{
log_info("add_index_bin_test passed. Each item was put in the correct "
Expand Down
2 changes: 0 additions & 2 deletions test_conformance/basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,12 @@ set(${MODULE_NAME}_SOURCES
test_kernel_call_kernel_function.cpp
test_local_kernel_scope.cpp
test_progvar.cpp
test_wg_barrier.cpp
test_global_linear_id.cpp
test_local_linear_id.cpp
test_enqueued_local_size.cpp
test_simple_image_pitch.cpp
test_get_linear_ids.cpp
test_rw_image_access_qualifier.cpp
test_wg_barrier.cpp
test_enqueued_local_size.cpp
test_global_linear_id.cpp
test_local_linear_id.cpp
Expand Down
Loading

0 comments on commit 4e56757

Please sign in to comment.