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