You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm implementing AVX-512 code in Codon and testing the _mm512_permutex2var_epi8 function. I'm experiencing strange behavior with the Codon compiler. The result of the assert changes when a print statement is present or absent. Below is the sample code. When I insert 'print(int(PtrX[0]))', the result becomes True, but if I comment it out, it turns False. Similarly, printing 'NgNo' results in True, but not printing it leads to False. I'm concerned that the 'Correct' variable might be getting corrupted. Additionally, executing this code requires the --mattr=+avx512bw option. In debugging with Codon, it's necessary to display results using print statements, and the presence or absence of these print statements changes the outcomes. Could you advise any solution to this issue ?
#-- Add below code to experimental/sdmi.codon
@llvm
@inline
def _mm512_loadu_m_si512(data:Ptr[i8]) -> Vec[i8, 64]:
%m512_val = call <64 x i8> asm sideeffect "vmovdqu32 $1, $0", "=v,p"(i8* %data)
ret <64 x i8> %m512_val
@llvm
@inline
def _mm512_permutex2var_epi8(a:Vec[i8, 64], idx:Vec[i8, 64], b:Vec[i8, 64]) -> Vec[i8, 64]:
%m512_val = call <64 x i8> asm sideeffect "vpermi2b $2, $1, $0","=v,v,v,v"(<64 x i8> %a, <64 x i8> %b, <64 x i8> %idx)
ret <64 x i8> %m512_val
#-------------------------------------------------------
#-- Codon test code ----
from experimental.simd import *
from random import *
A:Vec[i8,64]
i:int
Correct:bool=True
#-- AVX-512 Array --
XDt = Array[i8](64)
YDt = Array[i8](64)
#-- Set XDt --
for i in range(64):
XDt[i] = i8(i)
X=Vec[i8,64]._mm512_loadu_m_si512(XDt.ptr)
for i in range(64):
YDt[i] = i8(-i)
Y=Vec[i8,64]._mm512_loadu_m_si512(YDt.ptr)
IndexDt = Array[i8](64)
for i in range(64):
if i % 2 == 0:
IndexDt[i]=i8(i)
else:
IndexDt[i]=i8(i+64)
Index = Vec[i8,64]._mm512_loadu_m_si512(IndexDt.ptr)
A = Vec[i8,64]._mm512_permutex2var_epi8(X,Index,Y)
PtrA = __ptr__(A).as_byte()
PtrX = __ptr__(X).as_byte()
PtrY = __ptr__(Y).as_byte()
PtrIndex = __ptr__(Index).as_byte()
#----------------------------------------------
#--- Add print statement, result is True ---
#----------------------------------------------
print(int(PtrX[0]))
Correct = True
NgNo : int = -255
for i in range(64):
if int(PtrIndex[i]) < 64:
if int(PtrA[i])!=int(PtrX[i]):
NgNo = i
Correct = False
else:
if int(PtrA[i])!=int(PtrY[i]):
NgNo = -i
Correct = False
#-- Without print NgNo ==> the result is False
print("_mm512_permutex2var_epi8 test:",Correct)
#-- With print NgNo variable ==> result is True
#print("_mm512_permutex2var_epi8 test:",Correct,NgNo)
assert Correct,"_mm512_permutex2var_epi8 Test:Error"
#-- To execute this code, the --mattr option is required.
codon run --mattr=+avx512bw -release FileName
The text was updated successfully, but these errors were encountered:
I'm implementing AVX-512 code in Codon and testing the _mm512_permutex2var_epi8 function. I'm experiencing strange behavior with the Codon compiler. The result of the assert changes when a print statement is present or absent. Below is the sample code. When I insert 'print(int(PtrX[0]))', the result becomes True, but if I comment it out, it turns False. Similarly, printing 'NgNo' results in True, but not printing it leads to False. I'm concerned that the 'Correct' variable might be getting corrupted. Additionally, executing this code requires the --mattr=+avx512bw option. In debugging with Codon, it's necessary to display results using print statements, and the presence or absence of these print statements changes the outcomes. Could you advise any solution to this issue ?
The text was updated successfully, but these errors were encountered: