伊塞尼的内在论?

2024-05-14 23:24:38 发布

您现在位置:Python中文网/ 问答频道 /正文

有没有办法在Cython代码中使用AES-NI指令?在

我能找到的最接近的是某人如何访问SIMD指令: https://groups.google.com/forum/#!msg/cython-users/nTnyI7A6sMc/a6_GnOOsLuQJ

Python线程中的AES-NI没有应答: Python support for AES-NI


Tags: 代码httpscomgoogle指令msgforumusers
1条回答
网友
1楼 · 发布于 2024-05-14 23:24:38

您应该能够将内部函数定义为Cython中的普通C函数。有点像

cdef extern from "emmintrin.h": # I'm going off the microsoft documentation for where the headers are
    # define the datatype as an opaque type
    ctypedef struct __m128i x:
        pass

    __m128i _mm_set_epi32 (int i3, int i2, int i1, int i0)

cdef extern from "wmmintrin.h":
    __m128i _mm_aesdec_si128(__m128i v,__m128i rkey)

# then in some Cython function
def f():
   cdef __m128i v = _mm_set_epi32(1,2,3,4)
   cdef __m128i key = _mm_set_epi32(5,6,7,8)
   cdef __m128i result = _mm_aesdec_si128(v,key)

问题“如何在bytes数组上应用它”?首先,得到字节数组的char*。然后用range对其进行迭代(注意不要跑完末尾)。在

^{pr2}$

相关问题 更多 >

    热门问题