Ticket #9766: add_target_attribs.patch

File add_target_attribs.patch, 7.2 KB (added by Andrey Semashev, 8 years ago)

The patch adds target CPU attributes to the optimized functions.

  • libs/log/src/dump_avx2.cpp

    old new  
    2222#include <boost/log/detail/config.hpp>
    2323#include <boost/log/detail/header.hpp>
    2424
     25#if ((BOOST_GCC + 0) / 100) >= 407
     26#define BOOST_LOG_AUX_TARGET_ATTRIB __attribute__((target("avx2,arch=core-avx2")))
     27#else
     28#define BOOST_LOG_AUX_TARGET_ATTRIB
     29#endif
     30
    2531namespace boost {
    2632
    2733BOOST_LOG_OPEN_NAMESPACE
     
    5965 *
    6066 * The composed string is placed as follows (in Intel notation): mm_output1[127:0], mm_output2[127:0], mm_output3[127:0], mm_output1[255:128], mm_output2[255:128], mm_output3[255:128].
    6167 */
    62 static BOOST_FORCEINLINE void dump_pack(__m256i mm_char_10_to_a, __m256i mm_input, __m256i& mm_output1, __m256i& mm_output2, __m256i& mm_output3)
     68static BOOST_FORCEINLINE BOOST_LOG_AUX_TARGET_ATTRIB void dump_pack(__m256i mm_char_10_to_a, __m256i mm_input, __m256i& mm_output1, __m256i& mm_output2, __m256i& mm_output3)
    6369{
    6470    // Split half-bytes
    6571    const __m256i mm_15 = _mm256_set1_epi8(0x0F);
     
    100106}
    101107
    102108//! Dumps a pack of input data into a string of 8 bit ASCII characters
    103 static BOOST_FORCEINLINE void dump_pack(__m256i mm_char_10_to_a, __m128i mm_input, __m128i& mm_output1, __m128i& mm_output2, __m128i& mm_output3)
     109static BOOST_FORCEINLINE BOOST_LOG_AUX_TARGET_ATTRIB void dump_pack(__m256i mm_char_10_to_a, __m128i mm_input, __m128i& mm_output1, __m128i& mm_output2, __m128i& mm_output3)
    104110{
    105111    // Split half-bytes
    106112    __m128i mm_input_hi = _mm_srli_epi16(mm_input, 4);
     
    127133}
    128134
    129135template< typename CharT >
    130 BOOST_FORCEINLINE void store_characters(__m128i mm_chars, CharT* buf)
     136BOOST_FORCEINLINE BOOST_LOG_AUX_TARGET_ATTRIB void store_characters(__m128i mm_chars, CharT* buf)
    131137{
    132138    switch (sizeof(CharT))
    133139    {
     
    150156}
    151157
    152158template< typename CharT >
    153 BOOST_FORCEINLINE void store_characters_x3(__m256i mm_chars1, __m256i mm_chars2, __m256i mm_chars3, CharT* buf)
     159BOOST_FORCEINLINE BOOST_LOG_AUX_TARGET_ATTRIB void store_characters_x3(__m256i mm_chars1, __m256i mm_chars2, __m256i mm_chars3, CharT* buf)
    154160{
    155161    store_characters(_mm256_castsi256_si128(mm_chars1), buf);
    156162    store_characters(_mm256_castsi256_si128(mm_chars2), buf + 16);
     
    161167}
    162168
    163169template< typename CharT >
    164 BOOST_FORCEINLINE void dump_data_avx2(const void* data, std::size_t size, std::basic_ostream< CharT >& strm)
     170BOOST_FORCEINLINE BOOST_LOG_AUX_TARGET_ATTRIB void dump_data_avx2(const void* data, std::size_t size, std::basic_ostream< CharT >& strm)
    165171{
    166172    typedef CharT char_type;
    167173
     
    205211            __m256i mm_input = _mm256_load_si256(reinterpret_cast< const __m256i* >(p));
    206212            __m256i mm_output1, mm_output2, mm_output3;
    207213            dump_pack(mm_char_10_to_a, mm_input, mm_output1, mm_output2, mm_output3);
    208             store_characters_x3(mm_output1, mm_output2, mm_output3, buf);
     214            store_characters_x3(mm_output1, mm_output2, mm_output3, b);
    209215        }
    210216
    211217        _mm256_zeroall(); // need to zero all ymm registers to avoid register spills/restores the compler generates around the function call
     
    245251
    246252} // namespace
    247253
    248 void dump_data_char_avx2(const void* data, std::size_t size, std::basic_ostream< char >& strm)
     254BOOST_LOG_AUX_TARGET_ATTRIB void dump_data_char_avx2(const void* data, std::size_t size, std::basic_ostream< char >& strm)
    249255{
    250256    if (size >= 32)
    251257    {
     
    257263    }
    258264}
    259265
    260 void dump_data_wchar_avx2(const void* data, std::size_t size, std::basic_ostream< wchar_t >& strm)
     266BOOST_LOG_AUX_TARGET_ATTRIB void dump_data_wchar_avx2(const void* data, std::size_t size, std::basic_ostream< wchar_t >& strm)
    261267{
    262268    if (size >= 32)
    263269    {
     
    270276}
    271277
    272278#if !defined(BOOST_NO_CXX11_CHAR16_T)
    273 void dump_data_char16_avx2(const void* data, std::size_t size, std::basic_ostream< char16_t >& strm)
     279BOOST_LOG_AUX_TARGET_ATTRIB void dump_data_char16_avx2(const void* data, std::size_t size, std::basic_ostream< char16_t >& strm)
    274280{
    275281    if (size >= 32)
    276282    {
     
    284290#endif
    285291
    286292#if !defined(BOOST_NO_CXX11_CHAR32_T)
    287 void dump_data_char32_avx2(const void* data, std::size_t size, std::basic_ostream< char32_t >& strm)
     293BOOST_LOG_AUX_TARGET_ATTRIB void dump_data_char32_avx2(const void* data, std::size_t size, std::basic_ostream< char32_t >& strm)
    288294{
    289295    if (size >= 32)
    290296    {
  • libs/log/src/dump_ssse3.cpp

    old new  
    2222#include <boost/log/detail/config.hpp>
    2323#include <boost/log/detail/header.hpp>
    2424
     25#if ((BOOST_GCC + 0) / 100) >= 405
     26#define BOOST_LOG_AUX_TARGET_ATTRIB __attribute__((target("ssse3,arch=core2")))
     27#else
     28#define BOOST_LOG_AUX_TARGET_ATTRIB
     29#endif
     30
    2531namespace boost {
    2632
    2733BOOST_LOG_OPEN_NAMESPACE
     
    5763static const xmm_constant mm_shuffle_pattern3 = {{ 5, 0x80, 6, 7, 0x80, 8, 9, 0x80, 10, 11, 0x80, 12, 13, 0x80, 14, 15 }};
    5864
    5965//! Dumps a pack of input data into a string of 8 bit ASCII characters
    60 static BOOST_FORCEINLINE void dump_pack(__m128i mm_char_10_to_a, __m128i mm_input, __m128i& mm_output1, __m128i& mm_output2, __m128i& mm_output3)
     66static BOOST_FORCEINLINE BOOST_LOG_AUX_TARGET_ATTRIB void dump_pack(__m128i mm_char_10_to_a, __m128i mm_input, __m128i& mm_output1, __m128i& mm_output2, __m128i& mm_output3)
    6167{
    6268    // Split half-bytes
    6369    __m128i mm_input_hi = _mm_and_si128(_mm_srli_epi16(mm_input, 4), mm_15.as_mm);
     
    95101}
    96102
    97103template< typename CharT >
    98 BOOST_FORCEINLINE void store_characters(__m128i mm_chars, CharT* buf)
     104BOOST_FORCEINLINE BOOST_LOG_AUX_TARGET_ATTRIB void store_characters(__m128i mm_chars, CharT* buf)
    99105{
    100106    switch (sizeof(CharT))
    101107    {
     
    126132}
    127133
    128134template< typename CharT >
    129 BOOST_FORCEINLINE void dump_data_ssse3(const void* data, std::size_t size, std::basic_ostream< CharT >& strm)
     135BOOST_FORCEINLINE BOOST_LOG_AUX_TARGET_ATTRIB void dump_data_ssse3(const void* data, std::size_t size, std::basic_ostream< CharT >& strm)
    130136{
    131137    typedef CharT char_type;
    132138
     
    210216
    211217} // namespace
    212218
    213 void dump_data_char_ssse3(const void* data, std::size_t size, std::basic_ostream< char >& strm)
     219BOOST_LOG_AUX_TARGET_ATTRIB void dump_data_char_ssse3(const void* data, std::size_t size, std::basic_ostream< char >& strm)
    214220{
    215221    if (size >= 16)
    216222    {
     
    222228    }
    223229}
    224230
    225 void dump_data_wchar_ssse3(const void* data, std::size_t size, std::basic_ostream< wchar_t >& strm)
     231BOOST_LOG_AUX_TARGET_ATTRIB void dump_data_wchar_ssse3(const void* data, std::size_t size, std::basic_ostream< wchar_t >& strm)
    226232{
    227233    if (size >= 16)
    228234    {
     
    235241}
    236242
    237243#if !defined(BOOST_NO_CXX11_CHAR16_T)
    238 void dump_data_char16_ssse3(const void* data, std::size_t size, std::basic_ostream< char16_t >& strm)
     244BOOST_LOG_AUX_TARGET_ATTRIB void dump_data_char16_ssse3(const void* data, std::size_t size, std::basic_ostream< char16_t >& strm)
    239245{
    240246    if (size >= 16)
    241247    {
     
    249255#endif
    250256
    251257#if !defined(BOOST_NO_CXX11_CHAR32_T)
    252 void dump_data_char32_ssse3(const void* data, std::size_t size, std::basic_ostream< char32_t >& strm)
     258BOOST_LOG_AUX_TARGET_ATTRIB void dump_data_char32_ssse3(const void* data, std::size_t size, std::basic_ostream< char32_t >& strm)
    253259{
    254260    if (size >= 16)
    255261    {