Community
cancel
Showing results for 
Search instead for 
Did you mean: 
王__云飞
Beginner
44 Views

Is there any way to use VML on 2-dimensional array?

Suppose I have a 2-dimensional array a,and I want to get the result array of  one row of a adding another row of a.Is there any way to use VML in this case?I‘ve tried to directly use the code like this : vdAdd( n, a[1], a[3], y_add ),but errors comes.

If VML can't support 2D array, is there any other libraries which could support calculate between 2D arrays?

Thanks.

0 Kudos
2 Replies
Andrey_G_Intel2
Employee
44 Views

you question mostly relay to other question "how to work with pointer in C". Hope my small example will help you.

#include <stdio.h>
#include "mkl.h"

#define DIMX 10
#define DIMY 2

main()
{
    double a[DIMY][DIMX],y[DIMX];
    int i,j;

    for(i=0;i<DIMX;i++)
    {
        ((double *)(a))=i;
        ((double *)(a))[i+DIMX]=i+DIMX;
        y=-1;
    }

    for(j=0;j<DIMY;j++)
    {
        for(i=0;i<DIMX;i++)
        {
            printf("%.2f  ",a);
        }
        printf("\n");
    }

    vdAdd(DIMX,(double *)a,&((double *)a)[10],y);

    for(i=0;i<DIMX;i++)
    {
        printf("%.2f  ",y);
    }
}

王__云飞
Beginner
44 Views

Thank you!

I also wonder that if I want to offload only the vdAdd line to the MIC,what should I claim before the line?

I thought it may be like this:

#pragma offload target(mic:0)in((double *)a,&((double *)a)[10]:length(DIMX)) inout(y_add:length(DIMX))
{
    vdAdd(DIMX,(double *)a,&((double *)a)[10],y);
}

However,it doesn't work.

Could you help me with this?

Reply