Compare commits
4 Commits
8e96750046
...
78f79d92aa
| Author | SHA1 | Date | |
|---|---|---|---|
| 78f79d92aa | |||
| f09fe03e0d | |||
| 8e18ec15c9 | |||
| 4340f5444d |
@@ -240,8 +240,8 @@ void PIBroadcast::stopRead() {
|
|||||||
if (isRunning()) stopAndWait();
|
if (isRunning()) stopAndWait();
|
||||||
PIMutexLocker ml(mcast_mutex);
|
PIMutexLocker ml(mcast_mutex);
|
||||||
for (auto * e: eth_mcast)
|
for (auto * e: eth_mcast)
|
||||||
e->stopAndWait();
|
e->stopAndWait(5_s);
|
||||||
if (eth_lo) eth_lo->stopAndWait();
|
if (eth_lo) eth_lo->stopAndWait(5_s);
|
||||||
_started = false;
|
_started = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ bool PIBinaryLog::threadedRead(const uchar * readed, ssize_t size) {
|
|||||||
is_thread_ok = false;
|
is_thread_ok = false;
|
||||||
logmutex.lock();
|
logmutex.lock();
|
||||||
const PISystemTime lastrec_timestamp = lastrecord.timestamp;
|
const PISystemTime lastrec_timestamp = lastrecord.timestamp;
|
||||||
|
const int lastrec_id = lastrecord.id;
|
||||||
logmutex.unlock();
|
logmutex.unlock();
|
||||||
PISystemTime pt;
|
PISystemTime pt;
|
||||||
double delay;
|
double delay;
|
||||||
@@ -248,7 +249,8 @@ bool PIBinaryLog::threadedRead(const uchar * readed, ssize_t size) {
|
|||||||
break;
|
break;
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
bool res = PIIODevice::threadedRead(readed, size);
|
bool res = PIIODevice::threadedRead(readed, size);
|
||||||
|
threadedReadRecord(PIByteArray(readed, size), lastrec_id, lastrec_timestamp);
|
||||||
is_thread_ok = true;
|
is_thread_ok = true;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -327,6 +327,7 @@ public:
|
|||||||
EVENT(fileError);
|
EVENT(fileError);
|
||||||
EVENT1(newFile, const PIString &, filename);
|
EVENT1(newFile, const PIString &, filename);
|
||||||
EVENT1(posChanged, int, pos);
|
EVENT1(posChanged, int, pos);
|
||||||
|
EVENT3(threadedReadRecord, PIByteArray, data, int, id, PISystemTime, time);
|
||||||
|
|
||||||
//! Get binlog info and statistic
|
//! Get binlog info and statistic
|
||||||
static BinLogInfo getLogInfo(const PIString & path);
|
static BinLogInfo getLogInfo(const PIString & path);
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ public:
|
|||||||
//! \~russian Перегруженный оператор для вывода координат в \a PICout.
|
//! \~russian Перегруженный оператор для вывода координат в \a PICout.
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
PICout operator<<(PICout & s, const PILine<Type> & v) {
|
PICout operator<<(PICout & s, const PILine<Type> & v) {
|
||||||
|
s.space();
|
||||||
s.saveAndSetControls(0);
|
s.saveAndSetControls(0);
|
||||||
s << "Line{" << v.p0 << ", " << v.p1 << "}";
|
s << "Line{" << v.p0 << ", " << v.p1 << "}";
|
||||||
s.restoreControls();
|
s.restoreControls();
|
||||||
|
|||||||
@@ -771,6 +771,8 @@ inline std::ostream & operator<<(std::ostream & s, const PIMathMatrixT<Rows, Col
|
|||||||
//! \return непечатанная в консоль \a PICout.
|
//! \return непечатанная в консоль \a PICout.
|
||||||
template<uint Rows, uint Cols, typename Type>
|
template<uint Rows, uint Cols, typename Type>
|
||||||
inline PICout operator<<(PICout s, const PIMathMatrixT<Rows, Cols, Type> & m) {
|
inline PICout operator<<(PICout s, const PIMathMatrixT<Rows, Cols, Type> & m) {
|
||||||
|
s.space();
|
||||||
|
s.saveAndSetControls(0);
|
||||||
s << "{";
|
s << "{";
|
||||||
for (uint r = 0; r < Rows; ++r) {
|
for (uint r = 0; r < Rows; ++r) {
|
||||||
for (uint c = 0; c < Cols; ++c) {
|
for (uint c = 0; c < Cols; ++c) {
|
||||||
@@ -780,6 +782,7 @@ inline PICout operator<<(PICout s, const PIMathMatrixT<Rows, Cols, Type> & m) {
|
|||||||
if (r < Rows - 1) s << PICoutManipulators::NewLine << " ";
|
if (r < Rows - 1) s << PICoutManipulators::NewLine << " ";
|
||||||
}
|
}
|
||||||
s << "}";
|
s << "}";
|
||||||
|
s.restoreControls();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1465,6 +1468,8 @@ inline std::ostream & operator<<(std::ostream & s, const PIMathMatrix<Type> & m)
|
|||||||
//! \return непечатанная в консоль \a PICout.
|
//! \return непечатанная в консоль \a PICout.
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
inline PICout operator<<(PICout s, const PIMathMatrix<Type> & m) {
|
inline PICout operator<<(PICout s, const PIMathMatrix<Type> & m) {
|
||||||
|
s.space();
|
||||||
|
s.saveAndSetControls(0);
|
||||||
s << "Matrix{";
|
s << "Matrix{";
|
||||||
for (uint r = 0; r < m.rows(); ++r) {
|
for (uint r = 0; r < m.rows(); ++r) {
|
||||||
for (uint c = 0; c < m.cols(); ++c) {
|
for (uint c = 0; c < m.cols(); ++c) {
|
||||||
@@ -1474,6 +1479,7 @@ inline PICout operator<<(PICout s, const PIMathMatrix<Type> & m) {
|
|||||||
if (r < m.rows() - 1) s << PICoutManipulators::NewLine << " ";
|
if (r < m.rows() - 1) s << PICoutManipulators::NewLine << " ";
|
||||||
}
|
}
|
||||||
s << "}";
|
s << "}";
|
||||||
|
s.restoreControls();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -333,12 +333,15 @@ inline PIMathVectorT<Size, Type> operator*(const Type & x, const PIMathVectorT<S
|
|||||||
|
|
||||||
template<uint Size, typename Type>
|
template<uint Size, typename Type>
|
||||||
inline PICout operator<<(PICout s, const PIMathVectorT<Size, Type> & v) {
|
inline PICout operator<<(PICout s, const PIMathVectorT<Size, Type> & v) {
|
||||||
|
s.space();
|
||||||
|
s.saveAndSetControls(0);
|
||||||
s << "Vector{";
|
s << "Vector{";
|
||||||
PIMV_FOR {
|
PIMV_FOR {
|
||||||
s << v[i];
|
s << v[i];
|
||||||
if (i < Size - 1) s << ", ";
|
if (i < Size - 1) s << ", ";
|
||||||
}
|
}
|
||||||
s << "}";
|
s << "}";
|
||||||
|
s.restoreControls();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -611,12 +614,15 @@ inline std::ostream & operator<<(std::ostream & s, const PIMathVector<Type> & v)
|
|||||||
|
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
inline PICout operator<<(PICout s, const PIMathVector<Type> & v) {
|
inline PICout operator<<(PICout s, const PIMathVector<Type> & v) {
|
||||||
|
s.space();
|
||||||
|
s.saveAndSetControls(0);
|
||||||
s << "Vector{";
|
s << "Vector{";
|
||||||
for (uint i = 0; i < v.size(); ++i) {
|
for (uint i = 0; i < v.size(); ++i) {
|
||||||
s << v[i];
|
s << v[i];
|
||||||
if (i < v.size() - 1) s << ", ";
|
if (i < v.size() - 1) s << ", ";
|
||||||
}
|
}
|
||||||
s << "}";
|
s << "}";
|
||||||
|
s.restoreControls();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ public:
|
|||||||
//! \~russian Перегруженный оператор для вывода координат в \a PICout.
|
//! \~russian Перегруженный оператор для вывода координат в \a PICout.
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
PICout operator<<(PICout & s, const PIPoint<Type> & v) {
|
PICout operator<<(PICout & s, const PIPoint<Type> & v) {
|
||||||
|
s.space();
|
||||||
s.saveAndSetControls(0);
|
s.saveAndSetControls(0);
|
||||||
s << "Point{" << v.x << ", " << v.y << "}";
|
s << "Point{" << v.x << ", " << v.y << "}";
|
||||||
s.restoreControls();
|
s.restoreControls();
|
||||||
|
|||||||
@@ -360,6 +360,7 @@ private:
|
|||||||
|
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
PICout operator<<(PICout & s, const PIRect<Type> & v) {
|
PICout operator<<(PICout & s, const PIRect<Type> & v) {
|
||||||
|
s.space();
|
||||||
s.saveAndSetControls(0);
|
s.saveAndSetControls(0);
|
||||||
s << "Rect{" << v.bottomLeft() << ":" << v.width() << "x" << v.height() << "}";
|
s << "Rect{" << v.bottomLeft() << ":" << v.width() << "x" << v.height() << "}";
|
||||||
s.restoreControls();
|
s.restoreControls();
|
||||||
|
|||||||
@@ -228,9 +228,11 @@ public:
|
|||||||
void copyToContainer();
|
void copyToContainer();
|
||||||
void copyTo(void * data);
|
void copyTo(void * data);
|
||||||
void copyTo(void * data, int elements_count, int elements_offset = 0);
|
void copyTo(void * data, int elements_count, int elements_offset = 0);
|
||||||
|
void copyTo(Buffer * buffer, int elements_count = -1, int elements_from_offset = 0, int elements_to_offset = 0);
|
||||||
void copyFromContainer();
|
void copyFromContainer();
|
||||||
void copyFrom(void * data);
|
void copyFrom(void * data);
|
||||||
void copyFrom(void * data, int elements_count, int elements_offset = 0);
|
void copyFrom(void * data, int elements_count, int elements_offset = 0);
|
||||||
|
void copyFrom(Buffer * buffer, int elements_count = -1, int elements_from_offset = 0, int elements_to_offset = 0);
|
||||||
uint elementsCount() const { return elements; }
|
uint elementsCount() const { return elements; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -244,6 +246,7 @@ public:
|
|||||||
void zero();
|
void zero();
|
||||||
bool init();
|
bool init();
|
||||||
void * containerData();
|
void * containerData();
|
||||||
|
static void copy(Buffer * buffer_from, Buffer * buffer_to, int elements_count, int elements_from_offset, int elements_to_offset);
|
||||||
Context * context_;
|
Context * context_;
|
||||||
Direction dir;
|
Direction dir;
|
||||||
Container type;
|
Container type;
|
||||||
|
|||||||
@@ -240,11 +240,17 @@ PIOpenCL::Program * PIOpenCL::Context::createProgram(const PIString & source, co
|
|||||||
if (error) (*error) = "Empty program!";
|
if (error) (*error) = "Empty program!";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
PIString src_text = PRIVATE->complex_src + source;
|
static PIString double_ext = "#ifdef cl_khr_fp64\n\
|
||||||
const char * csrc = src_text.dataAscii();
|
#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n\
|
||||||
size_t src_size = src_text.size();
|
#elif defined(cl_amd_fp64)\n\
|
||||||
cl_int ret = 0;
|
#pragma OPENCL EXTENSION cl_amd_fp64 : enable\n\
|
||||||
cl_program prog = clCreateProgramWithSource(PRIVATE->context, 1, &csrc, &src_size, &ret);
|
#else\n\
|
||||||
|
#endif\n";
|
||||||
|
PIString src_text = PRIVATE->complex_src + double_ext + source;
|
||||||
|
const char * csrc = src_text.dataAscii();
|
||||||
|
size_t src_size = src_text.size();
|
||||||
|
cl_int ret = 0;
|
||||||
|
cl_program prog = clCreateProgramWithSource(PRIVATE->context, 1, &csrc, &src_size, &ret);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
piCout << "[PIOpenCL::Context]"
|
piCout << "[PIOpenCL::Context]"
|
||||||
<< "clCreateProgramWithSource error" << ret;
|
<< "clCreateProgramWithSource error" << ret;
|
||||||
@@ -429,6 +435,11 @@ void PIOpenCL::Buffer::copyTo(void * data, int elements_count, int elements_offs
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIOpenCL::Buffer::copyTo(Buffer * buffer, int elements_count, int elements_from_offset, int elements_to_offset) {
|
||||||
|
copy(this, buffer, elements_count, elements_from_offset, elements_to_offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIOpenCL::Buffer::copyFromContainer() {
|
void PIOpenCL::Buffer::copyFromContainer() {
|
||||||
if (!PRIVATE->buffer || !container) return;
|
if (!PRIVATE->buffer || !container) return;
|
||||||
copyFrom(containerData());
|
copyFrom(containerData());
|
||||||
@@ -445,12 +456,12 @@ void PIOpenCL::Buffer::copyFrom(void * data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIOpenCL::Buffer::copyFrom(void * data, int elements_count, int elements_offset) {
|
void PIOpenCL::Buffer::copyFrom(void * data, int elements_count, int elements_from_offset) {
|
||||||
if (!PRIVATE->buffer) return;
|
if (!PRIVATE->buffer) return;
|
||||||
cl_int ret = clEnqueueWriteBuffer(context_->PRIVATEWB->queue,
|
cl_int ret = clEnqueueWriteBuffer(context_->PRIVATEWB->queue,
|
||||||
PRIVATE->buffer,
|
PRIVATE->buffer,
|
||||||
CL_TRUE,
|
CL_TRUE,
|
||||||
elements_offset * def.size(),
|
elements_from_offset * def.size(),
|
||||||
elements_count * def.size(),
|
elements_count * def.size(),
|
||||||
data,
|
data,
|
||||||
0,
|
0,
|
||||||
@@ -463,6 +474,35 @@ void PIOpenCL::Buffer::copyFrom(void * data, int elements_count, int elements_of
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIOpenCL::Buffer::copyFrom(Buffer * buffer, int elements_count, int elements_from_offset, int elements_to_offset) {
|
||||||
|
copy(buffer, this, elements_count, elements_to_offset, elements_from_offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIOpenCL::Buffer::copy(Buffer * buffer_from,
|
||||||
|
Buffer * buffer_to,
|
||||||
|
int elements_count,
|
||||||
|
int elements_from_offset,
|
||||||
|
int elements_to_offset) {
|
||||||
|
if (!buffer_from || !buffer_to) return;
|
||||||
|
if (!buffer_from->PRIVATEWB->buffer || !buffer_to->PRIVATEWB->buffer) return;
|
||||||
|
if (elements_count < 0) elements_count = piMini(buffer_from->elements, buffer_to->elements);
|
||||||
|
cl_int ret = clEnqueueCopyBuffer(buffer_from->context_->PRIVATEWB->queue,
|
||||||
|
buffer_from->PRIVATEWB->buffer,
|
||||||
|
buffer_to->PRIVATEWB->buffer,
|
||||||
|
elements_from_offset * buffer_from->def.size(),
|
||||||
|
elements_to_offset * buffer_to->def.size(),
|
||||||
|
elements_count * buffer_from->def.size(),
|
||||||
|
0,
|
||||||
|
nullptr,
|
||||||
|
nullptr);
|
||||||
|
if (ret != 0) {
|
||||||
|
piCout << "[PIOpenCL::Buffer]"
|
||||||
|
<< "clEnqueueCopyBuffer error" << ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PIOpenCL::Program::Program() {
|
PIOpenCL::Program::Program() {
|
||||||
// piCout << "new program" << this;
|
// piCout << "new program" << this;
|
||||||
zero();
|
zero();
|
||||||
|
|||||||
Reference in New Issue
Block a user