重命名线程函数和线程参数
This commit is contained in:
parent
215e1d3dea
commit
ba9b3d63d3
|
|
@ -139,12 +139,12 @@ inline int Get1DIndex(int colNum, int row, int col) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 处理一个知识颗粒 */
|
/* 处理一个知识颗粒 */
|
||||||
struct ThreadParam { // 线程参数
|
struct ThreadParamEntropy { // 线程参数
|
||||||
fs::path matFilePath;
|
fs::path matFilePath;
|
||||||
fs::path outFilePath;
|
fs::path outFilePath;
|
||||||
vector<unordered_set<string> >* pvusWord;
|
vector<unordered_set<string> >* pvusWord;
|
||||||
};
|
};
|
||||||
void ThreadProcessData(ThreadParam& param) {
|
void ThreadProcessEntropy(ThreadParamEntropy& param) {
|
||||||
const fs::path& matFilePath = param.matFilePath;
|
const fs::path& matFilePath = param.matFilePath;
|
||||||
const fs::path& outFilePath = param.outFilePath;
|
const fs::path& outFilePath = param.outFilePath;
|
||||||
vector <unordered_set<string> >& vusWord = *param.pvusWord;
|
vector <unordered_set<string> >& vusWord = *param.pvusWord;
|
||||||
|
|
@ -309,7 +309,7 @@ void CalcEntropy(int argc, const char** argv) {
|
||||||
FOREACH_PARTICLE_END
|
FOREACH_PARTICLE_END
|
||||||
|
|
||||||
// 遍历每个知识颗粒,逐一进行处理
|
// 遍历每个知识颗粒,逐一进行处理
|
||||||
vector<ThreadParam> vTP;
|
vector<ThreadParamEntropy> vTP;
|
||||||
for (int round = 0; round < 1; ++round) { // 测试用
|
for (int round = 0; round < 1; ++round) { // 测试用
|
||||||
int i = 0;
|
int i = 0;
|
||||||
FOREACH_PARTICLE_START
|
FOREACH_PARTICLE_START
|
||||||
|
|
@ -319,7 +319,7 @@ void CalcEntropy(int argc, const char** argv) {
|
||||||
i++;
|
i++;
|
||||||
FOREACH_PARTICLE_END
|
FOREACH_PARTICLE_END
|
||||||
}
|
}
|
||||||
kt_for(numThread, ThreadProcessData, vTP);
|
kt_for(numThread, ThreadProcessEntropy, vTP);
|
||||||
|
|
||||||
// synchronize
|
// synchronize
|
||||||
//thPool.~ThreadPool();
|
//thPool.~ThreadPool();
|
||||||
|
|
|
||||||
|
|
@ -141,12 +141,12 @@ double CorrelationDistance(vector<double>& vX, vector<double>& vY) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 处理一个知识颗粒 */
|
/* 处理一个知识颗粒 */
|
||||||
struct ThreadParam {
|
struct ThreadParamKP {
|
||||||
fs::path matFilePath;
|
fs::path matFilePath;
|
||||||
fs::path outFilePath;
|
fs::path outFilePath;
|
||||||
};
|
};
|
||||||
//void ThreadProcessData(vector<ThreadParam>& vTP, long idx, int tid) {
|
//void ThreadProcessData(vector<ThreadParam>& vTP, long idx, int tid) {
|
||||||
void ThreadProcessData(ThreadParam& param) {
|
void ThreadProcessKP(ThreadParamKP& param) {
|
||||||
//const ThreadParam& param = vTP[idx];
|
//const ThreadParam& param = vTP[idx];
|
||||||
const fs::path& matFilePath = param.matFilePath;
|
const fs::path& matFilePath = param.matFilePath;
|
||||||
const fs::path& outFilePath = param.outFilePath;
|
const fs::path& outFilePath = param.outFilePath;
|
||||||
|
|
@ -198,7 +198,7 @@ int main(int argc, const char** argv) {
|
||||||
//ThreadPool thPool(numThread);
|
//ThreadPool thPool(numThread);
|
||||||
clock_t begin, finish;
|
clock_t begin, finish;
|
||||||
begin = clock();
|
begin = clock();
|
||||||
vector<ThreadParam> vTP;
|
vector<ThreadParamKP> vTP;
|
||||||
/* 遍历所有的知识颗粒目录,逐一进行处理 */
|
/* 遍历所有的知识颗粒目录,逐一进行处理 */
|
||||||
for (auto& childDir : fs::directory_iterator(parrentDir)) {
|
for (auto& childDir : fs::directory_iterator(parrentDir)) {
|
||||||
fs::path outFilePath = childDir / outFileName;
|
fs::path outFilePath = childDir / outFileName;
|
||||||
|
|
@ -212,7 +212,7 @@ int main(int argc, const char** argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
kt_for(numThread, ThreadProcessData, vTP);
|
kt_for(numThread, ThreadProcessKP, vTP);
|
||||||
//thPool.~ThreadPool();
|
//thPool.~ThreadPool();
|
||||||
finish = clock();
|
finish = clock();
|
||||||
cout << "GMM Total time: " << (double)(finish - begin) / CLOCKS_PER_SEC << " s" << endl;
|
cout << "GMM Total time: " << (double)(finish - begin) / CLOCKS_PER_SEC << " s" << endl;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue