<commit_before>// ======================================================================== //
// Copyright 2009-2015 Intel Corporation                                    //
//                                                                          //
// Licensed under the Apache License, Version 2.0 (the "License");          //
// you may not use this file except in compliance with the License.         //
// You may obtain a copy of the License at                                  //
//                                                                          //
//     http://www.apache.org/licenses/LICENSE-2.0                           //
//                                                                          //
// Unless required by applicable law or agreed to in writing, software      //
// distributed under the License is distributed on an "AS IS" BASIS,        //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and      //
// limitations under the License.                                           //
// ======================================================================== //

#pragma once

namespace embree
{ 
  /*! 16-wide MIC integer type. */
  class int16
  {
  public:
    
    union  { 
      __m512i v; 
      int i[16]; 
    };
    
    ////////////////////////////////////////////////////////////////////////////////
    /// Constructors, Assignment & Cast Operators
    ////////////////////////////////////////////////////////////////////////////////
       
    __forceinline int16() {};
    __forceinline int16(const int16& t) { v = t.v; };
    __forceinline int16& operator=(const int16& f) { v = f.v; return *this; };

    __forceinline int16(const __m512i& t) { v = t; };
    __forceinline operator __m512i () const { return v; };

    __forceinline int16(const int i) { 
      v = _mm512_set_1to16_epi32(i);
    }
    
    __forceinline int16(const int a, const int b, const int c, const int d) { 
      v = _mm512_set_4to16_epi32(a,b,c,d);      
    }
   
    __forceinline explicit int16(const __m512 f) { 
#if defined(__AVX512__)
      v = _mm512_cvt_roundps_epi32(f,_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC); // FIXME: round down as default?
#else
      v = _mm512_cvtfxpnt_round_adjustps_epi32(f,_MM_FROUND_FLOOR,_MM_EXPADJ_NONE);
#endif
    }
    
    ////////////////////////////////////////////////////////////////////////////////
    /// Constants
    ////////////////////////////////////////////////////////////////////////////////
    
    __forceinline int16( ZeroTy   ) : v(_mm512_setzero_epi32()) {}
    __forceinline int16( OneTy    ) : v(_mm512_set_1to16_epi32(1)) {}
    __forceinline int16( PosInfTy ) : v(_mm512_set_1to16_epi32(pos_inf)) {}
    __forceinline int16( NegInfTy ) : v(_mm512_set_1to16_epi32(neg_inf)) {}
    __forceinline int16( StepTy )   : v(_mm512_set_16to16_epi32(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)) {}

    __forceinline static int16 zero() { return _mm512_setzero_epi32(); }
    __forceinline static int16 one () { return _mm512_set_1to16_epi32(1); }
    __forceinline static int16 neg_one () { return _mm512_set_1to16_epi32(-1); }


    static __forceinline int16 loadu(const void* addr) 
    {
#if defined(__AVX512__)
      return _mm512_loadu_si512(addr);
#else
      int16 r = _mm512_undefined_epi32();
      r =_mm512_extloadunpacklo_epi32(r, addr, _MM_UPCONV_EPI32_NONE, _MM_HINT_NONE);
      return _mm512_extloadunpackhi_epi32(r, (int*)addr+16, _MM_UPCONV_EPI32_NONE, _MM_HINT_NONE);  
#endif
    }

    static __forceinline int16 load(const void* addr) {
      return _mm512_load_si512(addr);
    }

    static __forceinline void store(void* addr, const int16& v2) {
      _mm512_extstore_epi32(addr,v2,_MM_DOWNCONV_EPI32_NONE,_MM_HINT_NONE);
    }

    static __forceinline void storeu(void* ptr, const int16& f ) { 
#if defined(__AVX512__)
       _mm512_storeu_si512(ptr,f);
#else
       _mm512_extpackstorelo_ps(ptr+0  ,_mm512_castsi512_ps(f), _MM_DOWNCONV_PS_NONE , 0);
       _mm512_extpackstorehi_ps(ptr+16 ,_mm512_castsi512_ps(f), _MM_DOWNCONV_PS_NONE , 0);
#endif
    }

