多线程randsim
This commit is contained in:
parent
c9393a54e3
commit
18a5415e59
|
|
@ -240,8 +240,8 @@ void ThreadRandSim(TPRandSim& param) {
|
||||||
输出:
|
输出:
|
||||||
vr 应该是相关性数值
|
vr 应该是相关性数值
|
||||||
*/
|
*/
|
||||||
void mexFunction(int nlhs, mxArray* plhs[], int nrhs, mxArray** prhs) {
|
//void mexFunction(int nlhs, mxArray* plhs[], int nrhs, mxArray** prhs) {
|
||||||
//void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
|
void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
|
||||||
if (nrhs < 1) {
|
if (nrhs < 1) {
|
||||||
cout << "At least 3 arguments should be given for this function!" << endl;
|
cout << "At least 3 arguments should be given for this function!" << endl;
|
||||||
return;
|
return;
|
||||||
|
|
@ -326,14 +326,14 @@ void mexFunction(int nlhs, mxArray* plhs[], int nrhs, mxArray** prhs) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//ThreadPool thPool(numThread);
|
ThreadPool thPool(numThread);
|
||||||
int tid = 0;
|
int tid = 0;
|
||||||
for (int i = 0; i < loopNum; ++i) {
|
for (int i = 0; i < loopNum; ++i) {
|
||||||
TPRandSim tParam = { &vvZr[i], &vvRandPos[tid++ % numThread], &umWordPos, &vvWd2, vvWd.size()};
|
TPRandSim tParam = { &vvZr[i], &vvRandPos[tid++ % numThread], &umWordPos, &vvWd2, vvWd.size()};
|
||||||
//thPool.enqueue(ThreadRandSim, tParam);
|
thPool.enqueue(ThreadRandSim, tParam);
|
||||||
ThreadRandSim(tParam);
|
//ThreadRandSim(tParam);
|
||||||
}
|
}
|
||||||
//thPool.~ThreadPool();
|
thPool.~ThreadPool();
|
||||||
finish = clock();
|
finish = clock();
|
||||||
cout << "Random simulation time: " << (double)(finish - mid) / CLOCKS_PER_SEC << " s" << endl;
|
cout << "Random simulation time: " << (double)(finish - mid) / CLOCKS_PER_SEC << " s" << endl;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue