29 #include <tbb/queuing_rw_mutex.h> 33 tbb::queuing_rw_mutex libmutex;
35 void unload_dfe_lib_unlocked();
36 int init_dfe_lib_unlocked(
const int accelerator_num,
int qbit_num,
int initialize_id_in);
37 void uploadMatrix2DFE_unlocked(
Matrix& input);
62 lock.acquire(libmutex,
false);
77 tbb::queuing_rw_mutex::scoped_lock lock(libmutex,
true);
78 uploadMatrix2DFE_unlocked(input);
84 void uploadMatrix2DFE_unlocked(
Matrix& input ) {
86 std::cout <<
"size in bytes of uploading to DFE: " << input.
size()*2*
sizeof(float) << std::endl;
94 void unload_dfe_lib_unlocked()
112 tbb::queuing_rw_mutex::scoped_lock lock(libmutex,
true);
113 unload_dfe_lib_unlocked();
130 tbb::queuing_rw_mutex::scoped_lock lock(libmutex,
true);
131 return init_dfe_lib_unlocked(accelerator_num, qbit_num, initialize_id_in);
137 int init_dfe_lib_unlocked(
const int accelerator_num,
int qbit_num,
int initialize_id_in ) {
139 initialize_id = initialize_id_in;
142 unload_dfe_lib_unlocked();
146 std::string lib_name = getenv(
"SLIC_CONF") ?
DFE_LIB_SIM : lib_name_DFE;
149 handle = dlopen(lib_name.c_str(), RTLD_NOW);
150 if (
handle == NULL && qbit_num == 10 && !getenv(
"SLIC_CONF")) {
155 std::string err(
"init_dfe_lib: failed to load library " + lib_name +
" - " + std::string(dlerror()));
179 tbb::queuing_rw_mutex::scoped_lock lock(libmutex,
true);
180 if (initialize_id != initialize_id_in) {
181 init_dfe_lib_unlocked(accelerator_num, qbit_num, initialize_id_in);
183 uploadMatrix2DFE_unlocked(input);
int get_chained_gates_num()
Call to retrieve the number of gates that should be chained up during the execution of the DFE librar...
int(* load2LMEM_dll)(QGD_Complex16 *data, size_t rows, size_t cols)
void(* releive_DFE_dll)()
void uploadMatrix2DFE(Matrix &input)
Call to upload the input matrix to the DFE engine.
QGD_Complex8 * data
pointer to the stored data
int(* initialize_DFE_dll)(int accelerator_num)
scalar * get_data() const
Call to get the pointer to the stored data.
void init_dfe_lib_and_upload(const int accelerator_num, int qbit_num, int initialize_id_in, Matrix &input)
Initialize the DFE library if needed and upload the input matrix while holding the writer lock...
int init_dfe_lib(const int accelerator_num, int qbit_num, int initialize_id_in)
Call to initialize the DFE library support and allocate the requested devices.
int rows
The number of rows.
int cols
The number of columns.
size_t(* get_accelerator_avail_num_dll)()
int(* calcqgdKernelDFE_dll)(size_t rows, size_t cols, DFEgate_kernel_type *gates, int gatesNum, int gateSetNum, int traceOffset, double *trace)
Structure type representing complex numbers in the SQUANDER package.
Double-precision complex matrix (float64).
int size() const
Call to get the number of the allocated elements.
int get_initialize_id()
Call to get the identification number of the inititalization of the library.
Fixed point data related to a gate operation.
void unload_dfe_lib()
Call to unload the DFE libarary and release the allocated devices.
int calcqgdKernelDFE(size_t rows, size_t cols, DFEgate_kernel_type *gates, int gatesNum, int gateSetNum, int traceOffset, double *trace)
Call to execute the calculation on the reserved DFE engines.
size_t get_accelerator_avail_num()
Call to get the available number of accelerators.
Header file for DFE support in unitary simulation.
size_t get_accelerator_free_num()
Call to get the number of free accelerators.
size_t(* get_accelerator_free_num_dll)()
int(* get_chained_gates_num_dll)()