Skip to content

Commit f0f1d75

Browse files
authored
[fix, build] Remove -fno-threadsafe-statics option to guarantee hw initialization thread-safety (#636)
* reverted to using thread-safe statics to make sure Singleton works as expected (thread-safe) * removed limitation notice * added note w.r.t c++17 standard and c++ runtime
1 parent a343810 commit f0f1d75

File tree

7 files changed

+18
-31
lines changed

7 files changed

+18
-31
lines changed

cmake/CompileOptions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
set(QPL_LINUX_TOOLCHAIN_REQUIRED_FLAGS "-Wall;-Wextra;-fPIC;-fstack-protector;-fstack-protector-strong;-fstack-clash-protection;--param=ssp-buffer-size=4")
88
set(QPL_LINUX_TOOLCHAIN_DYNAMIC_LIBRARY_FLAGS "-Wl,-z,relro,-z,now;-Wl,-z,noexecstack")
9-
set(QPL_LINUX_TOOLCHAIN_CPP_EMBEDDED_FLAGS "-fno-exceptions;-fno-rtti;-fno-threadsafe-statics")
9+
set(QPL_LINUX_TOOLCHAIN_CPP_EMBEDDED_FLAGS "-fno-exceptions;-fno-rtti")
1010

1111
set(QPL_WINDOWS_TOOLCHAIN_REQUIRED_FLAGS "/W3;/WX;/GS")
1212
set(QPL_WINDOWS_TOOLCHAIN_DYNAMIC_LIBRARY_FLAGS "")

doc/source/documentation/get_started_docs/installation.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ Before building Intel® QPL, install and set up the following tools:
9898

9999
- nasm 2.15.0 or higher (e.g., can be obtained from https://www.nasm.us)
100100

101-
- GCC 8.2 or higher (Clang 12.0.1 or higher for building fuzz tests)
101+
- Intel QPL requires C++ compiler with C++17 standard support.
102+
For instance, GCC 8.2+ (or Clang 12.0.1+ for building fuzz tests).
102103

103104
- Universally Unique ID library ``uuid-dev`` version 2.35.2 or higher
104105

doc/source/documentation/get_started_docs/quick_start.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ Alternatively, in order to build ``compression_example.cpp`` individually using
6363
6464
g++ -I/<install_dir>/include -o compression_example compression_example.cpp /<install_dir>/lib64/libqpl.a -ldl
6565
66+
.. attention::
67+
68+
Intel QPL could be also used from C applications.
69+
This would still require C++ runtime library installed on the system, and adding `-lstdc++`.
70+
6671
To run the example on the Hardware Path, use:
6772

6873
.. code-block:: shell

include/qpl/c_api/job.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,8 @@ QPL_API(qpl_status, qpl_get_job_size, (qpl_path_t qpl_path, uint32_t * job_size_
164164
* @ref qpl_path_hardware or @ref qpl_path_software
165165
* @param[in,out] qpl_job_ptr a pointer to the @ref qpl_job structure
166166
*
167-
* @warning If multiple processes are created to submit jobs to the accelerator in the same application,
168-
* forking child process(es) must be done before the first @ref qpl_init_job function with @ref qpl_path_hardware.
169-
* Otherwise, the child process(es) may crash.
170-
*
171167
* @warning Memory for qpl_job structure must be allocated at the application side. Size (in bytes)
172-
* must be obtained with the @ref qpl_get_job_size function and then type-casted to @ref qpl_job :
173-
*
174-
* @code
175-
* uint32_t size;
176-
* qpl_job *qpl_job_ptr;
177-
* status = qpl_get_job_size(&size);
178-
* qpl_job_ptr = (qpl_job*)malloc(size);
179-
* @endcode
168+
* must be obtained with the @ref qpl_get_job_size function.
180169
*
181170
* @note qpl_job is an alias to the @ref qpl_job structure - must contain additional internal memory buffers for
182171
* SW path of compression/decompression/etc.

sources/core-iaa/include/hw_iaa_flags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ typedef uint64_t hw_operation_flags_t; /**< Represents operation's flags */
1717

1818
/* ################# COMPRESSION FLAGS ################# */
1919
/**
20-
* @name Operation codes
20+
* @name Operation codes for Intel® In-Memory Analytics Accelerator (Intel® IAA)
2121
* @anchor HW_OPCODES
2222
* @todo Opcode values
2323
* @{

sources/core-iaa/sources/descriptors/hw_crc64_descriptor.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
#include "qplc_memop.h"
1414

1515
/**
16-
* @brief Defines a type of the Intel IAA crc64 descriptor
16+
* @brief Defines a type of the Intel® In-Memory Analytics Accelerator (Intel® IAA)
17+
* crc64 descriptor
1718
*/
1819
HW_PATH_BYTE_PACKED_STRUCTURE_BEGIN {
1920
uint32_t trusted_fields; /**< 19:0 PASID - process address space ID; 30:20 - reserved; 31 - User/Supervisor */

sources/middle-layer/dispatcher/hw_dispatcher.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,9 @@
2020

2121
namespace qpl::ml::dispatcher {
2222

23-
24-
static int is_initialized = 0;
25-
static std::mutex hw_init_lock;
26-
2723
hw_dispatcher::hw_dispatcher() noexcept {
28-
if (!is_initialized) {
29-
hw_init_lock.lock();
30-
if (!is_initialized) {
31-
hw_init_status_ = hw_dispatcher::initialize_hw();
32-
hw_support_ = hw_init_status_ == HW_ACCELERATOR_STATUS_OK;
33-
34-
is_initialized = 1;
35-
}
36-
hw_init_lock.unlock();
37-
}
24+
hw_init_status_ = hw_dispatcher::initialize_hw();
25+
hw_support_ = hw_init_status_ == HW_ACCELERATOR_STATUS_OK;
3826
}
3927

4028
auto hw_dispatcher::initialize_hw() noexcept -> hw_accelerator_status {
@@ -100,9 +88,12 @@ hw_dispatcher::~hw_dispatcher() noexcept {
10088
#endif
10189
}
10290

91+
// starting from C++11 standard,
92+
// it is guarantued that the following would be thread-safe
93+
// and created only once
94+
// (case: static variables with block scope)
10395
auto hw_dispatcher::get_instance() noexcept -> hw_dispatcher & {
10496
static hw_dispatcher instance{};
105-
10697
return instance;
10798
}
10899

0 commit comments

Comments
 (0)