2022-05-26 12:37

c++ 11并行运算结果不对问题，求解答

int g_matrix[RANK_NUM][COL_NUM] = {
{ 0, 1, -1, 2, -2},
{ 1, 1, 1, 0, blank},
{ -1, 1, -1, bank, 0},
{ 2, 0, bank, bank, NK},
{ -2, BNK, BAN, ANK, K}
};
//原始矩阵，blank为待填入值的位置

int g_padVal[VAL_NUM] = {0, 1, -1, 2, -2};
//待填入的值范围

//uncertainValPosVec为待填入元素的下标列表，Pos的定义为行下标和列下标的结构体
{
Pos firstPos = uncertainValPosVec[0];
uncertainValPosVec.erase(uncertainValPosVec.begin());
Pos secondPos = uncertainValPosVec[0];
uncertainValPosVec.erase(uncertainValPosVec.begin());
int num = 0;
while (true)
{
for(; num < VAL_NUM * VAL_NUM; num++)
{
int matrix[RANK_NUM][COL_NUM];
memcpy(matrix, oriMatrix, sizeof(int) * RANK_NUM * COL_NUM);
vector tmp = uncertainValPosVec;
}
{
break;
}
}
}

{
CHECK_RET_RETURN_NULL(matrix == NULL)
CHECK_RET_RETURN_NULL(pUncertainValPosVec == NULL)
int oriMatrix[RANK_NUM][COL_NUM] = {{0}};
memcpy(oriMatrix, matrix, sizeof(int) * RANK_NUM * COL_NUM);
vector uncertainValPosVec = *(vector *)(pUncertainValPosVec);
//cout << "PadMatrixValByRule uncertainValPosVec = " << uncertainValPosVec.size() << endl;
if(uncertainValPosVec.empty())
{
BOOLEAN sentinal = IsMatrixAssociation(oriMatrix);
if(TRUE == sentinal)
{
cout << "find one matrix = " << endl;
PrintMatrix(oriMatrix);
}
}
else
{
Pos pos;
pos.rank = uncertainValPosVec[0].rank;
pos.col = uncertainValPosVec[0].col;
uncertainValPosVec.erase(uncertainValPosVec.begin());
int matrix[RANK_NUM][COL_NUM];
memcpy(matrix, oriMatrix, sizeof(int) * RANK_NUM * COL_NUM);
for(int i = 0; i < VAL_NUM; i++)
{
}
}
}

BOOLEAN IsMatrixAssociation(int matrix[RANK_NUM][COL_NUM])
{
g_mutex.lock();
g_countNum++;
if(0 == g_countNum % 10000)
{
cout << "g_countNum = " << g_countNum << endl;
}
g_mutex.unlock();

``````return TRUE;
``````

}

{
while (true)
{
{
future tempFuture = async(launch::async, func, matrix, vec);
break;
}
else
{
{
{
break;
}
}
}
}
}

{
{
{
break;
}
}
{
return true;
}
return false;
}

• 写回答
• 好问题 提建议
• 追加酬金
• 关注问题
• 邀请回答