seanzw / gem5-avx

This adds partial support of AVX2 and AVX-512 to gem5.
BSD 3-Clause "New" or "Revised" License
11 stars 5 forks source link

Does _mm512_store_ps() only support store data in the stack? #4

Open luckyq opened 2 years ago

luckyq commented 2 years ago

Hi, All:

Thanks for the great work for supporting avx in gem5.

Today, I have met a problem when I run the example of avx_test. If _mm512_store_ps() is used to store an _mm512 variable into the main memory. The code is like below:

float a= (float *)aligned_malloc(64, 16); _mm512 b; _mm512_store_ps(a,b);

The gem5 reported an error: panic: Unrecognized/invalid instruction executed: panic: Unrecognized/invalid instruction executed:

{ leg = 0x10, rex = 0, evex = 0x842, op = { type = two byte, op = 0xef, }, modRM = 0xe4, sib = 0, immediate = 0, displacement = 0 dispSize = 0} Memory Usage: 8566948 KBytes Program aborted at tick 17968375710 Then the simulation is terminated.

But if I change it into the following code:

void func(){ float a[16]; __mm512 b; _mm512_store_ps(a,b); }

It works fine.

Do you have any clue about why it happens and how to fix it?

Thanks in advance.

Best, Dong

seanzw commented 2 years ago

Thanks for trying gem5-avx. I noticed something suspicious in this code:

float a= (float *)aligned_malloc(64, 16); _mm512 b; _mm512_store_ps(a,b);

You are allocating 16 bytes instead of 64 bytes here. Also, you are assigning a pointer to float.

Beyond this, the error message of gem5 says it decoded some invalid instructions. Maybe you can take a look at the assembly code and check that both intrinsics are compiled into the same instruction?

luckyq commented 2 years ago

Thanks for your reply.

And sorry for the typo. Actually, I have allocated a large array.

Maybe you can take a look at the assembly code and check that both intrinsics are compiled into the same instruction?

Are there special flags that should be used when we compile the program?

Best, Dong