Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
291 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...