Community
cancel
Showing results for 
Search instead for 
Did you mean: 
gajendra_g_
Beginner
175 Views

error: ‘blocked_range2d’ does not name a type

Jump to solution

i am not sure why am i getting this error.  This example follows the pattern similar to the one provided on TBB documentation except I am trying to do a 1D array for matrix multiplication.

The  code is below

The compilation command i enter is : g++ -std=c++11 matrix.cpp -ltbb -o matrix.out

(thanks for the help in advance)

#include <iostream>
#include "tbb/tbb.h"
#include "tbb/parallel_for.h"
#include "tbb/blocked_range2d.h"
#include <chrono>

const size_t m_rows = 2048;
const size_t m_columns = 2048;
const size_t m_k = 2048;

class MatrixMultiply2D
{
    private:
        double *m_A;
        double *m_B;
        double *m_C;

    public:
        void operator()(const blocked_range2d<size_t>& rnge )
        {
            double *usrA = m_A;
            double *usrB = m_B;
            double *usrC = m_C;

            for(size_t row=rnge.rows().begin(); row<rnge.rows().end(); ++row)
            {
                for(size_t col=rnge.cols().begin(); col <rnge.cols().end(); ++col)
                {
                    double sum = 0.0;
                
                     for(size_t k=0; k<m_k; ++k)
                     {
                        usrC[row*(rnge.col().end()-rnge.col().begin()) + col]  += usrA[row*m_k + k]*usrB[k*(rnge.cols.end()-rnge.cols.begin()) + col];     
                    }
                }
            }
        }

        MatrixMultiply2D(double *A, double *B, double *C):
        m_A(A), m_B(B), m_C(C)
        {       }
};

int main(int argc, char **argv)
{
    double *A = new double[m_rows*m_k];
    double *B = new double[m_k*m_columns];
    double *C = new double[m_rows*m_columns];

    serialMatrixMultiply(A, B, C, m_rows, m_columns, m_k); 

    delete[] A;
    delete[] B;
    delete[] C;
    return 0;
}

 

0 Kudos
1 Solution
Alexei_K_Intel
Employee
175 Views

Hi,

The most functionality of Intel TBB library is located inside the tbb namespace. Try to use tbb::blocked_range2d<size_t>. You can find what namespace is used for particular functionality in documentation, e.g. the blocked_range2d section states:

namespace tbb {
    template<typename RowValue, typename ColValue=RowValue>
    class blocked_range2d {
    public:
    ...

Regards,
Alex

View solution in original post

2 Replies
Alexei_K_Intel
Employee
176 Views

Hi,

The most functionality of Intel TBB library is located inside the tbb namespace. Try to use tbb::blocked_range2d<size_t>. You can find what namespace is used for particular functionality in documentation, e.g. the blocked_range2d section states:

namespace tbb {
    template<typename RowValue, typename ColValue=RowValue>
    class blocked_range2d {
    public:
    ...

Regards,
Alex

View solution in original post

gajendra_g_
Beginner
175 Views

Hi Alex,

 

Thanks for pointing out the error. My code doesn't give me that error anymore. It was a silly mistake :|

Reply