<commit_before>// ======================================================================== //
// Copyright 2009-2014 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

#include "common/default.h"

namespace embree
{
  /*! Implements a data buffer. */
  class Buffer
  {
  public:

    /*! Buffer construction */
    Buffer (); 
    
    /*! Buffer destruction */
    ~Buffer ();
      
  public:
    
    /*! initialized the buffer */
    void init(size_t num_in, size_t stride_in);

    /*! sets shared buffer */
    void set(void* ptr_in, size_t ofs_in, size_t stride_in);

    /*! sets shared buffer */
    void set(void* ptr);

    /*! allocated buffer */
    void alloc();

    /*! fees the buffer */
    void free();

    /*! maps the buffer */
    void* map(atomic_t& cntr);
    
    /*! unmaps the buffer */
    void unmap(atomic_t& cntr);

    /*! checks if the buffer is mapped */
    __forceinline bool isMapped() const {
      return mapped; 
    }

    /*! returns the number of elements of the buffer */
    size_t size() const { 
      return num; 
    }

    __forceinline operator bool() { 
      return ptr; 
    }

  protected:
    char* ptr;       //!< pointer to buffer data
    size_t bytes;    //!< size of buffer in bytes
    char* ptr_ofs;   //!< base pointer plus offset

#if defined(__MIC__)
    unsigned int stride;
#else
    size_t stride;   //!< stride of the stream in bytes
#endif
    size_t num;      //!< number of elements in the stream
    bool shared;     //!< set if memory is shared with application
    bool mapped;     //!< set if buffer is mapped
  };

  /*! Implements a data stream inside a data buffer. */
  template<typename T>
    class BufferT : public Buffer
  {
  public:

    typedef T value_type;

    /*! access to the ith element of the buffer stream */
    __forceinline const T& operator[](size_t i) const 
    {
      assert(i<num);
#if defined(RTCORE_BUFFER_STRIDE)
      return *(T*)(ptr_ofs + i*stride);
#else
      return *(T*)(ptr_ofs + i*sizeof(T));
#endif
    }

    __forceinline char* getPtr( size_t i = 0 ) const 
    {
#if defined(RTCORE_BUFFER_STRIDE)
      return ptr_ofs + i*stride;
#else
      return ptr_ofs + i*sizeof(T);
#endif
    }

    __forceinline unsigned int getBufferStride() const {
#if defined(RTCORE_BUFFER_STRIDE)
      return stride;
#else
      return sizeof(T);
#endif
    }
  };

  /*! Implements a data stream inside a data buffer. */
  template<>
    class BufferT<Vec3fa> : public Buffer
  {
  public:

    typedef Vec3fa value_type;

    /*! access to the ith element of the buffer stream */
    __forceinline const Vec3fa operator[](size_t i) const
    {
      assert(i<num);
#if defined(RTCORE_BUFFER_STRIDE)
#if defined(__MIC__)
      return *(Vec3fa*)(ptr_ofs + i*stride);
#else
      return Vec3fa(ssef::loadu(ptr_ofs + i*stride));
#endif
#else
      return *(Vec3fa*)(ptr_ofs + i*sizeof(Vec3fa));
#endif
    }

    __forceinline char* getPtr( size_t i = 0 ) const 
    {
#if defined(RTCORE_BUFFER_STRIDE)
      return ptr_ofs + i*stride;
#else
      return ptr_ofs + i*sizeof(Vec3fa);
#endif
    }

    __forceinline unsigned int getBufferStride() const {
#if defined(RTCORE_BUFFER_STRIDE)
      return stride;
#else
      return sizeof(T);
#endif
    }
  };
}
<commit_msg>Compile fix when RTCORE_BUFFER_STRIDE=off<commit_after>// ======================================================================== //
// Copyright 2009-2014 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

#include "common/default.h"

namespace embree
{
  /*! Implements a data buffer. */
  class Buffer
  {
  public:

    /*! Buffer construction */
    Buffer (); 
    
    /*! Buffer destruction */
    ~Buffer ();
      
  public:
    
    /*! initialized the buffer */
    void init(size_t num_in, size_t stride_in);

    /*! sets shared buffer */
    void set(void* ptr_in, size_t ofs_in, size_t stride_in);

    /*! sets shared buffer */
    void set(void* ptr);

    /*! allocated buffer */
    void alloc();

    /*! fees the buffer */
    void free();

    /*! maps the buffer */
    void* map(atomic_t& cntr);
    
    /*! unmaps the buffer */
    void unmap(atomic_t& cntr);

    /*! checks if the buffer is mapped */
    __forceinline bool isMapped() const {
      return mapped; 
    }

    /*! returns the number of elements of the buffer */
    size_t size() const { 
      return num; 
    }

    __forceinline operator bool() { 
      return ptr; 
    }

  protected:
    char* ptr;       //!< pointer to buffer data
    size_t bytes;    //!< size of buffer in bytes
    char* ptr_ofs;   //!< base pointer plus offset

#if defined(__MIC__)
    unsigned int stride;
#else
    size_t stride;   //!< stride of the stream in bytes
#endif
    size_t num;      //!< number of elements in the stream
    bool shared;     //!< set if memory is shared with application
    bool mapped;     //!< set if buffer is mapped
  };

  /*! Implements a data stream inside a data buffer. */
  template<typename T>
    class BufferT : public Buffer
  {
  public:

    typedef T value_type;

    /*! access to the ith element of the buffer stream */
    __forceinline const T& operator[](size_t i) const 
    {
      assert(i<num);
#if defined(RTCORE_BUFFER_STRIDE)
      return *(T*)(ptr_ofs + i*stride);
#else
      return *(T*)(ptr_ofs + i*sizeof(T));
#endif
    }

    __forceinline char* getPtr( size_t i = 0 ) const 
    {
#if defined(RTCORE_BUFFER_STRIDE)
      return ptr_ofs + i*stride;
#else
      return ptr_ofs + i*sizeof(T);
#endif
    }

    __forceinline unsigned int getBufferStride() const {
#if defined(RTCORE_BUFFER_STRIDE)
      return stride;
#else
      return sizeof(T);
#endif
    }
  };

  /*! Implements a data stream inside a data buffer. */
  template<>
    class BufferT<Vec3fa> : public Buffer
  {
  public:

    typedef Vec3fa value_type;

    /*! access to the ith element of the buffer stream */
    __forceinline const Vec3fa operator[](size_t i) const
    {
      assert(i<num);
#if defined(RTCORE_BUFFER_STRIDE)
#if defined(__MIC__)
      return *(Vec3fa*)(ptr_ofs + i*stride);
#else
      return Vec3fa(ssef::loadu(ptr_ofs + i*stride));
#endif
#else
      return *(Vec3fa*)(ptr_ofs + i*sizeof(Vec3fa));
#endif
    }

    __forceinline char* getPtr( size_t i = 0 ) const 
    {
#if defined(RTCORE_BUFFER_STRIDE)
      return ptr_ofs + i*stride;
#else
      return ptr_ofs + i*sizeof(Vec3fa);
#endif
    }

    __forceinline unsigned int getBufferStride() const {
#if defined(RTCORE_BUFFER_STRIDE)
      return stride;
#else
      return sizeof(Vec3fa);
#endif
    }
  };
}

{'fraction_non_alphanumeric': 0.13613832853025937, 'fraction_numerical': 0.005187319884726225, 'mean_word_length': 1.9510204081632654, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 9, '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': '3183719', 'n_tokens_mistral': 2463, 'n_tokens_neox': 2355, 'n_words': 785}