How to divide the work into group of threads using OpenMP

How to divide the work into group of threads using OpenMP

I have the follwoing code , the commented line is a description of the process, I want to distribute the work into group of threads. In case my architecture is MIC. I have 224 thread I want to to distribute them as 14 group each group with 16 thread. How can I do it using OpenMP . Also , How can I synchronize between them that the group finshed its work.

    //addMatrices(a11,a22,t1,newsize);
    //addMatrices(b11,b22,t2,newsize);
   // strassenMultMatrix(t1,t2,c21,newsize);
    addMatrices(a,a,t1,newsize,srow1,scol1,newsize+srow1,newsize+scol1,DIM0,DIM0,newsize);
//myprint(a,"print a11",newsize,srow1,scol1,size);
//myprint(a,"print a22",newsize,newsize+srow1,newsize+scol1,size);
//myprint(t1,"addition result of a11,a22",newsize,0,0,newsize);
    addMatrices(b,b,t2,newsize,srow2,scol2,newsize+srow2,newsize+scol2,DIM1,DIM1,newsize);
//myprint(t2,"addition result of b11,b22",newsize,0,0,newsize);
    strassenMultMatrix(t1,t2,c,newsize,0,0,0,0,newsize+srow3,scol3,newsize,newsize,DIM2);
//myprint(c,"Result Matrix of t1*t2 calculate M1",newsize,newsize+srow3,scol3,DIM2);
//myprint(c,"All C matrix",DIM2,0,0,DIM2);

   // subMatrices(a21,a11,t1,newsize);
    subMatrices(a,a,t1,newsize,newsize+srow1,scol1,srow1,scol1,DIM0,DIM0,newsize);
//myprint(t1,"subtraction of a21,a11 ",newsize,0,0,newsize);

    //addMatrices(b11,b12,t2,newsize);
    addMatrices(b,b,t2,newsize,srow2,scol2,srow2,newsize+scol2,DIM1,DIM1,newsize);
//myprint(t2,"addition of b11,b12",newsize,0,0,newsize);

    //strassenMultMatrix(t1,t2,c22,newsize);
    strassenMultMatrix(t1,t2,c,newsize,0,0,0,0,newsize+srow3,newsize+scol3,newsize,newsize,DIM2);//Calculate M6
//myprint(c,"Calculate M6 t1*t2",newsize,newsize+srow3,newsize+scol3,DIM2);
//myprint(c,"All C matrix",DIM2,0,0,DIM2);
//###################################################################################Until here the operation is right
    //subMatrices(a12,a22,t1,newsize);
    subMatrices(a,a,t1,newsize,srow1,newsize+srow1,newsize+srow1,newsize+scol1,DIM0,DIM0,newsize);
//myprint(t1,"subtration a12,a22",newsize,0,0,newsize);
    //addMatrices(b21,b22,t2,newsize);
    addMatrices(b,b,t2,newsize,newsize+srow2,scol2,newsize+srow2,newsize+scol2,DIM1,DIM1,newsize);
//myprint(t2,"addition b21,b22",newsize,0,0,newsize);
    //strassenMultMatrix(t1,t2,c11,newsize);
    strassenMultMatrix(t1,t2,c,newsize,0,0,0,0,srow3,scol3,newsize,newsize,DIM2);//calculate M7
//myprint(c,"calculate M7 t1*t2",newsize,srow3,scol3,DIM2);
//myprint(c,"All C matrix",DIM2,0,0,DIM2);
//################################################################################Until Here the operation is right

// Need to define another addition function to make it possible to done
    //addMatrices(c11,c21,c11,newsize);
    addMatricesc(c,c,c,newsize,srow3,scol3,newsize+srow3,scol3,srow3,scol3,DIM2,DIM2,DIM2);
//myprint(c,"Problem Submatrix c11",newsize,srow3,scol3,DIM2);
//myprint(c,"Problem Submatrix c21",newsize,newsize+srow3,scol3,DIM2);
//myprint(c,"Addition the problem Start here C's sub matrix c11 , c21",newsize,srow3,scol3,DIM2);

    //addMatrices(c21,c22,c22,newsize);
    addMatricesc(c,c,c,newsize,newsize+srow3,scol3,newsize+srow3,newsize+scol3,newsize+srow3,newsize+scol3,DIM2,DIM2,DIM2);
//myprint(c,"Addition C's sub matrix of c21,c22",newsize,newsize+srow3,newsize+scol3,DIM2);
//myprint(c,"All C matrix",DIM2,0,0,DIM2);

//####################################################################################
    //addMatrices(a21,a22,t1,newsize);
    addMatrices(a,a,t1,newsize,newsize+srow1,scol1,newsize+srow1,newsize+scol1,DIM0,DIM0,newsize);
//myprint(t1,"Additon a21 , a22",newsize,0,0,newsize);

    //strassenMultMatrix(t1,b11,c21,newsize);
    strassenMultMatrix(t1,b,c,newsize,0,0,srow2,scol2,newsize+srow3,scol3,newsize,DIM1,DIM2); // Compute M2