    static __forceinline void storeu(const bool16& mask, int* ptr, const int16& f ) { 
#if defined(__AVX512__)
      _mm512_mask_storeu_epi32(ptr,mask,f);
#else<commit_msg>bugfix for Xeon Phi<commit_after>// ======================================================================== //
// Copyright 2009-2015 Intel Corporation                                    //
//                                                                          //
// Licensed under the Apache License, Version 2.0 (the "License");          //
// you may not use this file except in compliance with the License.         //
// You may obtain a copy of the License at                                  //
//                                                                          //
//     http://www.apache.org/licenses/LICENSE-2.0                           //
//                                                                          //
// Unless required by applicable law or agreed to in writing, software      //
// distributed under the License is distributed on an "AS IS" BASIS,        //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and      //
// limitations under the License.                                           //
// ======================================================================== //

#pragma once

namespace embree
{ 
  /*! 16-wide MIC integer type. */
  class int16
  {
  public:
    
    union  { 
      __m512i v; 
      int i[16]; 
    };
    
    ////////////////////////////////////////////////////////////////////////////////
    /// Constructors, Assignment & Cast Operators
    ////////////////////////////////////////////////////////////////////////////////
       
    __forceinline int16() {};
    __forceinline int16(const int16& t) { v = t.v; };
    __forceinline int16& operator=(const int16& f) { v = f.v; return *this; };

    __forceinline int16(const __m512i& t) { v = t; };
    __forceinline operator __m512i () const { return v; };

    __forceinline int16(const int i) { 
      v = _mm512_set_1to16_epi32(i);
    }
    
    __forceinline int16(const int a, const int b, const int c, const int d) { 
      v = _mm512_set_4to16_epi32(a,b,c,d);      
    }
   
    __forceinline explicit int16(const __m512 f) { 
#if defined(__AVX512__)
      v = _mm512_cvt_roundps_epi32(f,_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC); // FIXME: round down as default?
#else
      v = _mm512_cvtfxpnt_round_adjustps_epi32(f,_MM_FROUND_FLOOR,_MM_EXPADJ_NONE);
#endif
    }
    
    ////////////////////////////////////////////////////////////////////////////////
    /// Constants
    ////////////////////////////////////////////////////////////////////////////////
    
    __forceinline int16( ZeroTy   ) : v(_mm512_setzero_epi32()) {}
    __forceinline int16( OneTy    ) : v(_mm512_set_1to16_epi32(1)) {}
    __forceinline int16( PosInfTy ) : v(_mm512_set_1to16_epi32(pos_inf)) {}
    __forceinline int16( NegInfTy ) : v(_mm512_set_1to16_epi32(neg_inf)) {}
    __forceinline int16( StepTy )   : v(_mm512_set_16to16_epi32(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)) {}

    __forceinline static int16 zero() { return _mm512_setzero_epi32(); }
    __forceinline static int16 one () { return _mm512_set_1to16_epi32(1); }
    __forceinline static int16 neg_one () { return _mm512_set_1to16_epi32(-1); }


    static __forceinline int16 loadu(const void* addr) 
    {
#if defined(__AVX512__)
      return _mm512_loadu_si512(addr);
#else
      int16 r = _mm512_undefined_epi32();
      r =_mm512_extloadunpacklo_epi32(r, addr, _MM_UPCONV_EPI32_NONE, _MM_HINT_NONE);
      return _mm512_extloadunpackhi_epi32(r, (int*)addr+16, _MM_UPCONV_EPI32_NONE, _MM_HINT_NONE);  
#endif
    }

    static __forceinline int16 load(const void* addr) {
      return _mm512_load_si512(addr);
    }

    static __forceinline void store(void* addr, const int16& v2) {
      _mm512_extstore_epi32(addr,v2,_MM_DOWNCONV_EPI32_NONE,_MM_HINT_NONE);
    }

    static __forceinline void storeu(void* ptr, const int16& f ) { 
#if defined(__AVX512__)
       _mm512_storeu_si512(ptr,f);
#else
       _mm512_extpackstorelo_ps((int*)ptr+0  ,_mm512_castsi512_ps(f), _MM_DOWNCONV_PS_NONE , 0);
       _mm512_extpackstorehi_ps((int*)ptr+16 ,_mm512_castsi512_ps(f), _MM_DOWNCONV_PS_NONE , 0);
#endif
    }

    static __forceinline void storeu(const bool16& mask, int* ptr, const int16& f ) { 
#if defined(__AVX512__)
      _mm512_mask_storeu_epi32(ptr,mask,f);
#else
{'fraction_non_alphanumeric': 0.19674012855831038, 'fraction_numerical': 0.06336088154269973, 'mean_word_length': 1.85297969875573, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '742697', 'n_tokens_mistral': 3016, 'n_tokens_neox': 2620, 'n_words': 580}