rjhogan / Adept-2

Combined array and automatic differentiation library in C++
http://www.met.reading.ac.uk/clouds/adept/
Apache License 2.0
163 stars 29 forks source link

mm_prod_pd, mm_hmin_pd and mm_hmax_pd are not defined under __AVX__ and ADEPT_FLOAT_PACKET_SIZE == 8 #16

Closed juanlucasrey closed 4 years ago

juanlucasrey commented 4 years ago

this leads to following errors on packet.h on windows:

adept/Packet.h(400,14): error C3861: 'mm_hprod_pd': identifier not found adept/Packet.h(404,14): error C3861: 'mm_hmin_pd': identifier not found adept/Packet.h(408,14): error C3861: 'mm_hmax_pd': identifier not found

rjhogan commented 4 years ago

It looks like the Microsoft compiler doesn't define the SSE2 to indicate that SSE2 instructions are available (which they always are if AVX is available). Could you try adding the block of code beginning with the comment about the Microsoft compiler near the top of Packet.h (I've given you a few lines of context)? If this works I'll push the fix. Thanks.

ifndef AdeptPacket_H

define AdeptPacket_H 1

include

include

// Microsoft compiler doesn't define SSE2 even if AVX is // defined

ifdef AVX

ifndef SSE2

define SSE2 1

endif

endif

// Headers needed for x86 vector intrinsics

ifdef SSE2

rjhogan commented 4 years ago

Arg, my code has been rewritten by the stupid markdown feature! Should be:

#ifndef AdeptPacket_H
#define AdeptPacket_H 1

#include <iostream>
#include <cstdlib>

// Microsoft compiler doesn't define __SSE2__ even if __AVX__ is
// defined
#ifdef __AVX__
#ifndef __SSE2__
#define __SSE2__ 1
#endif
#endif

// Headers needed for x86 vector intrinsics
#ifdef __SSE2__
juanlucasrey commented 4 years ago

I'll try a little later to see if this works and report back. thanks!

juanlucasrey commented 4 years ago

this works, thanks.

by the way I am also getting this minor warnings: adept/Stack.h(353,34): warning C4267: 'return': conversion from 'size_t' to 'adept::uIndex', possible loss of data adept/Stack.h(354,32): warning C4267: 'return': conversion from 'size_t' to 'adept::uIndex', possible loss of data adept/Stack.h(634,35): warning C4267: 'return': conversion from 'size_t' to 'adept::uIndex', possible loss of data adept/Stack.h(635,33): warning C4267: 'return': conversion from 'size_t' to 'adept::uIndex', possible loss of data

rjhogan commented 4 years ago

That's because by default Adept uses 4-byte integers for indexing the stack, whereas on a 64-bit system the STL containers use 8-byte integers to describe their size. 4-byte integers work out faster. For very large problems, you can use 8-byte integers by compiling with ADEPT_SUPPORT_HUGE_ARRAYS defined and you would probably find this warning disappears.