Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
7646 Discussions

How to make mat_mul by using static variables by using intel C compiler?

kim__seongik
Beginner
228 Views

#include <stdio.h>


void mat_mul2(int M, int N, int K, double A[M][K], double B[K][N], double C[M][N])
{
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
for (int k = 0; k < K; k++) {
C[i][j] += A[i][k] * B[k][j];
}
}
}
}

int main(int argc, char **argv)
{

 

double A[3][3], B[3][3];
double C[3][3] = { 0 };

for (int i = 0; i < 3; i++) {
B[i][i] = 1;
for (int j = 0; j < 3; j++) {
A[i][j] = 3 * i + j;
}
}
printf("before\n");
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
printf(" %lf", C[i][j]);
}
printf("\n");
}

mat_mul2(3, 3, 3, A, B, C);

printf("after\n");
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
printf(" %lf", C[i][j]);
}
printf("\n");
}

 

return 0;
}

 

 

 

 

When I build by using above source code the output is below.

 

kim__seongik_0-1623291508227.png

 

Expected results are 

 

kim__seongik_1-1623291550761.png

 

..

 

How can I solve this problem??

Actually It works in GCC compiler.

0 Kudos
3 Replies
ShivaniK_Intel
Moderator
214 Views

Hi,

 

Thanks for reaching out to us.

 

Could you please provide us the compiler command you have used to investigate more on your issue?

 

Could you also provide the Intel C compiler version you are using?

 

We are able to execute the mat_mul program using icl in Windows and ICC in Linux machines. Please refer to the below attachments for more information.

 

Thanks & Regards

Shivani

mat_mul.pngmat_mul1.png

 

ShivaniK_Intel
Moderator
188 Views

Hi,


As we didn't hear back from you, Is your issue resolved? If not, please provide the details that have been asked in my previous post.


Thanks & Regards,

Shivani


ShivaniK_Intel
Moderator
174 Views

Hi,


As we have not heard back from you, we are considering that your issue has been resolved. So we will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.


Have a Good day!


Thanks & Regards

Shivani


Reply