Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
da3e996
Allow building for unavailable devices in offline compile mode
ping-ee Oct 11, 2026
19d97d2
Fix program-scope variable initialization on queried and rebuilt prog…
maleadt Oct 19, 2026
460bf3b
Test clCreateProgramWithBinary on sub-devices of one root and a secon…
anun333 Sep 26, 2026
d9cd5e2
clCreateProgramWithBinary: read binaries and write binary_status by t…
anun333 Sep 26, 2026
c2c1033
test_program_binary_subdevices: release the program and free the bina…
anun333 Oct 20, 2026
e0a724e
tests: regression test for -cl-fp32-correctly-rounded-divide-sqrt
anun333 Oct 15, 2026
b254aec
Check -cl-fp32-correctly-rounded-divide-sqrt against each device
anun333 Oct 20, 2026
4527e33
CPU: report correctly rounded divide and sqrt on AArch64
anun333 Oct 16, 2026
4880e71
test_subgroup_queries: look up clGetKernelSubGroupInfoKHR by name
anun333 Oct 21, 2026
3a6a2b8
Return clGetKernelSubGroupInfoKHR from clGetExtensionFunctionAddressF…
anun333 Oct 21, 2026
a3f44c6
VariableUniformityAnalysis: don't reuse the uniformity of deleted values
maleadt Oct 24, 2026
de1ef97
Merge pull request #2414 from maleadt/tb/vua-deleted-values
tneval Oct 26, 2026
6907c6a
cl_half.h: don't shift into the sign bit of int
maleadt Oct 21, 2026
fd77eb3
printf: decode half arguments without _Float16
maleadt Oct 15, 2026
ea24dc2
Account for the z extent and global offset in the grid width
maleadt Oct 19, 2026
17d39e8
build(deps): bump the codeql-dependencies group with 3 updates
dependabot[bot] Oct 27, 2026
934623e
Merge pull request #2417 from pocl/dependabot/github_actions/codeql-d…
franz Oct 28, 2026
cd28603
Merge branch 'main' into fix/cr-divsqrt-check
franz Oct 29, 2026
75036dc
Merge pull request #2405 from anun333/fix/cr-divsqrt-check
franz Oct 29, 2026
8a0216b
Merge pull request #2406 from ping-ee/fix/offline-compile-unavailable…
franz Oct 30, 2026
110a597
Merge pull request #2407 from maleadt/tb/gvar-init-once
franz Oct 30, 2026
a74c7d0
clCreateProgramWithBinary: names and comments from review
anun333 Oct 30, 2026
4549718
Merge pull request #2412 from anun333/fix/subgroup-info-khr-noicd
franz Oct 30, 2026
8a741e5
test_program_binary_subdevices: refuse different binaries for sub-dev…
anun333 Oct 31, 2026
171ed9a
clCreateProgramWithBinary: refuse different binaries for one root device
anun333 Oct 31, 2026
6b8a44a
Pass LLVMContext to PassBuilder constructor for LLVM 24
woodychow Nov 2, 2026
c631093
[llvmopencl] Use BasicBlock::getFirstNonPHIOrLifetime for LLVM 24
woodychow Nov 2, 2026
36f1608
Merge pull request #2420 from woodychow/fix-passbuilder-llvm24
franz Nov 2, 2026
ef6588c
Merge pull request #2366 from anun333/fix/binary-index-collapse
franz Nov 2, 2026
e5aa282
Fix the SVM and USM shadow-buffer failure paths
pvelesko Oct 26, 2026
e4afc5d
Do not touch *event when an SVM/USM memcpy fails to enqueue
pvelesko Oct 26, 2026
77460a1
Fix abs() of the minimum signed integer
maleadt Nov 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee
uses: github/codeql-action/init@9b3254085494b55a0f7c4c2b3d2d52cc712ce370
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
Expand Down Expand Up @@ -90,6 +90,6 @@ jobs:
exit 1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee
uses: github/codeql-action/analyze@9b3254085494b55a0f7c4c2b3d2d52cc712ce370
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard (optional).
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee
uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370
with:
sarif_file: results.sarif
9 changes: 6 additions & 3 deletions include/CL/cl_half.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ static inline cl_float cl_half_to_float(cl_half h)
} f32;

// Extract sign bit
// pocl: the `sign << 31` below is cast to uint32_t, since shifting the
// promoted int into its sign bit is undefined. KhronosGroup/OpenCL-Headers
// still has the uncast shift; keep the casts when syncing this header.
uint16_t sign = h >> 15;

// Extract FP16 exponent and mantissa
Expand All @@ -388,13 +391,13 @@ static inline cl_float cl_half_to_float(cl_half h)
// NaN -> propagate mantissa and silence it
uint32_t f_mant = h_mant << (CL_FLT_MANT_DIG - CL_HALF_MANT_DIG);
f_mant |= 0x400000;
f32.i = (sign << 31) | 0x7F800000 | f_mant;
f32.i = ((uint32_t)sign << 31) | 0x7F800000 | f_mant;
return f32.f;
}
else
{
// Infinity -> zero mantissa
f32.i = (sign << 31) | 0x7F800000;
f32.i = ((uint32_t)sign << 31) | 0x7F800000;
return f32.f;
}
}
Expand Down Expand Up @@ -423,7 +426,7 @@ static inline cl_float cl_half_to_float(cl_half h)
}
}

