Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
239 views
in Technique[技术] by (71.8m points)

c - omp parallel for takes more time than serial code

inside activateNN fuction if you uncomment the #pragma omp, it runs 2 time slower on my machine, i even have tried to parallelize different more simple parts of my code but still it take more time

void activateNN(double* Vector){
    int i = 0;
    int y = 0;
    
    
    //#pragma omp parallel for private(i)
    for (i = 0; i < L1; i++) {
        
        OL1[i] = 0;
        for (y = 0; y < N; y++)
            OL1[i] += WL1[i][y] * Vector[y];
        OL1[i] += WL1[i][N];
        OL1[i] = activation_Sigmoid(OL1[i]);
    }
    
    
    for (i = 0; i < L2; i++) {
        
        OL2[i] = 0;
        for (y = 0; y < L1; y++)
            OL2[i] += WL2[i][y] * OL1[y];
        OL2[i] += WL2[i][L1];
        OL2[i] = activation_Sigmoid(OL2[i]);
    }
}


question from:https://stackoverflow.com/questions/66050836/omp-parallel-for-takes-more-time-than-serial-code

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...