<commit_before>#include "potent2.h"
#include "dev_mem.h"
#include "dev_mem_reuse.h"
#include "device_utils.h"
#include "global_variables.h"
#include "particle_allocator.h"
#include "pic_utils.h"

#include <cufft.h>

#include <stdio.h>
#include <string>

//******************************************************************************
// Name: checkCufftStatus
// Code Type: Kernel
// Purpose: Check a cufft call for errors. If one is found, in all cases print
//          an error message. If in debug mode, throw an exception, otherwise
//          exit.
// Parameters:
// ----------------
// returnCode - The return code set by a cufft routine
//******************************************************************************
void checkCufftStatus(cufftResult returnCode)
{
   std::string errorString;
   FILE *file;

   switch(returnCode)
   {
   case CUFFT_INVALID_PLAN:
      errorString = "ERROR: CUFFT Invalid Plan";
      break;
   case CUFFT_ALLOC_FAILED:
      errorString = "ERROR: CUFFT Alloc Failed";
      break;
   case CUFFT_INVALID_TYPE:
      errorString = "ERROR: CUFFT Invalid Type";
      break;
   case CUFFT_INVALID_VALUE:
      errorString = "ERROR: CUFFT Invalid Value";
      break;
   case CUFFT_INTERNAL_ERROR:
      errorString = "ERROR: CUFFT Internal Error";
      break;
   case CUFFT_EXEC_FAILED:
      errorString = "ERROR: CUFFT Exec Failed";
      break;
   case CUFFT_SETUP_FAILED:
      errorString = "ERROR: CUFFT Setup Failed";
      break;
   case CUFFT_INVALID_SIZE:
      errorString = "ERROR: CUFFT Invalid Size";
      break;
   };

   if(returnCode != CUFFT_SUCCESS)
   {
      fprintf(stderr, "%s\n", errorString.c_str());
      file = fopen("errorLog.txt", "w");
      fprintf(file,"%s\n", errorString.c_str());
      fclose(file);
      assert(returnCode == CUFFT_SUCCESS);
      exit(1);
   }
}

//******************************************************************************
// Name: initPb
// Code Type: Kernel
// Block Structure: One thread per grid column; Blocks and block size should
//                  be one dimensional
// Shared Memory Requirements: None
// Purpose: Initializes the pb array with voltage P0 and the imaginary
//          components to 0
// Parameters:
// ----------------
// pb - The array of size NX1 to initialize
// P0 - TBD
// size - The size of the array to convert
//******************************************************************************
__global__
void initPb(cufftComplex pb[], const float P0, const unsigned int size)
{
   unsigned int threadX = blockDim.x * blockIdx.x + threadIdx.x;
   cufftComplex val;
   val.x = P0;
   val.y = 0.0;

   if(threadX < size)
   {
      pb[threadX] = val;
   }
}

//******************************************************************************
// Name: loadHarmonics
// Code Type: Kernel
// Block Structure: One thread per grid column
// Shared Memory Requirements: None
// Purpose: Calculates the values for cokx
// Parameters:
// ----------------
// cokx - TBD
// size - Should be set to NX1
//******************************************************************************
__global__
void loadHarmonics(float cokx[], const unsigned int size)
{
   unsigned int threadX = blockDim.x * blockIdx.x + threadIdx.x;
   float num;

   if(threadX < size)
   {
      num = sin(D_PI * threadX / size);
      cokx[threadX]=4*(num*num);
   }
}

//******************************************************************************
// Name: calcPhif
// Code Type: Kernel
// Block Structure: One thread per grid column
// Shared Memory Requirements: None
// Purpose: Calculates the values for phif
// Parameters:
// ----------------
// phif - The phif array which will be set
// z - The z array is an intermediate working array and is expected to be of
//     size NX1 * NY1
// yyy - The yyy array is an intermediate working array and is expected to be of
//       size NX1 * NY1
// cokx - TBD size NX1
// pb - TBD size NX1
// c  - TBD size NX1 * NY1
// NX1 - The number of columns being calculated
// NY1 - The number of rows being calculated
// DX - The spacing between columns
// DY - The spacing between rows
//******************************************************************************
__global__
void calcPhif(cufftComplex phif[],
              float z [],
              cufftComplex yyy[],
              const float cokx[],
              const cufftComplex pb[],
              const cufftComplex c[],
              const unsigned int NX1,
              const unsigned int NY1,
              const float DX,
              const float DY
              )<commit_msg>Fixed an error in a comment<commit_after>#include "potent2.h"
