Skip to content

Commit c737141

Browse files
Updating src/tests/Interop/PInvoke/Generics/GenericsNative.Vector* to annotate individual methods as requiring AVX (#61259)
* Updating src/tests/Interop/PInvoke/Generics/GenericsNative.Vector* to annotate individual methods as requiring AVX * Always use __m256i on XARCH
1 parent 2099752 commit c737141

11 files changed

+42
-44
lines changed

src/tests/Common/Platform/platformdefines.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,5 +270,11 @@ inline void CoreClrFree(void *p)
270270
#define strcpy_s TP_strcpy_s
271271
#endif
272272

273+
#if defined(TARGET_XARCH) && !defined(_MSC_VER)
274+
#define ENABLE_AVX __attribute__ ((target("avx")))
275+
#else
276+
#define ENABLE_AVX
277+
#endif
278+
273279
#endif
274280

src/tests/Interop/PInvoke/Generics/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
1717
# The ABI for passing parameters with 32-byte alignment has changed in GCC 4.6
1818
add_compile_options(-Wno-psabi)
1919
endif()
20-
if (MSVC)
21-
# The MSVC require explicitly ask for AVX2 so define would be present.
22-
add_compile_options(/arch:AVX2)
23-
else()
24-
if (NOT CLR_CMAKE_TARGET_ARCH_ARM64 AND NOT CLR_CMAKE_TARGET_ARCH_ARM)
25-
add_compile_options(-mavx)
26-
endif()
27-
endif()
2820
set(SOURCES
2921
GenericsNative.IUnknown.cpp
3022
GenericsNative.NullableB.cpp

src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256B.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#error Unsupported target architecture
1515
#endif
1616

17-
#if defined(__AVX2__)
17+
#if defined(TARGET_XARCH)
1818
typedef __m256i Vector256B;
1919
#else
2020
typedef struct {

src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256C.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#error Unsupported target architecture
1515
#endif
1616

17-
#if defined(__AVX2__)
17+
#if defined(TARGET_XARCH)
1818
typedef __m256i Vector256C;
1919
#else
2020
typedef struct {

src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256D.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#error Unsupported target architecture
1515
#endif
1616

17-
#if defined(__AVX2__)
17+
#if defined(TARGET_XARCH)
1818
typedef __m256 Vector256D;
1919
#else
2020
typedef struct {
@@ -27,7 +27,7 @@
2727

2828
static Vector256D Vector256DValue = { };
2929

30-
extern "C" DLL_EXPORT Vector256D STDMETHODCALLTYPE GetVector256D(double e00, double e01, double e02, double e03)
30+
extern "C" DLL_EXPORT Vector256D STDMETHODCALLTYPE ENABLE_AVX GetVector256D(double e00, double e01, double e02, double e03)
3131
{
3232
union {
3333
double value[4];
@@ -42,7 +42,7 @@ extern "C" DLL_EXPORT Vector256D STDMETHODCALLTYPE GetVector256D(double e00, dou
4242
return result;
4343
}
4444

45-
extern "C" DLL_EXPORT void STDMETHODCALLTYPE GetVector256DOut(double e00, double e01, double e02, double e03, Vector256D* pValue)
45+
extern "C" DLL_EXPORT void STDMETHODCALLTYPE ENABLE_AVX GetVector256DOut(double e00, double e01, double e02, double e03, Vector256D* pValue)
4646
{
4747
Vector256D value = GetVector256D(e00, e01, e02, e03);
4848

@@ -54,18 +54,18 @@ extern "C" DLL_EXPORT void STDMETHODCALLTYPE GetVector256DOut(double e00, double
5454
#endif
5555
}
5656

57-
extern "C" DLL_EXPORT const Vector256D* STDMETHODCALLTYPE GetVector256DPtr(double e00, double e01, double e02, double e03)
57+
extern "C" DLL_EXPORT const Vector256D* STDMETHODCALLTYPE ENABLE_AVX GetVector256DPtr(double e00, double e01, double e02, double e03)
5858
{
5959
GetVector256DOut(e00, e01, e02, e03, &Vector256DValue);
6060
return &Vector256DValue;
6161
}
6262

63-
extern "C" DLL_EXPORT Vector256D STDMETHODCALLTYPE AddVector256D(Vector256D lhs, Vector256D rhs)
63+
extern "C" DLL_EXPORT Vector256D STDMETHODCALLTYPE ENABLE_AVX AddVector256D(Vector256D lhs, Vector256D rhs)
6464
{
6565
throw "P/Invoke for Vector256<double> should be unsupported.";
6666
}
6767

68-
extern "C" DLL_EXPORT Vector256D STDMETHODCALLTYPE AddVector256Ds(const Vector256D* pValues, uint32_t count)
68+
extern "C" DLL_EXPORT Vector256D STDMETHODCALLTYPE ENABLE_AVX AddVector256Ds(const Vector256D* pValues, uint32_t count)
6969
{
7070
throw "P/Invoke for Vector256<double> should be unsupported.";
7171
}

src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256F.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#error Unsupported target architecture
1515
#endif
1616

17-
#if defined(__AVX2__)
17+
#if defined(TARGET_XARCH)
1818
typedef __m256 Vector256F;
1919
#else
2020
typedef struct {
@@ -31,7 +31,7 @@
3131

3232
static Vector256F Vector256FValue = { };
3333

34-
extern "C" DLL_EXPORT Vector256F STDMETHODCALLTYPE GetVector256F(float e00, float e01, float e02, float e03, float e04, float e05, float e06, float e07)
34+
extern "C" DLL_EXPORT Vector256F STDMETHODCALLTYPE ENABLE_AVX GetVector256F(float e00, float e01, float e02, float e03, float e04, float e05, float e06, float e07)
3535
{
3636
union {
3737
float value[8];
@@ -50,7 +50,7 @@ extern "C" DLL_EXPORT Vector256F STDMETHODCALLTYPE GetVector256F(float e00, floa
5050
return result;
5151
}
5252

53-
extern "C" DLL_EXPORT void STDMETHODCALLTYPE GetVector256FOut(float e00, float e01, float e02, float e03, float e04, float e05, float e06, float e07, Vector256F* pValue)
53+
extern "C" DLL_EXPORT void STDMETHODCALLTYPE ENABLE_AVX GetVector256FOut(float e00, float e01, float e02, float e03, float e04, float e05, float e06, float e07, Vector256F* pValue)
5454
{
5555
Vector256F value = GetVector256F(e00, e01, e02, e03, e04, e05, e06, e07);
5656

@@ -62,18 +62,18 @@ extern "C" DLL_EXPORT void STDMETHODCALLTYPE GetVector256FOut(float e00, float e
6262
#endif
6363
}
6464

65-
extern "C" DLL_EXPORT const Vector256F* STDMETHODCALLTYPE GetVector256FPtr(float e00, float e01, float e02, float e03, float e04, float e05, float e06, float e07)
65+
extern "C" DLL_EXPORT const Vector256F* STDMETHODCALLTYPE ENABLE_AVX GetVector256FPtr(float e00, float e01, float e02, float e03, float e04, float e05, float e06, float e07)
6666
{
6767
GetVector256FOut(e00, e01, e02, e03, e04, e05, e06, e07, &Vector256FValue);
6868
return &Vector256FValue;
6969
}
7070

71-
extern "C" DLL_EXPORT Vector256F STDMETHODCALLTYPE AddVector256F(Vector256F lhs, Vector256F rhs)
71+
extern "C" DLL_EXPORT Vector256F STDMETHODCALLTYPE ENABLE_AVX AddVector256F(Vector256F lhs, Vector256F rhs)
7272
{
7373
throw "P/Invoke for Vector256<float> should be unsupported.";
7474
}
7575

76-
extern "C" DLL_EXPORT Vector256F STDMETHODCALLTYPE AddVector256Fs(const Vector256F* pValues, uint32_t count)
76+
extern "C" DLL_EXPORT Vector256F STDMETHODCALLTYPE ENABLE_AVX AddVector256Fs(const Vector256F* pValues, uint32_t count)
7777
{
7878
throw "P/Invoke for Vector256<float> should be unsupported.";
7979
}

src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256L.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#error Unsupported target architecture
1515
#endif
1616

17-
#if defined(__AVX2__)
17+
#if defined(TARGET_XARCH)
1818
typedef __m256i Vector256L;
1919
#else
2020
typedef struct {

src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256U.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#error Unsupported target architecture
1515
#endif
1616

17-
#if defined(__AVX2__)
17+
#if defined(TARGET_XARCH)
1818
typedef __m256i Vector256U;
1919
#else
2020
typedef struct {
@@ -31,7 +31,7 @@
3131

3232
static Vector256U Vector256UValue = { };
3333

34-
extern "C" DLL_EXPORT Vector256U STDMETHODCALLTYPE GetVector256U(uint32_t e00, uint32_t e01, uint32_t e02, uint32_t e03, uint32_t e04, uint32_t e05, uint32_t e06, uint32_t e07)
34+
extern "C" DLL_EXPORT Vector256U STDMETHODCALLTYPE ENABLE_AVX GetVector256U(uint32_t e00, uint32_t e01, uint32_t e02, uint32_t e03, uint32_t e04, uint32_t e05, uint32_t e06, uint32_t e07)
3535
{
3636
union {
3737
uint32_t value[8];
@@ -50,7 +50,7 @@ extern "C" DLL_EXPORT Vector256U STDMETHODCALLTYPE GetVector256U(uint32_t e00, u
5050
return result;
5151
}
5252

53-
extern "C" DLL_EXPORT void STDMETHODCALLTYPE GetVector256UOut(uint32_t e00, uint32_t e01, uint32_t e02, uint32_t e03, uint32_t e04, uint32_t e05, uint32_t e06, uint32_t e07, Vector256U* pValue)
53+
extern "C" DLL_EXPORT void STDMETHODCALLTYPE ENABLE_AVX GetVector256UOut(uint32_t e00, uint32_t e01, uint32_t e02, uint32_t e03, uint32_t e04, uint32_t e05, uint32_t e06, uint32_t e07, Vector256U* pValue)
5454
{
5555
Vector256U value = GetVector256U(e00, e01, e02, e03, e04, e05, e06, e07);
5656

@@ -62,18 +62,18 @@ extern "C" DLL_EXPORT void STDMETHODCALLTYPE GetVector256UOut(uint32_t e00, uint
6262
#endif
6363
}
6464

65-
extern "C" DLL_EXPORT const Vector256U* STDMETHODCALLTYPE GetVector256UPtr(uint32_t e00, uint32_t e01, uint32_t e02, uint32_t e03, uint32_t e04, uint32_t e05, uint32_t e06, uint32_t e07)
65+
extern "C" DLL_EXPORT const Vector256U* STDMETHODCALLTYPE ENABLE_AVX GetVector256UPtr(uint32_t e00, uint32_t e01, uint32_t e02, uint32_t e03, uint32_t e04, uint32_t e05, uint32_t e06, uint32_t e07)
6666
{
6767
GetVector256UOut(e00, e01, e02, e03, e04, e05, e06, e07, &Vector256UValue);
6868
return &Vector256UValue;
6969
}
7070

71-
extern "C" DLL_EXPORT Vector256U STDMETHODCALLTYPE AddVector256U(Vector256U lhs, Vector256U rhs)
71+
extern "C" DLL_EXPORT Vector256U STDMETHODCALLTYPE ENABLE_AVX AddVector256U(Vector256U lhs, Vector256U rhs)
7272
{
7373
throw "P/Invoke for Vector256<uint> should be unsupported.";
7474
}
7575

76-
extern "C" DLL_EXPORT Vector256U STDMETHODCALLTYPE AddVector256Us(const Vector256U* pValues, uint32_t count)
76+
extern "C" DLL_EXPORT Vector256U STDMETHODCALLTYPE ENABLE_AVX AddVector256Us(const Vector256U* pValues, uint32_t count)
7777
{
7878
throw "P/Invoke for Vector256<uint> should be unsupported.";
7979
}

src/tests/Interop/PInvoke/Generics/GenericsNative.VectorD.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" DLL_EXPORT VectorD128 STDMETHODCALLTYPE GetVectorD128(double e00, dou
2727
return *reinterpret_cast<VectorD128*>(value);
2828
}
2929

30-
extern "C" DLL_EXPORT VectorD256 STDMETHODCALLTYPE GetVectorD256(double e00, double e01, double e02, double e03)
30+
extern "C" DLL_EXPORT VectorD256 STDMETHODCALLTYPE ENABLE_AVX GetVectorD256(double e00, double e01, double e02, double e03)
3131
{
3232
double value[4] = { e00, e01, e02, e03 };
3333
return *reinterpret_cast<VectorD256*>(value);
@@ -38,7 +38,7 @@ extern "C" DLL_EXPORT void STDMETHODCALLTYPE GetVectorD128Out(double e00, double
3838
*pValue = GetVectorD128(e00, e01);
3939
}
4040

41-
extern "C" DLL_EXPORT void STDMETHODCALLTYPE GetVectorD256Out(double e00, double e01, double e02, double e03, VectorD256* pValue)
41+
extern "C" DLL_EXPORT void STDMETHODCALLTYPE ENABLE_AVX GetVectorD256Out(double e00, double e01, double e02, double e03, VectorD256* pValue)
4242
{
4343
*pValue = GetVectorD256(e00, e01, e02, e03);
4444
}
@@ -49,7 +49,7 @@ extern "C" DLL_EXPORT const VectorD128* STDMETHODCALLTYPE GetVectorD128Ptr(doubl
4949
return &VectorD128Value;
5050
}
5151

52-
extern "C" DLL_EXPORT const VectorD256* STDMETHODCALLTYPE GetVectorD256Ptr(double e00, double e01, double e02, double e03)
52+
extern "C" DLL_EXPORT const VectorD256* STDMETHODCALLTYPE ENABLE_AVX GetVectorD256Ptr(double e00, double e01, double e02, double e03)
5353
{
5454
GetVectorD256Out(e00, e01, e02, e03, &VectorD256Value);
5555
return &VectorD256Value;
@@ -60,7 +60,7 @@ extern "C" DLL_EXPORT VectorD128 STDMETHODCALLTYPE AddVectorD128(VectorD128 lhs,
6060
throw "P/Invoke for Vector<char> should be unsupported.";
6161
}
6262

63-
extern "C" DLL_EXPORT VectorD256 STDMETHODCALLTYPE AddVectorD256(VectorD256 lhs, VectorD256 rhs)
63+
extern "C" DLL_EXPORT VectorD256 STDMETHODCALLTYPE ENABLE_AVX AddVectorD256(VectorD256 lhs, VectorD256 rhs)
6464
{
6565
throw "P/Invoke for Vector<char> should be unsupported.";
6666
}
@@ -70,7 +70,7 @@ extern "C" DLL_EXPORT VectorD128 STDMETHODCALLTYPE AddVectorD128s(const VectorD1
7070
throw "P/Invoke for Vector<char> should be unsupported.";
7171
}
7272

73-
extern "C" DLL_EXPORT VectorD256 STDMETHODCALLTYPE AddVectorD256s(const VectorD256* pValues, double count)
73+
extern "C" DLL_EXPORT VectorD256 STDMETHODCALLTYPE ENABLE_AVX AddVectorD256s(const VectorD256* pValues, double count)
7474
{
7575
throw "P/Invoke for Vector<char> should be unsupported.";
7676
}

src/tests/Interop/PInvoke/Generics/GenericsNative.VectorL.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" DLL_EXPORT VectorL128 STDMETHODCALLTYPE GetVectorL128(int64_t e00, in
2727
return *reinterpret_cast<VectorL128*>(value);
2828
}
2929

30-
extern "C" DLL_EXPORT VectorL256 STDMETHODCALLTYPE GetVectorL256(int64_t e00, int64_t e01, int64_t e02, int64_t e03)
30+
extern "C" DLL_EXPORT VectorL256 STDMETHODCALLTYPE ENABLE_AVX GetVectorL256(int64_t e00, int64_t e01, int64_t e02, int64_t e03)
3131
{
3232
int64_t value[4] = { e00, e01, e02, e03 };
3333
return *reinterpret_cast<VectorL256*>(value);
@@ -38,7 +38,7 @@ extern "C" DLL_EXPORT void STDMETHODCALLTYPE GetVectorL128Out(int64_t e00, int64
3838
*pValue = GetVectorL128(e00, e01);
3939
}
4040

41-
extern "C" DLL_EXPORT void STDMETHODCALLTYPE GetVectorL256Out(int64_t e00, int64_t e01, int64_t e02, int64_t e03, VectorL256* pValue)
41+
extern "C" DLL_EXPORT void STDMETHODCALLTYPE ENABLE_AVX GetVectorL256Out(int64_t e00, int64_t e01, int64_t e02, int64_t e03, VectorL256* pValue)
4242
{
4343
*pValue = GetVectorL256(e00, e01, e02, e03);
4444
}
@@ -49,7 +49,7 @@ extern "C" DLL_EXPORT const VectorL128* STDMETHODCALLTYPE GetVectorL128Ptr(int64
4949
return &VectorL128Value;
5050
}
5151

52-
extern "C" DLL_EXPORT const VectorL256* STDMETHODCALLTYPE GetVectorL256Ptr(int64_t e00, int64_t e01, int64_t e02, int64_t e03)
52+
extern "C" DLL_EXPORT const VectorL256* STDMETHODCALLTYPE ENABLE_AVX GetVectorL256Ptr(int64_t e00, int64_t e01, int64_t e02, int64_t e03)
5353
{
5454
GetVectorL256Out(e00, e01, e02, e03, &VectorL256Value);
5555
return &VectorL256Value;
@@ -60,7 +60,7 @@ extern "C" DLL_EXPORT VectorL128 STDMETHODCALLTYPE AddVectorL128(VectorL128 lhs,
6060
throw "P/Invoke for Vector<char> should be unsupported.";
6161
}
6262

63-
extern "C" DLL_EXPORT VectorL256 STDMETHODCALLTYPE AddVectorL256(VectorL256 lhs, VectorL256 rhs)
63+
extern "C" DLL_EXPORT VectorL256 STDMETHODCALLTYPE ENABLE_AVX AddVectorL256(VectorL256 lhs, VectorL256 rhs)
6464
{
6565
throw "P/Invoke for Vector<char> should be unsupported.";
6666
}
@@ -70,7 +70,7 @@ extern "C" DLL_EXPORT VectorL128 STDMETHODCALLTYPE AddVectorL128s(const VectorL1
7070
throw "P/Invoke for Vector<char> should be unsupported.";
7171
}
7272

73-
extern "C" DLL_EXPORT VectorL256 STDMETHODCALLTYPE AddVectorL256s(const VectorL256* pValues, int64_t count)
73+
extern "C" DLL_EXPORT VectorL256 STDMETHODCALLTYPE ENABLE_AVX AddVectorL256s(const VectorL256* pValues, int64_t count)
7474
{
7575
throw "P/Invoke for Vector<char> should be unsupported.";
7676
}

0 commit comments

Comments
 (0)