<commit_before>// Copyright 2017 Netherlands Institute for Radio Astronomy (ASTRON)
// Copyright 2017 Netherlands eScience Center
//
// 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 <iostream>
#include <string>
#include <vector>
#include <exception>
#include <ctime>

#include <configuration.hpp>

#include <ArgumentList.hpp>
#include <Observation.hpp>
#include <InitializeOpenCL.hpp>
#include <Kernel.hpp>
#include <utils.hpp>
#include <Integration.hpp>


int main(int argc, char *argv[]) {
  bool printCode = false;
  bool printResults = false;
  bool random = false;
  bool DMsSamples = false;
  bool inPlace = false;
  bool beforeDedispersion = false;
  unsigned int padding = 0;
  unsigned int integration = 0;
  unsigned int clPlatformID = 0;
  unsigned int clDeviceID = 0;
  uint64_t wrongSamples = 0;
  Integration::integrationConf conf;
  AstroData::Observation observation;

  try
  {
    isa::utils::ArgumentList args(argc, argv);
    // Modes
    inPlace = args.getSwitch("-in_place");
    if ( inPlace )
    {
      beforeDedispersion = args.getSwitch("-before_dedispersion");
      bool afterDedispersion = args.getSwitch("-after_dedispersion");
      if ( (beforeDedispersion && afterDedispersion) || (!beforeDedispersion && !afterDedispersion) )
      {
        std::cerr << "-before_dedispersion and -after_dedispersion are mutually exclusive." << std::endl;
        return 1;
      }
    }
    else
    {
      DMsSamples = args.getSwitch("-dms_samples");
      bool samplesDMs = args.getSwitch("-samples_dms");
      if ( (DMsSamples && samplesDMs) || (!DMsSamples && !samplesDMs) )
      {
        std::cerr << "-dms_samples and -samples_dms are mutually exclusive." << std::endl;
        return 1;
      }
    }
    printCode = args.getSwitch("-print_code");
    printResults = args.getSwitch("-print_results");
    random = args.getSwitch("-random");
    // OpenCL
    clPlatformID = args.getSwitchArgument< unsigned int >("-opencl_platform");
    clDeviceID = args.getSwitchArgument< unsigned int >("-opencl_device");
    // Configuration
    conf.setNrThreadsD0(args.getSwitchArgument< unsigned int >("-threadsD0"));
    conf.setNrItemsD0(args.getSwitchArgument< unsigned int >("-itemsD0"));
    conf.setIntType(args.getSwitchArgument<unsigned int>("-int_type"));
    // Scenario
    padding = args.getSwitchArgument< unsigned int >("-padding");
    integration = args.getSwitchArgument< unsigned int >("-integration");
    observation.setNrSynthesizedBeams(args.getSwitchArgument< unsigned int >("-beams"));
    observation.setNrSamplesPerBatch(args.getSwitchArgument< unsigned int >("-samples"));
    if ( inPlace && beforeDedispersion )
    {
      observation.setFrequencyRange(1, args.getSwitchArgument<unsigned int>("-channels"), 0.0f, 0.0f);
      observation.setNrSamplesPerDispersedBatch(observation.getNrSamplesPerBatch());
      observation.setNrBeams(observation.getNrSynthesizedBeams());
      conf.setSubbandDedispersion(args.getSwitch("-subband"));
    }
    else
    {
      conf.setSubbandDedispersion(args.getSwitch("-subband"));
      if ( conf.getSubbandDedispersion() )
      {
        observation.setDMRange(args.getSwitchArgument< unsigned int >("-subbanding_dms"), 0.0f, 0.0f, true);
      }
      else
      {
        observation.setDMRange(1, 0.0f, 0.0f, true);
      }
      observation.setDMRange(args.getSwitchArgument< unsigned int >("-dms"), 0.0f, 0.0f);
    }
  }
  catch  ( isa::utils::SwitchNotFound & err )
  {
    std::cerr << err.what() << std::endl;
    return 1;
  }
  catch ( std::exception & err )
  {<commit_msg>Fixing a bug with subband mode.<commit_after>// Copyright 2017 Netherlands Institute for Radio Astronomy (ASTRON)
// Copyright 2017 Netherlands eScience Center
//
// 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 <iostream>
#include <string>
#include <vector>
#include <exception>
#include <ctime>

#include <configuration.hpp>

#include <ArgumentList.hpp>
#include <Observation.hpp>
#include <InitializeOpenCL.hpp>
#include <Kernel.hpp>
#include <utils.hpp>
#include <Integration.hpp>


int main(int argc, char *argv[]) {
  bool printCode = false;
  bool printResults = false;
  bool random = false;
  bool DMsSamples = false;
  bool inPlace = false;
  bool beforeDedispersion = false;
  unsigned int padding = 0;
  unsigned int integration = 0;
  unsigned int clPlatformID = 0;
  unsigned int clDeviceID = 0;
  uint64_t wrongSamples = 0;
  Integration::integrationConf conf;
  AstroData::Observation observation;

  try
  {
    isa::utils::ArgumentList args(argc, argv);
    // Modes
    inPlace = args.getSwitch("-in_place");
    if ( inPlace )
    {
      beforeDedispersion = args.getSwitch("-before_dedispersion");
      bool afterDedispersion = args.getSwitch("-after_dedispersion");
      if ( (beforeDedispersion && afterDedispersion) || (!beforeDedispersion && !afterDedispersion) )
      {
        std::cerr << "-before_dedispersion and -after_dedispersion are mutually exclusive." << std::endl;
        return 1;
      }
    }
    else
    {
      DMsSamples = args.getSwitch("-dms_samples");
      bool samplesDMs = args.getSwitch("-samples_dms");
      if ( (DMsSamples && samplesDMs) || (!DMsSamples && !samplesDMs) )
      {
        std::cerr << "-dms_samples and -samples_dms are mutually exclusive." << std::endl;
        return 1;
      }
    }
    printCode = args.getSwitch("-print_code");
    printResults = args.getSwitch("-print_results");
    random = args.getSwitch("-random");
    // OpenCL
    clPlatformID = args.getSwitchArgument< unsigned int >("-opencl_platform");
    clDeviceID = args.getSwitchArgument< unsigned int >("-opencl_device");
    // Configuration
    conf.setNrThreadsD0(args.getSwitchArgument< unsigned int >("-threadsD0"));
    conf.setNrItemsD0(args.getSwitchArgument< unsigned int >("-itemsD0"));
    conf.setIntType(args.getSwitchArgument<unsigned int>("-int_type"));
    // Scenario
    padding = args.getSwitchArgument< unsigned int >("-padding");
    integration = args.getSwitchArgument< unsigned int >("-integration");
    observation.setNrSynthesizedBeams(args.getSwitchArgument< unsigned int >("-beams"));
    observation.setNrSamplesPerBatch(args.getSwitchArgument< unsigned int >("-samples"));
    if ( inPlace && beforeDedispersion )
    {
      observation.setFrequencyRange(1, args.getSwitchArgument<unsigned int>("-channels"), 0.0f, 0.0f);
      observation.setNrBeams(observation.getNrSynthesizedBeams());
      conf.setSubbandDedispersion(args.getSwitch("-subband"));
      if ( conf.getSubbandDedispersion() )
      {
        observation.setNrSamplesPerDispersedBatch(observation.getNrSamplesPerBatch(), true);
      }
      else
      {
        observation.setNrSamplesPerDispersedBatch(observation.getNrSamplesPerBatch());
      }
    }
    else
    {
      conf.setSubbandDedispersion(args.getSwitch("-subband"));
      if ( conf.getSubbandDedispersion() )
      {
        observation.setDMRange(args.getSwitchArgument< unsigned int >("-subbanding_dms"), 0.0f, 0.0f, true);
      }
      else
      {
        observation.setDMRange(1, 0.0f, 0.0f, true);
      }
      observation.setDMRange(args.getSwitchArgument< unsigned int >("-dms"), 0.0f, 0.0f);
    }
  }
  catch  ( isa::utils::SwitchNotFound & err )
  {
    std::cerr << err.what() << std::endl;
    return 1;
  }
  catch ( std::exception & err )
  {
{'fraction_non_alphanumeric': 0.12686300226541075, 'fraction_numerical': 0.01049242875879337, 'mean_word_length': 3.571117166212534, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2724151', 'n_tokens_mistral': 2616, 'n_tokens_neox': 2590, 'n_words': 616}