<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.                                           //
// ======================================================================== //

#include "ospray/common/OSPCommon.h"
#include "ospray/include/ospray/ospray.h"
#include "ospray/render/Renderer.h"
#include "ospray/camera/Camera.h"
#include "ospray/common/Material.h"
#include "ospray/volume/Volume.h"
#include "ospray/transferFunction/TransferFunction.h"
#include "LocalDevice.h"
#include "ospray/common/Core.h"

#ifdef _WIN32
#  include <process.h> // for getpid
#endif

#if 1
# define LOG(a) if (ospray::logLevel > 2) std::cout << "#ospray: " << a << std::endl;
#else
# define LOG(a) /*ignore*/
#endif

/*! \file api.cpp implements the public ospray api functions by
  routing them to a respective \ref device */
namespace ospray {

  using std::endl;
  using std::cout;

#ifdef OSPRAY_MPI
  namespace mpi {
    ospray::api::Device *createMPI_ListenForWorkers(int *ac, const char **av,
                                                    const char *fileNameToStorePortIn);
    ospray::api::Device *createMPI_LaunchWorkerGroup(int *ac, const char **av,
                                                     const char *launchCommand);
    ospray::api::Device *createMPI_runOnExistingRanks(int *ac, const char **av,
                                                      bool ranksBecomeWorkers);
    ospray::api::Device *createMPI_RanksBecomeWorkers(int *ac, const char **av)
    { return createMPI_runOnExistingRanks(ac,av,true); }

    void initDistributedAPI(int *ac, char ***av, OSPDRenderMode mpiMode);
  }
#endif

#ifdef OSPRAY_MIC_COI
  namespace coi {
    ospray::api::Device *createCoiDevice(int *ac, const char **av);
  }
#endif

} // ::ospray

  std::string getPidString() {
    char s[100];
    sprintf(s, "(pid %i)", getpid());
    return s;
  }

#define ASSERT_DEVICE() if (ospray::api::Device::current == NULL)       \
    throw std::runtime_error("OSPRay not yet initialized "              \
                             "(most likely this means you tried to "    \
                             "call an ospray API function before "      \
                             "first calling ospInit())"+getPidString());

  using namespace ospray;

  extern "C" void ospInit(int *_ac, const char **_av)
  {
    if (ospray::api::Device::current)
      throw std::runtime_error("OSPRay error: device already exists "
                               "(did you call ospInit twice?)");<commit_msg>add conadd environment variable to set number of threads used by ospray<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.                                           //
// ======================================================================== //

#include "ospray/common/OSPCommon.h"
#include "ospray/include/ospray/ospray.h"
#include "ospray/render/Renderer.h"
#include "ospray/camera/Camera.h"
#include "ospray/common/Material.h"
#include "ospray/volume/Volume.h"
#include "ospray/transferFunction/TransferFunction.h"
#include "LocalDevice.h"
#include "ospray/common/Core.h"

#ifdef _WIN32
#  include <process.h> // for getpid
#endif

#if 1
# define LOG(a) if (ospray::logLevel > 2) std::cout << "#ospray: " << a << std::endl;
#else
# define LOG(a) /*ignore*/
#endif

/*! \file api.cpp implements the public ospray api functions by
  routing them to a respective \ref device */
namespace ospray {

  using std::endl;
  using std::cout;

#ifdef OSPRAY_MPI
  namespace mpi {
    ospray::api::Device *createMPI_ListenForWorkers(int *ac, const char **av,
                                                    const char *fileNameToStorePortIn);
    ospray::api::Device *createMPI_LaunchWorkerGroup(int *ac, const char **av,
                                                     const char *launchCommand);
    ospray::api::Device *createMPI_runOnExistingRanks(int *ac, const char **av,
                                                      bool ranksBecomeWorkers);
    ospray::api::Device *createMPI_RanksBecomeWorkers(int *ac, const char **av)
    { return createMPI_runOnExistingRanks(ac,av,true); }

    void initDistributedAPI(int *ac, char ***av, OSPDRenderMode mpiMode);
  }
#endif

#ifdef OSPRAY_MIC_COI
  namespace coi {
    ospray::api::Device *createCoiDevice(int *ac, const char **av);
  }
#endif

} // ::ospray

  std::string getPidString() {
    char s[100];
    sprintf(s, "(pid %i)", getpid());
    return s;
  }

#define ASSERT_DEVICE() if (ospray::api::Device::current == NULL)       \
    throw std::runtime_error("OSPRay not yet initialized "              \
                             "(most likely this means you tried to "    \
                             "call an ospray API function before "      \
                             "first calling ospInit())"+getPidString());

  using namespace ospray;

  extern "C" void ospInit(int *_ac, const char **_av)
  {
    if (ospray::api::Device::current) {
      throw std::runtime_error("OSPRay error: device already exists "
                               "(did you call ospInit twice?)");
    }

    auto *nThreads = getenv("OSPRAY_THREADS");
    if (nThreads) {
      numThreads = atoi(nThreads);
    }
{'fraction_non_alphanumeric': 0.14769102759672723, 'fraction_numerical': 0.005269726806268201, 'mean_word_length': 1.875598086124402, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 38, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '873047', 'n_tokens_mistral': 1949, 'n_tokens_neox': 1876, 'n_words': 545}