f32.i = (sign << 31) | (f_exp << 23) | (h_mant << 13);
f32.i = ((uint32_t)sign << 31) | (f_exp << 23) | (h_mant << 13);
return f32.f;
}

Expand Down
100 changes: 82 additions & 18 deletions lib/CL/clCreateProgramWithBinary.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,34 @@
#include "pocl_util.h"
#include <string.h>

/* The caller's binaries, lengths and binary_status are indexed by the
* caller's device list. The program has one slot per distinct root device, in
* the order pocl_unique_device_list leaves them, so a slot must find its
* entries by device, not by position: [sub1, sub2, other] reduces to
* [other, root]. */
static unsigned
find_index_for_root_device (const cl_device_id *caller_devs,
cl_uint caller_num, cl_device_id root)
{
for (unsigned j = 0; j < caller_num; ++j)
if (pocl_real_dev (caller_devs[j]) == root)
return j;
assert (0 && "every root comes from the caller's list");
return 0;
}

/* Set binary status to 'status' for devices matching to or sub-divided from 'root' device. */
static void
set_binary_status (cl_int *binary_status, const cl_device_id *caller_devs,
cl_uint caller_num, cl_device_id root, cl_int status)
{
if (binary_status == NULL)
return;
for (unsigned j = 0; j < caller_num; ++j)
if (pocl_real_dev (caller_devs[j]) == root)
binary_status[j] = status;
}

/** Creates either a program with binaries, or an empty program.
*
* The latter is useful for clLinkProgram() which needs an empty program to put
Expand Down Expand Up @@ -78,7 +106,10 @@ create_program_skeleton (cl_context context, cl_uint num_devices,
"device %s specified multiple times\n", context->devices[i]->long_name);
}

// convert subdevices to devices and remove duplicates
// convert subdevices to devices and remove duplicates; the caller's list
// still indexes binaries[], lengths[] and binary_status[]
const cl_device_id *original_device_list = device_list;
cl_uint original_num_devices = num_devices;
cl_uint real_num_devices = 0;
unique_devlist = pocl_unique_device_list(device_list, num_devices, &real_num_devices);
num_devices = real_num_devices;
Expand All @@ -100,6 +131,29 @@ create_program_skeleton (cl_context context, cl_uint num_devices,
device_list[i]->long_name);
}

/* The program keeps one binary per root device, so entries that reduce to
the same root must carry the same binary: a different one could not be
kept, and kernels on its device would run the other's. */
if (binaries != NULL && lengths != NULL)
for (i = 0; i < original_num_devices; ++i)
for (j = i + 1; j < original_num_devices; ++j)
{
if (pocl_real_dev (original_device_list[i])
!= pocl_real_dev (original_device_list[j])
|| binaries[i] == NULL || binaries[j] == NULL)
continue;
if (lengths[i] == lengths[j]
&& (binaries[i] == binaries[j]
|| memcmp (binaries[i], binaries[j], lengths[i]) == 0))
continue;
if (binary_status != NULL)
binary_status[i] = binary_status[j] = CL_INVALID_BINARY;
POCL_GOTO_ERROR_ON (1, CL_INVALID_BINARY,
"devices %u and %u share a root device but "
"were given different binaries\n",
i, j);
}

