C++ use SSE instructions for comparing huge vectors of ints
问题 I have a huge vector<vector<int>> (18M x 128). Frequently I want to take 2 rows of this vector and compare them by this function: int getDiff(int indx1, int indx2) { int result = 0; int pplus, pminus, tmp; for (int k = 0; k < 128; k += 2) { pplus = nodeL[indx2][k] - nodeL[indx1][k]; pminus = nodeL[indx1][k + 1] - nodeL[indx2][k + 1]; tmp = max(pplus, pminus); if (tmp > result) { result = tmp; } } return result; } As you see, the function, loops through the two row vectors does some