From 18a5415e59f299df83cf8eabe4da946eac7f002f Mon Sep 17 00:00:00 2001 From: zzh Date: Sat, 7 Oct 2023 04:26:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E7=BA=BF=E7=A8=8Brandsim?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MexFunc/RandSim.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/MexFunc/RandSim.cpp b/MexFunc/RandSim.cpp index 7391229..f640a9d 100644 --- a/MexFunc/RandSim.cpp +++ b/MexFunc/RandSim.cpp @@ -240,8 +240,8 @@ void ThreadRandSim(TPRandSim& param) { 输出: vr 应该是相关性数值 */ -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, mxArray** prhs) { +void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) { if (nrhs < 1) { cout << "At least 3 arguments should be given for this function!" << endl; return; @@ -326,14 +326,14 @@ void mexFunction(int nlhs, mxArray* plhs[], int nrhs, mxArray** prhs) { } } - //ThreadPool thPool(numThread); + ThreadPool thPool(numThread); int tid = 0; for (int i = 0; i < loopNum; ++i) { TPRandSim tParam = { &vvZr[i], &vvRandPos[tid++ % numThread], &umWordPos, &vvWd2, vvWd.size()}; - //thPool.enqueue(ThreadRandSim, tParam); - ThreadRandSim(tParam); + thPool.enqueue(ThreadRandSim, tParam); + //ThreadRandSim(tParam); } - //thPool.~ThreadPool(); + thPool.~ThreadPool(); finish = clock(); cout << "Random simulation time: " << (double)(finish - mid) / CLOCKS_PER_SEC << " s" << endl;