#include "dev_mem.h"
#include "dev_mem_reuse.h"
#include "device_utils.h"
#include "global_variables.h"
#include "particle_allocator.h"
#include "pic_utils.h"

#include <cufft.h>

#include <stdio.h>
#include <string>

//******************************************************************************
// Name: checkCufftStatus
// Code Type: Kernel
// Purpose: Check a cufft call for errors. If one is found, in all cases print
//          an error message. If in debug mode, throw an exception, otherwise
//          exit.
// Parameters:
// ----------------
// returnCode - The return code set by a cufft routine
//******************************************************************************
void checkCufftStatus(cufftResult returnCode)
{
   std::string errorString;
   FILE *file;

   switch(returnCode)
   {
   case CUFFT_INVALID_PLAN:
      errorString = "ERROR: CUFFT Invalid Plan";
      break;
   case CUFFT_ALLOC_FAILED:
      errorString = "ERROR: CUFFT Alloc Failed";
      break;
   case CUFFT_INVALID_TYPE:
      errorString = "ERROR: CUFFT Invalid Type";
      break;
   case CUFFT_INVALID_VALUE:
      errorString = "ERROR: CUFFT Invalid Value";
      break;
   case CUFFT_INTERNAL_ERROR:
      errorString = "ERROR: CUFFT Internal Error";
      break;
   case CUFFT_EXEC_FAILED:
      errorString = "ERROR: CUFFT Exec Failed";
      break;
   case CUFFT_SETUP_FAILED:
      errorString = "ERROR: CUFFT Setup Failed";
      break;
   case CUFFT_INVALID_SIZE:
      errorString = "ERROR: CUFFT Invalid Size";
      break;
   };

   if(returnCode != CUFFT_SUCCESS)
   {
      fprintf(stderr, "%s\n", errorString.c_str());
      file = fopen("errorLog.txt", "w");
      fprintf(file,"%s\n", errorString.c_str());
      fclose(file);
      assert(returnCode == CUFFT_SUCCESS);
      exit(1);
   }
}

//******************************************************************************
// Name: initPb
// Code Type: Kernel
// Block Structure: One thread per grid column; Blocks and block size should
//                  be one dimensional
// Shared Memory Requirements: None
// Purpose: Initializes the pb array with voltage P0 and the imaginary
//          components to 0
// Parameters:
// ----------------
// pb - The array of size NX1 to initialize
// P0 - TBD
// size - The size of the array to convert
//******************************************************************************
__global__
void initPb(cufftComplex pb[], const float P0, const unsigned int size)
{
   unsigned int threadX = blockDim.x * blockIdx.x + threadIdx.x;
   cufftComplex val;
   val.x = P0;
   val.y = 0.0;

   if(threadX < size)
   {
      pb[threadX] = val;
   }
}

//******************************************************************************
// Name: loadHarmonics
// Code Type: Kernel
// Block Structure: One thread per grid column
// Shared Memory Requirements: None
// Purpose: Calculates the values for cokx
// Parameters:
// ----------------
// cokx - TBD
// size - Should be set to NX1
//******************************************************************************
__global__
void loadHarmonics(float cokx[], const unsigned int size)
{
   unsigned int threadX = blockDim.x * blockIdx.x + threadIdx.x;
   float num;

   if(threadX < size)
   {
      num = sin(D_PI * threadX / size);
      cokx[threadX]=4*(num*num);
   }
}

//******************************************************************************
// Name: calcPhif
// Code Type: Kernel
// Block Structure: One thread per grid column
// Shared Memory Requirements: None
// Purpose: Calculates the values for phif
// Parameters:
// ----------------
// phif - The phif array which will be set
// z - The z array is an intermediate working array and is expected to be of
//     size NX1 * NY1
// yyy - The yyy array is an intermediate working array and is expected to be of
//       size NX1 * NY1
// cokx - TBD size NX1
// pb - TBD size NX1
// c  - TBD size NX1 * NY
// NX1 - The number of columns being calculated
// NY1 - The number of rows being calculated
// DX - The spacing between columns
// DY - The spacing between rows
//******************************************************************************
__global__
void calcPhif(cufftComplex phif[],
              float z [],
              cufftComplex yyy[],
              const float cokx[],
              const cufftComplex pb[],
              const cufftComplex c[],
              const unsigned int NX1,
              const unsigned int NY1,
              const float DX,
              const float DY
              )
{'fraction_non_alphanumeric': 0.23957312425133398, 'fraction_numerical': 0.005118153109005772, 'mean_word_length': 2.8234804329725227, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2918535', 'n_tokens_mistral': 2689, 'n_tokens_neox': 2563, 'n_words': 847}