<commit_before>#ifdef __CUDACC__
#define USE_CUDA
#endif

#include <cmath>   // smallpt, a Path Tracer by <NAME>, 2008
#include <cstdlib> // Make : g++ -O3 -fopenmp smallpt.cpp -o smallpt
#include <chrono>
#include <cstdio>  //        Remove "-fopenmp" for g++ version < 4.2

#include <stack>
#include <vector>
#include <cassert>

#include <agency/execution_policy.hpp>
#ifdef USE_CUDA
#include <agency/cuda/execution_policy.hpp>
#endif

#ifndef __host__
#define __host__
#define HOST_NEED_UNDEF
#endif

#ifndef __device__
#define __device__
#define DEVICE_NEED_UNDEF
#endif


struct Rand48
{
  __host__ __device__
  double drand()
  {
    update();
    return (stat & 0xFFFFFFFFFFFFULL) * (1.0 / 281474976710656.0);
  }
  __host__ __device__
  long lrand()
  {
    update();
    return (long)(stat >> 17) & 0x7FFFFFFFULL;
  }
  __host__ __device__
  long mrand()
  {
    update();
    return (long)(stat >> 16) & 0xFFFFFFFFULL;
  }
  __host__ __device__
  void srand(const long seed) { stat = (seed << 16) + 0x330EFULL; }
  __host__ __device__
  Rand48(const long seed = 0) { srand(seed); }

private:
  unsigned long long stat;
  __host__ __device__
  void update() { stat = stat * 0x5DEECE66DULL + 0xBULL; }
};

#if 0
using real = double;
#define EPS (1.0e-4)
#define RR  (1.0e5)
#else
using real = float;
#define EPS (1.0e-2)
#define RR  (1.0e4)
#endif

struct Vec 
{        // Usage: time ./smallpt 5000 && xv image.ppm
  real x, y, z;                  // position, also color (r,g,b)
  __host__ __device__
  Vec(real x_=0, real y_=0, real z_=0) : x(x_), y(y_), z(z_) {}
  __host__ __device__
  Vec operator+(const Vec &b) const { return Vec(x+b.x,y+b.y,z+b.z); }
  __host__ __device__
  Vec operator-(const Vec &b) const { return Vec(x-b.x,y-b.y,z-b.z); }
  __host__ __device__
  Vec operator*(const real b) const { return Vec(x*b,y*b,z*b); }
  __host__ __device__
  Vec mult(const Vec &b) const { return Vec(x*b.x,y*b.y,z*b.z); }
  __host__ __device__
  Vec& norm() { return *this = *this * (1/sqrt(x*x+y*y+z*z)); }
  __host__ __device__
  real dot(const Vec &b) const { return x*b.x+y*b.y+z*b.z; } // cross:
  __host__ __device__
  Vec operator%(Vec&b){return Vec(y*b.z-z*b.y,z*b.x-x*b.z,x*b.y-y*b.x);}
};

struct Ray 
{ 
  Vec o, d; <commit_msg>improve acc<commit_after>#ifdef __CUDACC__
#define USE_CUDA
#endif

#include <cmath>   // smallpt, a Path Tracer by <NAME>, 2008
#include <cstdlib> // Make : g++ -O3 -fopenmp smallpt.cpp -o smallpt
#include <chrono>
#include <cstdio>  //        Remove "-fopenmp" for g++ version < 4.2

#include <stack>
#include <vector>
#include <cassert>

#include <agency/execution_policy.hpp>
#ifdef USE_CUDA
#include <agency/cuda/execution_policy.hpp>
#endif

#ifndef __host__
#define __host__
#define HOST_NEED_UNDEF
#endif

#ifndef __device__
#define __device__
#define DEVICE_NEED_UNDEF
#endif


struct Rand48
{
  __host__ __device__
  double drand()
  {
    update();
    return (stat & 0xFFFFFFFFFFFFULL) * (1.0 / 281474976710656.0);
  }
  __host__ __device__
  long lrand()
  {
    update();
    return (long)(stat >> 17) & 0x7FFFFFFFULL;
  }
  __host__ __device__
  long mrand()
  {
    update();
    return (long)(stat >> 16) & 0xFFFFFFFFULL;
  }
  __host__ __device__
  void srand(const long seed) { stat = (seed << 16) + 0x330EFULL; }
  __host__ __device__
  Rand48(const long seed = 0) { srand(seed); }

private:
  unsigned long long stat;
  __host__ __device__
  void update() { stat = stat * 0x5DEECE66DULL + 0xBULL; }
};

#if 0
using real = double;
#define EPS (1.0e-4)
#define RR  (1.0e5)
#else
using real = float;
#define EPS (1.5e-2)
#define RR  (1.0e4)
#endif

struct Vec 
{        // Usage: time ./smallpt 5000 && xv image.ppm
  real x, y, z;                  // position, also color (r,g,b)
  __host__ __device__
  Vec(real x_=0, real y_=0, real z_=0) : x(x_), y(y_), z(z_) {}
  __host__ __device__
  Vec operator+(const Vec &b) const { return Vec(x+b.x,y+b.y,z+b.z); }
  __host__ __device__
  Vec operator-(const Vec &b) const { return Vec(x-b.x,y-b.y,z-b.z); }
  __host__ __device__
  Vec operator*(const real b) const { return Vec(x*b,y*b,z*b); }
  __host__ __device__
  Vec mult(const Vec &b) const { return Vec(x*b.x,y*b.y,z*b.z); }
  __host__ __device__
  Vec& norm() { return *this = *this * (1/sqrt(x*x+y*y+z*z)); }
  __host__ __device__
  real dot(const Vec &b) const { return x*b.x+y*b.y+z*b.z; } // cross:
  __host__ __device__
  Vec operator%(Vec&b){return Vec(y*b.z-z*b.y,z*b.x-x*b.z,x*b.y-y*b.x);}
};

struct Ray 
{ 
  Vec o, d; 
{'fraction_non_alphanumeric': 0.152753108348135, 'fraction_numerical': 0.03108348134991119, 'mean_word_length': 3.496007984031936, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, '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': '6111328', 'n_tokens_mistral': 1999, 'n_tokens_neox': 1884, 'n_words': 467}