<commit_before>// ======================================================================== //
// Copyright 2009-2016 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 "../sys/platform.h"
#include "../sys/alloc.h"
#include "../sys/barrier.h"
#include "../sys/thread.h"
#include "../sys/mutex.h"
#include "../sys/condition.h"
#include "../sys/ref.h"
#include "../../kernels/algorithms/range.h"

#if defined(__WIN32__)
#  define NOMINMAX
#  if defined(__clang__) && !defined(__INTEL_COMPILER) 
#    define __MINGW64__ 1
#  endif
#endif

#define TBB_IMPLEMENT_CPP0X 0
#define __TBB_NO_IMPLICIT_LINKAGE 1
#define __TBBMALLOC_NO_IMPLICIT_LINKAGE 1
#include "tbb/tbb.h"

namespace embree
{
#  define SPAWN_BEGIN tbb::task_group __internal_task_group
#  define SPAWN(closure) __internal_task_group.run(closure)
#  define SPAWN_END __internal_task_group.wait();                       \
  if (tbb::task::self().is_cancelled())                                 \
    throw std::runtime_error("task group cancelled");
  
  struct TaskScheduler
  {
    /*! initializes the task scheduler */
    static void create(size_t numThreads, bool set_affinity);

    /*! destroys the task scheduler again */
    static void destroy();
    
    /* returns the index of the current thread */
    static __forceinline size_t threadIndex()
    {
#if TBB_INTERFACE_VERSION_MAJOR < 8
      return 0;<commit_msg>configured TBB to use std::exception_ptr, the default TBB exception capturing shows some invalid reads in valgrind<commit_after>// ======================================================================== //
// Copyright 2009-2016 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 "../sys/platform.h"
#include "../sys/alloc.h"
#include "../sys/barrier.h"
#include "../sys/thread.h"
#include "../sys/mutex.h"
#include "../sys/condition.h"
#include "../sys/ref.h"
#include "../../kernels/algorithms/range.h"

#if defined(__WIN32__)
#  define NOMINMAX
#  if defined(__clang__) && !defined(__INTEL_COMPILER) 
#    define __MINGW64__ 1
#  endif
#endif

#define TBB_IMPLEMENT_CPP0X 0
#define __TBB_NO_IMPLICIT_LINKAGE 1
#define __TBBMALLOC_NO_IMPLICIT_LINKAGE 1
#include "tbb/tbb_config.h"
#undef TBB_USE_CAPTURED_EXCEPTION
#define TBB_USE_CAPTURED_EXCEPTION 0
#undef __TBB_EXCEPTION_PTR_PRESENT
#define __TBB_EXCEPTION_PTR_PRESENT 1
#include "tbb/tbb.h"

namespace embree
{
#  define SPAWN_BEGIN tbb::task_group __internal_task_group
#  define SPAWN(closure) __internal_task_group.run(closure)
#  define SPAWN_END __internal_task_group.wait();                       \
  if (tbb::task::self().is_cancelled())                                 \
    throw std::runtime_error("task group cancelled");
  
  struct TaskScheduler
  {
    /*! initializes the task scheduler */
    static void create(size_t numThreads, bool set_affinity);

    /*! destroys the task scheduler again */
    static void destroy();
    
    /* returns the index of the current thread */
    static __forceinline size_t threadIndex()
    {
#if TBB_INTERFACE_VERSION_MAJOR < 8
      return 0;
{'fraction_non_alphanumeric': 0.1525917297612114, 'fraction_numerical': 0.009318578916715201, 'mean_word_length': 1.9009009009009008, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4532946', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1290, 'n_words': 382}