Skip to content

Commit 57d47d0

Browse files
2 parents 84e793c + dd7c2cd commit 57d47d0

17 files changed

+64
-77
lines changed

include/acl_auto.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ extern "C" {
1616
* The last one is for the driver version query. The OpenCL spec says it
1717
* has to match \d+.\d+ and nothing else.
1818
*/
19-
#define ACL_VERSION "v2023.1.0"
20-
#define ACL_VERSION_PLAIN "2023.1"
21-
#define ACL_VERSION_PLAIN_FOR_DRIVER_QUERY "2023.1"
19+
#define ACL_VERSION "v2023.2.0"
20+
#define ACL_VERSION_PLAIN "2023.2"
21+
#define ACL_VERSION_PLAIN_FOR_DRIVER_QUERY "2023.2"
2222

2323
/* Check if we are currently compiling for ACDS Pro or Standard.
2424
* 1 means Pro and 0 means Standard.

include/acl_device_binary.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ class acl_device_binary_t {
2626
public:
2727
~acl_device_binary_t() { unload_content(); }
2828

29+
acl_device_binary_t &operator=(const acl_device_binary_t &) = delete;
30+
31+
acl_device_binary_t(const acl_device_binary_t &) = delete;
32+
33+
acl_device_binary_t() = default;
34+
2935
inline void set_dev_prog(acl_device_program_info_t *dev_prog) {
3036
m_dev_prog = dev_prog;
3137
}

include/acl_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,10 @@ typedef struct _cl_platform_id
15761576
// The setting of environment variable CL_CONTEXT_OFFLINE_DEVICE_INTELFPGA, if
15771577
// any.
15781578
std::string offline_device;
1579+
// Cache context offline mode specified by environment variables
1580+
// CL_CONTEXT_OFFLINE_DEVICE_INTELFPGA, CL_CONTEXT_MPSIM_DEVICE_INTELFPGA
1581+
// or CL_CONTEXT_MSIM_DEVICE_INTELFPGA
1582+
int offline_mode;
15791583

15801584
// Should we track and automatically release leaked objects?
15811585
// This helps immensely with the OpenCL conformance tests which tend to

lib/acl_threadsupport/include/acl_threadsupport/acl_threadsupport.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ int acl_sem_destroy(acl_sem_t *sem);
186186
// The very tricky part is that the signaler can only use
187187
// semaphore-increment, and therefore *does not have a lock*.
188188
//
189-
// See this Microsoft Research paper on how to implement condition
190-
// variables with only semaphores
191-
// http://research.microsoft.com/pubs/64242/implementingcvs.pdf
192-
// It's veyr instructive, but we can't use its implementation because:
189+
// See
190+
// Andrew D. Birrell, Implementing Condition Variables with Semaphores (2003).
191+
// https://web.archive.org/web/20091122223051/http://research.microsoft.com/pubs/64242/implementingcvs.pdf
192+
// It's very instructive, but we can't use its implementation because:
193193
// - The signaler acquires a mutex
194194
// - It keeps an explicit linked list of waiters
195195
//

src/acl_auto_configure.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -775,14 +775,12 @@ static bool read_accel_defs(const std::string &config_str,
775775
accel[i].mem.next = reinterpret_cast<void *>(0x00020000);
776776

777777
int total_fields_kernel = 0;
778-
if (result) {
779-
result = read_int_counters(config_str, curr_pos, total_fields_kernel,
780-
counters);
781-
}
778+
result = result && read_int_counters(config_str, curr_pos,
779+
total_fields_kernel, counters);
782780
counters.emplace_back(total_fields_kernel);
783781

784-
result =
785-
read_string_counters(config_str, curr_pos, hal_info[i].name, counters);
782+
result = result && read_string_counters(config_str, curr_pos,
783+
hal_info[i].name, counters);
786784

787785
if (!result)
788786
break;

src/acl_context.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,6 @@ static cl_int l_finalize_context(cl_context context, cl_uint num_devices,
553553
static cl_int l_load_properties(cl_context context,
554554
const cl_context_properties *properties) {
555555
const char *default_compile_cmd = 0;
556-
int env_override = 0;
557556
acl_assert_locked();
558557

559558
// Set defaults.
@@ -717,8 +716,6 @@ static cl_int l_load_properties(cl_context context,
717716
// Always terminate list. After all, 'properties' might be empty!
718717
context->properties[context->num_property_entries++] = 0;
719718

720-
(void)acl_get_offline_device_user_setting(&env_override);
721-
722719
context->compiles_programs_incompletely = 0;
723720
switch (context->compiler_mode) {
724721
case static_cast<acl_compiler_mode_t>(
@@ -788,7 +785,7 @@ static cl_int l_load_properties(cl_context context,
788785
// We need backing store for the buffers.
789786
context->device_buffers_have_backing_store = 1;
790787

791-
if (env_override == ACL_CONTEXT_MPSIM) {
788+
if (acl_platform.offline_mode == ACL_CONTEXT_MPSIM) {
792789
// Simulator should support save/restore buffers around programming if
793790
// reprogramming on-the-fly is supported
794791
context->saves_and_restores_buffers_for_reprogramming = 1;

src/acl_device_binary.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,10 @@ cl_int acl_device_binary_t::load_binary_pkg(int validate_compile_options,
175175
#define FAILREAD_MSG "Could not read parts of the program binary."
176176
size_t data_len = 0;
177177

178-
int env_override = 0;
179-
180178
acl_assert_locked();
181179

182-
(void)acl_get_offline_device_user_setting(&env_override);
183-
184-
if (env_override == ACL_CONTEXT_MPSIM && !validate_compile_options &&
180+
if (acl_platform.offline_mode == ACL_CONTEXT_MPSIM &&
181+
!validate_compile_options &&
185182
context->compiler_mode != CL_CONTEXT_COMPILER_MODE_OFFLINE_INTELFPGA &&
186183
get_binary_len() < 1024) {
187184
// IF the binary is ridiculously small (arbitrary number) we are going
@@ -258,7 +255,7 @@ cl_int acl_device_binary_t::load_binary_pkg(int validate_compile_options,
258255
// runtime.
259256
if (acl_pkg_section_exists(pkg, ".acl.rand_hash", &data_len) &&
260257
dev_prog->device->loaded_bin == nullptr &&
261-
env_override != ACL_CONTEXT_MPSIM) {
258+
acl_platform.offline_mode != ACL_CONTEXT_MPSIM) {
262259
std::vector<char> pkg_rand_hash(data_len + 1);
263260
AND_CHECK(acl_pkg_read_section(pkg, ".acl.rand_hash", pkg_rand_hash.data(),
264261
data_len + 1),
@@ -305,7 +302,7 @@ cl_int acl_device_binary_t::load_binary_pkg(int validate_compile_options,
305302
// For simulator flow, we treat as if the device has already been
306303
// programmed and check device global memory layout against
307304
// dev_prog->device->last_bin
308-
if (env_override == ACL_CONTEXT_MPSIM) {
305+
if (acl_platform.offline_mode == ACL_CONTEXT_MPSIM) {
309306
if (validate_memory_layout && dev_prog->device->last_bin) {
310307
AND_CHECK(get_devdef().autodiscovery_def.num_global_mem_systems <=
311308
1 ||
@@ -357,7 +354,7 @@ cl_int acl_device_binary_t::load_binary_pkg(int validate_compile_options,
357354
is_simulator = 0;
358355
if (status == CL_SUCCESS &&
359356
acl_pkg_section_exists(pkg, ".acl.simulator_object", &data_len)) {
360-
if (env_override != ACL_CONTEXT_MPSIM) {
357+
if (acl_platform.offline_mode != ACL_CONTEXT_MPSIM) {
361358
acl_context_callback(
362359
context,
363360
"aocx contains simulated kernel, but simulation mode not set!");
@@ -382,7 +379,7 @@ cl_int acl_device_binary_t::load_binary_pkg(int validate_compile_options,
382379
context,
383380
"aocx contains unsupported legacy opencl emulated kernel for windows!");
384381
}
385-
if (status == CL_SUCCESS && env_override == ACL_CONTEXT_MPSIM &&
382+
if (status == CL_SUCCESS && acl_platform.offline_mode == ACL_CONTEXT_MPSIM &&
386383
!is_simulator) {
387384
acl_context_callback(context,
388385
"Simulation mode set but aocx is for hardware!");

src/acl_globals.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ cl_bool acl_init_from_hal_discovery(void) {
203203
return CL_FALSE;
204204
}
205205
// Probe the HAL for a device.
206-
acl_set_hal(board_hal);
206+
if (!acl_set_hal(board_hal)) {
207+
return CL_FALSE;
208+
}
207209

208210
if (use_offline_only != ACL_CONTEXT_OFFLINE_ONLY) {
209211
acl_present_board_is_valid_value = 1;
@@ -224,6 +226,7 @@ void acl_reset(void) {
224226
l_reset_present_board();
225227

226228
acl_platform.offline_device = "";
229+
acl_platform.offline_mode = ACL_CONTEXT_OFFLINE_AND_AUTODISCOVERY;
227230
acl_platform.num_devices = 0;
228231
for (unsigned i = 0; i < ACL_MAX_DEVICE; ++i) {
229232
acl_platform.device[i] = _cl_device_id();

src/acl_hal_mmd.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ cl_bool l_load_board_libraries(cl_bool load_libraries) {
855855
}
856856
fin.close();
857857
}
858+
closedir(dir);
858859
}
859860

860861
if (num_vendor_files_found == 0) {
@@ -876,8 +877,6 @@ cl_bool l_load_board_libraries(cl_bool load_libraries) {
876877
}
877878
}
878879

879-
if (dir)
880-
closedir(dir);
881880
return num_boards_found == 0 ? CL_FALSE : CL_TRUE;
882881
}
883882
#endif
@@ -1248,7 +1247,7 @@ acl_mmd_get_system_definition(acl_system_def_t *sys,
12481247
#endif
12491248

12501249
// Dynamically load board mmd & symbols
1251-
acl_get_offline_device_user_setting(&use_offline_only);
1250+
(void)acl_get_offline_device_user_setting(&use_offline_only);
12521251
if (use_offline_only == ACL_CONTEXT_MPSIM) {
12531252

12541253
// Substitute the simulator MMD layer.

src/acl_hostch.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,14 @@ CL_API_ENTRY cl_int CL_API_CALL clReadPipeIntelFPGA(cl_mem pipe, void *ptr) {
248248
acl_idle_update(pipe->context);
249249
}
250250

251-
acl_mutex_lock(&(pipe->host_pipe_info->m_lock));
252-
253-
// Error checking
254251
if (pipe->host_pipe_info == NULL) {
255-
acl_mutex_unlock(&(pipe->host_pipe_info->m_lock));
256252
ERR_RET(CL_INVALID_MEM_OBJECT, pipe->context,
257253
"This pipe is not a host pipe");
258254
}
255+
256+
acl_mutex_lock(&(pipe->host_pipe_info->m_lock));
257+
258+
// Error checking
259259
if (!(pipe->flags & CL_MEM_HOST_READ_ONLY)) {
260260
acl_mutex_unlock(&(pipe->host_pipe_info->m_lock));
261261
ERR_RET(CL_INVALID_MEM_OBJECT, pipe->context,
@@ -349,14 +349,14 @@ CL_API_ENTRY cl_int CL_API_CALL clWritePipeIntelFPGA(cl_mem pipe, void *ptr) {
349349
acl_idle_update(pipe->context);
350350
}
351351

352-
acl_mutex_lock(&(pipe->host_pipe_info->m_lock));
353-
354352
// Error checking
355353
if (pipe->host_pipe_info == NULL) {
356-
acl_mutex_unlock(&(pipe->host_pipe_info->m_lock));
357354
ERR_RET(CL_INVALID_MEM_OBJECT, pipe->context,
358355
"This pipe is not a host pipe");
359356
}
357+
358+
acl_mutex_lock(&(pipe->host_pipe_info->m_lock));
359+
360360
if (!(pipe->flags & CL_MEM_HOST_WRITE_ONLY)) {
361361
acl_mutex_unlock(&(pipe->host_pipe_info->m_lock));
362362
ERR_RET(CL_INVALID_MEM_OBJECT, pipe->context,
@@ -465,6 +465,11 @@ CL_API_ENTRY void *CL_API_CALL clMapHostPipeIntelFPGA(cl_mem pipe,
465465
acl_idle_update(pipe->context);
466466
}
467467

468+
if (pipe->host_pipe_info == NULL) {
469+
BAIL_INFO(CL_INVALID_MEM_OBJECT, pipe->context,
470+
"This pipe is not a host pipe");
471+
}
472+
468473
acl_mutex_lock(&(pipe->host_pipe_info->m_lock));
469474

470475
if (errcode_ret) {
@@ -479,12 +484,6 @@ CL_API_ENTRY void *CL_API_CALL clMapHostPipeIntelFPGA(cl_mem pipe,
479484
}
480485
*mapped_size = 0;
481486

482-
if (pipe->host_pipe_info == NULL) {
483-
acl_mutex_unlock(&(pipe->host_pipe_info->m_lock));
484-
BAIL_INFO(CL_INVALID_MEM_OBJECT, pipe->context,
485-
"This pipe is not a host pipe");
486-
}
487-
488487
if (!pipe->host_pipe_info->m_binded_kernel) {
489488
acl_mutex_unlock(&(pipe->host_pipe_info->m_lock));
490489
BAIL_INFO(CL_INVALID_KERNEL, pipe->context,
@@ -595,14 +594,14 @@ clUnmapHostPipeIntelFPGA(cl_mem pipe, void *mapped_ptr, size_t size_to_unmap,
595594
acl_idle_update(pipe->context);
596595
}
597596

598-
acl_mutex_lock(&(pipe->host_pipe_info->m_lock));
599-
600-
// Error checking
601597
if (pipe->host_pipe_info == NULL) {
602-
acl_mutex_unlock(&(pipe->host_pipe_info->m_lock));
603598
ERR_RET(CL_INVALID_MEM_OBJECT, pipe->context,
604599
"This pipe is not a host pipe");
605600
}
601+
602+
acl_mutex_lock(&(pipe->host_pipe_info->m_lock));
603+
604+
// Error checking
606605
if (!pipe->host_pipe_info->m_binded_kernel) {
607606
acl_mutex_unlock(&(pipe->host_pipe_info->m_lock));
608607
ERR_RET(CL_INVALID_KERNEL, pipe->context,

0 commit comments

Comments
 (0)