Thread: help with parallesation

  1. #1
    Registered User
    Join Date
    Feb 2014
    Posts
    1

    Unhappy help with parallesation

    Hi there,
    I need help with the following problem:
    Multiplication of a matrix by a vector: Ap = q.
    This may sound trivial but in my case it is not simply because the dimensions of A are 250,000,000 by 250,000,000. The variables in my algorithm are:
    dataMatrix (50,000,000 x 30) is a matrix that contains indices (addresses) for the matrix A
    dataRecord is a row of dataMatrix
    nrow is the index to the corresponding Rinv matrix, e.g Rinv(5,9,9)
    the call to the function getASddress creates two matrices address containing the indices of A, say A(3,5) and coefficient contains the corresponding values of A(3,5).
    p is an input vector and q is the output vector
    My attempt to parallelise the algorithm failed with a crash of the program. Any help to fix the problem and improve the speed of the program will be greatly appreciated. Below is the code (note that I am using Blitz arrays):

    Code:
                      int numOfThreads = 5;
    #pragma omp parallel for num_threads(numOfThreads)
            for (int ir = 0; ir < dataMatrix.rows(); ir++) {
                    dataRecord(Range::all()) = dataMatrix(ir, Range::all());
            nrow = getRowForRinv(dataRecord);
    // find address and design matrix coefficients
                    getAddress();
    // calculate contributions            
                    t1 = 0.0;
                    for (int i = 0; i < newNumFactors; i++) {
            for (int k = 0; k < numberOfTraits; k++) {
            if (address(i,k) == missingValue) {continue;}
                    t1(k) += coefficient(i,k)*p(address(i,k));
                    }
                    }
                    t2 = 0.0;
            for (int k = 0; k < numberOfTraits; k++) {
            for (int l = 0; l < numberOfTraits; l++) {
            t2(k) += Rinv(nrow,k,l)*t1(l);
                    }
                    }
                    for (int i = 0; i < newNumFactors; i++) {
                    for (int j = 0; j < numberOfTraits; j++) {
            if (address(i,j) == missingValue) {continue;}
                    q(address(i,j)) += coefficient(i,j)*t2(j);
                    }
                    }
                    }     // end of data loop

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    I take it that you're referring to this -> The Blitz++ meta-template library

    The first thing I would suggest you do is some research to see if that library is openmp compatible.
    Ask the authors / maintainers / dedicated support forum or mailing list.

    Next, try a trivial array program, say copying one array to another array. Build it up slowly.

    You also need to do a lot more than simply pasting in a single line to indicate that you want parallelism.
    OpenMP - Wikipedia, the free encyclopedia
    Even apparently trivial programs need care and attention.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Tags for this Thread