//myprint(c,"Calculate M2 t1*b11",newsize,newsize+srow3,scol3,DIM2);
//myprint(c,"All C matrix",DIM2,0,0,DIM2);

    //subMatrices(b12,b22,t2,newsize);
    subMatrices(b,b,t2,newsize,srow2,newsize+scol2,newsize+srow2,newsize+scol2,DIM1,DIM1,newsize);
//myprint(t2,"Subtration b12,b22",newsize,0,0,newsize);
    //strassenMultMatrix(a11,t2,c12,newsize)
    strassenMultMatrix(a,t2,c,newsize,srow1,scol1,0,0,srow3,newsize+scol3,DIM0,newsize,DIM2);//Compute M3
//myprint(c,"Calculate M3 a11*t2",newsize,srow3,newsize+scol3,DIM2);
//myprint(c,"All C matrix",DIM2,0,0,DIM2);

    //subMatrices(c22,c21,c22,newsize);
    subMatricesc(c,c,c,newsize,newsize+srow3,newsize+scol3,newsize+srow3,scol3,newsize+srow3,newsize+scol3,DIM2,DIM2,DIM2);
//myprint(c,"Subtraction C of c22*c21",newsize,newsize+srow3,newsize+scol3,DIM2);
//myprint(c,"All C matrix",DIM2,0,0,DIM2);
       // addMatrices(c22,c12,c22,newsize);
    addMatricesc(c,c,c,newsize,newsize+srow3,newsize+scol3,srow3,newsize+scol3,newsize+srow3,newsize+scol3,DIM2,DIM2,DIM2);
//myprint(c,"Addition C of c22*c12",newsize,newsize+srow3,newsize+scol3,DIM2);
//myprint(c,"All C matrix",DIM2,0,0,DIM2);

//################################################################

    //subMatrices(b21,b11,t2,newsize);
    subMatrices(b,b,t2,newsize,newsize+srow2,scol2,srow2,scol2,DIM1,DIM1,newsize);
//myprint(t2,"Subtraction t2 of b21 ,b11",newsize,0,0,newsize);
    //strassenMultMatrix(a22,t2,t1,newsize);
    strassenMultMatrix(a,t2,t1,newsize,newsize+srow1,newsize+scol1,0,0,0,0,DIM0,newsize,newsize);//compute M4
//myprint(t1,"Calculate M4 a22*t2",newsize,0,0,newsize);

        //addMatrices(c11,t1,c11,newsize);
    addMatrices1(c,t1,c,newsize,srow3,scol3,srow3,scol3,DIM2,newsize,DIM2);
//myprint(c,"Addition 1 C of c11,t1 ",newsize,srow3,scol3,DIM2);
//myprint(c,"All C matrix",DIM2,0,0,DIM2);
       // addMatrices(c21,t1,c21,newsize);
       //This is the statment that has the problem
    addMatrices1(c,t1,c,newsize,newsize+srow3,scol3,newsize+srow3,scol3,DIM2,newsize,DIM2);
//myprint(c,"Addition C of c21, t1",newsize,newsize+srow3,scol3,DIM2);
//myprint(c,"All C matrix",DIM2,0,0,DIM2);

    //addMatrices(a11,a12,t1,newsize);
    addMatrices(a,a,t1,newsize,srow1,scol1,srow1,newsize+scol1,DIM0,DIM0,newsize);
//myprint(t1,"Additon t1 , a11,a12",newsize,0,0,newsize);
    //strassenMultMatrix(t1,b22,t2,newsize);
strassenMultMatrix(t1,b,t2,newsize,0,0,newsize+srow2,newsize+scol2,0,0,newsize,DIM1,newsize);
//myprint(t2,"Strassen Matrix Multiplication t1*b11",newsize,0,0,newsize);

    //subMatrices(c11,t2,c11,newsize);
    subMatrices1(c,t2,c,newsize,srow3,scol3,srow3,scol3,DIM2,newsize,DIM2);
//myprint(c,"Subtraction 1 C c11-t2",newsize,srow3,scol3,size);
        //addMatrices(c12,t2,c12,newsize);
//myprint(c,"All C matrix",8,0,0,8);
    addMatrices1(c,t2,c,newsize,srow3,newsize+scol3,srow3,newsize+scol3,DIM2,newsize,DIM2);
//myprint(c,"Addition C c12,t2",newsize,srow3,newsize+scol3,DIM2);
//myprint(c,"All C matrix",DIM2,0,0,DIM2);

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

You are asking the question in the wrong forum. This forum is for questions about the internals of the openMP runtime, not about how to use OpenMP.

Since the question is about MIC, you should take it to the general MIC forum http://software.intel.com/en-us/forums/intel-many-integrated-core. You might also like to try to summarize what it is you're trying to do with less code and more text. I, for one, find your current explanation cryptic.

Leave a Comment

Please sign in to add a comment. Not a member? Join today