Use __AVX__ compiler define instead of custom and broken NO_AVX flag. Fixes #559 (#564)

* Change to __AVX__ macro defined by compiler
* Source files should not be executable
This commit is contained in:
Kenneth Heafield 2019-12-05 22:17:54 +00:00 committed by Marcin Junczys-Dowmunt
parent 6224cb16e2
commit 734a8791dd
8 changed files with 6 additions and 8 deletions

View File

@ -117,8 +117,6 @@ else(MSVC)
message(STATUS "AVX support found")
set(INTRINSICS "${INTRINSICS} -mavx")
list(APPEND INTRINSICS_NVCC -Xcompiler\ -mavx)
else()
add_definitions(-DNO_AVX)
endif(AVX_FOUND)
if(AVX2_FOUND)
message(STATUS "AVX2 support found")

0
src/3rd_party/avx_mathfun.h vendored Executable file → Normal file
View File

0
src/3rd_party/sse_mathfun.h vendored Executable file → Normal file
View File

View File

@ -174,7 +174,7 @@ public:
};
// @TODO: consider how code can be shared via templating
#ifndef NO_AVX
#ifdef __AVX__
struct float32x8 {
private:
__m256 f_;

View File

@ -319,7 +319,7 @@ struct Ops<float32x4> {
} // end namespace functional
} // end namespace marian
#ifndef NO_AVX
#ifdef __AVX__
#include "3rd_party/avx_mathfun.h"
namespace marian {

View File

@ -31,7 +31,7 @@ inline marian::Shape adapt<float32x4>(const marian::Shape& shape) {
x4Shape.set(-1, shape[-1] / 4);
return x4Shape;
}
#ifndef NO_AVX
#ifdef __AVX__
template <>
inline marian::Shape adapt<float32x8>(const marian::Shape& shape) {
ABORT_IF(shape[-1] % 8 != 0,

View File

@ -99,7 +99,7 @@ void elementFloat(const Functor& functor, marian::Tensor out, Tensors... tensors
if(div8) {
// std::cerr << "8: " << functor.to_string() << std::endl;
#ifndef NO_AVX
#ifdef __AVX__
element<float32x8>(functor, out, tensors...);
return;
#endif

View File

@ -425,7 +425,7 @@ void Softmax(Tensor out, Tensor in) {
matchOrAbort<float>(out->type());
matchOrAbort<float>(in->type());
#ifndef NO_AVX
#ifdef __AVX__
if(out->shape()[-1] % 8 == 0) {
Softmax<float32x8>(out, in);
return;
@ -481,7 +481,7 @@ void LogSoftmax(Tensor out, Tensor in) {
matchOrAbort<float>(out->type());
matchOrAbort<float>(in->type());
#ifndef NO_AVX
#ifdef __AVX__
if(out->shape()[-1] % 8 == 0) {
LogSoftmax<float32x8>(out, in);
return;