if ((program = (cl_program) calloc (1, sizeof (struct _cl_program))) == NULL)
{
errcode = CL_OUT_OF_HOST_MEMORY;
Expand Down Expand Up @@ -157,14 +211,20 @@ create_program_skeleton (cl_context context, cl_uint num_devices,

for (i = 0; i < num_devices; ++i)
{
unsigned src = find_index_for_root_device (original_device_list,
original_num_devices,
device_list[i]);
const unsigned char *binary = binaries[src];
size_t length = lengths[src];

/* Poclcc binary */
if (pocl_binary_check_binary(device_list[i], binaries[i]))
if (pocl_binary_check_binary (device_list[i], binary))
{
program->pocl_binary_sizes[i] = lengths[i];
program->pocl_binaries[i] = (unsigned char*) malloc (lengths[i]);
memcpy (program->pocl_binaries[i], binaries[i], lengths[i]);
program->pocl_binary_sizes[i] = length;
program->pocl_binaries[i] = (unsigned char *)malloc (length);
memcpy (program->pocl_binaries[i], binary, length);

pocl_binary_set_program_buildhash (program, i, binaries[i]);
pocl_binary_set_program_buildhash (program, i, binary);
int error = pocl_cache_create_program_cachedir
(program, i, NULL, 0, program_bc_path);
POCL_GOTO_ERROR_ON((error != 0), CL_BUILD_PROGRAM_FAILURE,
Expand All @@ -182,28 +242,32 @@ create_program_skeleton (cl_context context, cl_uint num_devices,
program->binary_sizes[i] = (size_t)size;
}

if (binary_status != NULL)
binary_status[i] = CL_SUCCESS;
set_binary_status (binary_status, original_device_list,
original_num_devices, device_list[i],
CL_SUCCESS);
}
/* check if the driver supports that binary */
else
{
cl_device_id device = program->associated_devices[i];
if (device->ops->supports_binary
&& device->ops->supports_binary (device, lengths[i],
(const char *)binaries[i]))
&& device->ops->supports_binary (device, length,
(const char *)binary))
{
program->binary_sizes[i] = lengths[i];
program->binaries[i] = (unsigned char *)malloc (lengths[i]);
memcpy (program->binaries[i], binaries[i], lengths[i]);
if (binary_status != NULL)
binary_status[i] = CL_SUCCESS;
program->binary_sizes[i] = length;
program->binaries[i] = (unsigned char *)malloc (length);
memcpy (program->binaries[i], binary, length);
set_binary_status (binary_status, original_device_list,
original_num_devices, device_list[i],
CL_SUCCESS);
}
else
{
POCL_MSG_WARN ("Could not recognize binary for device %i\n", i);
if (binary_status != NULL)
binary_status[i] = CL_INVALID_BINARY;
POCL_MSG_WARN ("Could not recognize binary for device %u\n",
src);
set_binary_status (binary_status, original_device_list,
original_num_devices, device_list[i],
CL_INVALID_BINARY);
errcode = CL_INVALID_BINARY;
goto ERROR;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/CL/clEnqueueSVMMemcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pocl_svm_memcpy_common (cl_command_buffer_khr command_buffer,
}

// TODO this is likely very wrong
if (event != NULL)
if (errcode == CL_SUCCESS && event != NULL)
(*event)->command_type = command_type;

return errcode;
Expand Down
6 changes: 6 additions & 0 deletions lib/CL/clGetExtensionFunctionAddressForPlatform.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ CL_API_SUFFIX__VERSION_1_2
if (strcmp (func_name, "clCreateProgramWithILKHR") == 0)
return (void *)&POname(clCreateProgramWithIL);

/* cl_khr_subgroups. Without an ICD loader this is the only way to reach
it; loaders answer the name themselves or through
clIcdGetFunctionAddressForPlatformKHR. */
if (strcmp (func_name, "clGetKernelSubGroupInfoKHR") == 0)
return (void *)&POname (clGetKernelSubGroupInfo);

/* cl_khr_command_buffer */
if (strcmp (func_name, "clCreateCommandBufferKHR") == 0)
return (void *)&POname (clCreateCommandBufferKHR);
Expand Down
3 changes: 2 additions & 1 deletion lib/CL/clMemAllocINTEL.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ pocl_usm_alloc (unsigned alloc_type, cl_context context, cl_device_id device,
POCL_UNLOCK_OBJ (context);
device->ops->usm_free (device, ptr);
POCL_MSG_ERR ("Failed to allocate memory a shadow cl_mem object.\n");
return NULL;
ptr = NULL;
goto ERROR;
}

item->shadow_cl_mem = clmem_shadow;
Expand Down
1 change: 0 additions & 1 deletion lib/CL/clSVMAlloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ POname(clSVMAlloc)(cl_context context,
POCL_LOCK_OBJ (context);
pocl_raw_ptr_set_erase (context->raw_ptrs, item);
POCL_UNLOCK_OBJ (context);
POCL_MEM_FREE (item);
context->svm_allocdev->ops->svm_free (context->svm_allocdev, ptr);
POCL_MSG_ERR ("Failed to allocate memory a shadow cl_mem object.\n");
return NULL;
Expand Down
1 change: 1 addition & 0 deletions lib/CL/devices/basic/basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ pocl_basic_free_program (cl_device_id device, cl_program program,
pocl_driver_free_program (device, program, dev_i);
program->global_var_total_size[dev_i] = 0;
pocl_aligned_free (program->gvar_storage[dev_i]);
program->gvar_storage[dev_i] = NULL;
return 0;
}
/*********************** IMAGES ********************************/
Expand Down
11 changes: 7 additions & 4 deletions lib/CL/devices/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -983,13 +983,16 @@ pocl_fill_dev_sampler_t (dev_sampler_t *ds, struct pocl_argument *parg)
}

/* Returns the width of the widest dimension in the grid of the given
run command. */
run command, counted from the origin: the small-grid work-group functions
assume that both the group counts and the global offsets are bounded. */
size_t
pocl_cmd_max_grid_dim_width (_cl_command_run *cmd)
{
return max (max (cmd->pc.local_size[0] * cmd->pc.num_groups[0],
cmd->pc.local_size[1] * cmd->pc.num_groups[1]),
cmd->pc.local_size[2] * cmd->pc.local_size[2]);
size_t width = 0;
for (unsigned d = 0; d < 3; ++d)
width = max (width, cmd->pc.global_offset[d]
+ cmd->pc.local_size[d] * cmd->pc.num_groups[d]);
return width;
}


Expand Down
Loading
Loading