Commit fdda9657 authored by Leonardo Solis's avatar Leonardo Solis
Browse files

#31, partly ported opencl setup

Not yet compiling


Former-commit-id: 12af7ce0
parent 8d4d1bdf
......@@ -14,190 +14,21 @@
#include <stdlib.h>
#include <math.h>
#include <cstring>
#include "CL/opencl.h"
#include "CL/opencl.h"
/*
#include "AOCLUtils/aocl_utils.h"
using namespace aocl_utils;
*/
#define STRING_BUFFER_LEN 1024
// OpenCL runtime configuration
static cl_platform_id platform = NULL;
static cl_device_id device = NULL;
static cl_context context = NULL;
#if 0
// Unique command queue
static cl_command_queue command_queue = NULL;
#endif
// Kernel name as defined in the CL file
#ifdef ENABLE_KRNL_GA
static cl_command_queue command_queue_ga = NULL;
static cl_kernel kernel_ga = NULL;
static const char *name_krnl_ga = "Krnl_GA";
#endif
#ifdef ENABLE_KRNL_CONFORM
static cl_command_queue command_queue_conform = NULL;
static cl_kernel kernel_conform = NULL;
static const char *name_krnl_conform = "Krnl_Conform";
#endif
#ifdef ENABLE_KRNL_INTERE
static cl_command_queue command_queue_intere = NULL;
static cl_kernel kernel_intere = NULL;
static const char *name_krnl_intere = "Krnl_InterE";
#endif
#ifdef ENABLE_KRNL_INTRAE
static cl_command_queue command_queue_intrae = NULL;
static cl_kernel kernel_intrae = NULL;
static const char *name_krnl_intrae = "Krnl_IntraE";
#endif
#ifdef ENABLE_KRNL_PRNG_BT_USHORT_FLOAT
static cl_command_queue command_queue_prng_bt_ushort_float = NULL;
static cl_kernel kernel_prng_bt_ushort_float = NULL;
static const char *name_krnl_prng_bt_ushort_float = "Krnl_Prng_BT_ushort_float";
#endif
#ifdef ENABLE_KRNL_PRNG_GG_UCHAR
static cl_command_queue command_queue_prng_gg_uchar = NULL;
static cl_kernel kernel_prng_gg_uchar = NULL;
static const char *name_krnl_prng_gg_uchar = "Krnl_Prng_GG_uchar";
#endif
#ifdef ENABLE_KRNL_PRNG_GG_FLOAT
static cl_command_queue command_queue_prng_gg_float = NULL;
static cl_kernel kernel_prng_gg_float = NULL;
static const char *name_krnl_prng_gg_float = "Krnl_Prng_GG_float";
#endif
#ifdef ENABLE_KRNL_PRNG_LS123_USHORT
static cl_command_queue command_queue_prng_ls123_ushort = NULL;
static cl_kernel kernel_prng_ls123_ushort = NULL;
static const char *name_krnl_prng_ls123_ushort = "Krnl_Prng_LS123_ushort";
#endif
#ifdef ENABLE_KRNL_PRNG_LS_FLOAT
static cl_command_queue command_queue_prng_ls_float = NULL;
static cl_kernel kernel_prng_ls_float = NULL;
static const char *name_krnl_prng_ls_float = "Krnl_Prng_LS_float";
#endif
#ifdef ENABLE_KRNL_PRNG_LS2_FLOAT
static cl_command_queue command_queue_prng_ls2_float = NULL;
static cl_kernel kernel_prng_ls2_float = NULL;
static const char *name_krnl_prng_ls2_float = "Krnl_Prng_LS2_float";
#endif
#ifdef ENABLE_KRNL_PRNG_LS3_FLOAT
static cl_command_queue command_queue_prng_ls3_float = NULL;
static cl_kernel kernel_prng_ls3_float = NULL;
static const char *name_krnl_prng_ls3_float = "Krnl_Prng_LS3_float";
#endif
#ifdef ENABLE_KRNL_PRNG_LS4_FLOAT
static cl_command_queue command_queue_prng_ls4_float = NULL;
static cl_kernel kernel_prng_ls4_float = NULL;
static const char *name_krnl_prng_ls4_float = "Krnl_Prng_LS4_float";
#endif
#ifdef ENABLE_KRNL_PRNG_LS5_FLOAT
static cl_command_queue command_queue_prng_ls5_float = NULL;
static cl_kernel kernel_prng_ls5_float = NULL;
static const char *name_krnl_prng_ls5_float = "Krnl_Prng_LS5_float";
#endif
#ifdef ENABLE_KRNL_PRNG_LS6_FLOAT
static cl_command_queue command_queue_prng_ls6_float = NULL;
static cl_kernel kernel_prng_ls6_float = NULL;
static const char *name_krnl_prng_ls6_float = "Krnl_Prng_LS6_float";
#endif
#include "xcl2.hpp"
#include <vector>
using std::vector;
#ifdef ENABLE_KRNL_PRNG_LS7_FLOAT
static cl_command_queue command_queue_prng_ls7_float = NULL;
static cl_kernel kernel_prng_ls7_float = NULL;
static const char *name_krnl_prng_ls7_float = "Krnl_Prng_LS7_float";
#endif
#ifdef ENABLE_KRNL_PRNG_LS8_FLOAT
static cl_command_queue command_queue_prng_ls8_float = NULL;
static cl_kernel kernel_prng_ls8_float = NULL;
static const char *name_krnl_prng_ls8_float = "Krnl_Prng_LS8_float";
#endif
#ifdef ENABLE_KRNL_PRNG_LS9_FLOAT
static cl_command_queue command_queue_prng_ls9_float = NULL;
static cl_kernel kernel_prng_ls9_float = NULL;
static const char *name_krnl_prng_ls9_float = "Krnl_Prng_LS9_float";
#endif
#ifdef ENABLE_KRNL_LS
static cl_command_queue command_queue_ls = NULL;
static cl_kernel kernel_ls = NULL;
static const char *name_krnl_ls = "Krnl_LS";
#endif
#ifdef ENABLE_KRNL_LS2
static cl_command_queue command_queue_ls2 = NULL;
static cl_kernel kernel_ls2 = NULL;
static const char *name_krnl_ls2 = "Krnl_LS2";
#endif
#ifdef ENABLE_KRNL_LS3
static cl_command_queue command_queue_ls3 = NULL;
static cl_kernel kernel_ls3 = NULL;
static const char *name_krnl_ls3 = "Krnl_LS3";
#endif
#ifdef ENABLE_KRNL_LS4
static cl_command_queue command_queue_ls4 = NULL;
static cl_kernel kernel_ls4 = NULL;
static const char *name_krnl_ls4 = "Krnl_LS4";
#endif
#ifdef ENABLE_KRNL_LS5
static cl_command_queue command_queue_ls5 = NULL;
static cl_kernel kernel_ls5 = NULL;
static const char *name_krnl_ls5 = "Krnl_LS5";
#endif
#ifdef ENABLE_KRNL_LS6
static cl_command_queue command_queue_ls6 = NULL;
static cl_kernel kernel_ls6 = NULL;
static const char *name_krnl_ls6 = "Krnl_LS6";
#endif
#ifdef ENABLE_KRNL_LS7
static cl_command_queue command_queue_ls7 = NULL;
static cl_kernel kernel_ls7 = NULL;
static const char *name_krnl_ls7 = "Krnl_LS7";
#endif
#ifdef ENABLE_KRNL_LS8
static cl_command_queue command_queue_ls8 = NULL;
static cl_kernel kernel_ls8 = NULL;
static const char *name_krnl_ls8 = "Krnl_LS8";
#endif
#ifdef ENABLE_KRNL_LS9
static cl_command_queue command_queue_ls9 = NULL;
static cl_kernel kernel_ls9 = NULL;
static const char *name_krnl_ls9 = "Krnl_LS9";
#endif
#ifdef ENABLE_KRNL_IGL_ARBITER
static cl_command_queue command_queue_igl_arbiter = NULL;
static cl_kernel kernel_igl_arbiter = NULL;
static const char *name_krnl_igl_arbiter = "Krnl_IGL_Arbiter";
#endif
static cl_program program = NULL;
// Function prototypes
bool init();
void cleanup();
static void device_info_ulong( cl_device_id device, cl_device_info param, const char* name);
static void device_info_uint ( cl_device_id device, cl_device_info param, const char* name);
......@@ -210,32 +41,10 @@ static void display_device_info( cl_device_id device );
//// --------------------------------
Dockparameters dockpars;
kernelconstant_static KerConstStatic;
#if defined(SINGLE_COPY_POP_ENE)
#else
kernelconstant_dynamic KerConstDynamic;
#endif
//// --------------------------------
//// Host memory buffers
//// --------------------------------
float* cpu_init_populations;
float* cpu_final_populations;
float* cpu_energies;
Ligandresult* cpu_result_ligands;
unsigned int* cpu_prng_seeds;
#if defined(SINGLE_COPY_POP_ENE)
int *cpu_evals_of_runs;
int *cpu_gens_of_runs;
#endif
float* cpu_ref_ori_angles;
//// --------------------------------
//// Device memory buffers
//// --------------------------------
#if defined (FIXED_POINT_INTERE)
cl_mem mem_KerConstStatic_fixpt64_atom_charges_const;
#endif
cl_mem mem_KerConstStatic_InterE_atom_charges_const;
cl_mem mem_KerConstStatic_InterE_atom_types_const;
......@@ -277,21 +86,11 @@ cl_mem mem_ref_orientation_quats_const; // float [4*MAX_NUM_OF_RUNS]; // 4*100
*/
cl_mem mem_dockpars_fgrids;
#if defined(SEPARATE_FGRID_INTERE)
cl_mem mem_dockpars_fgrids2;
cl_mem mem_dockpars_fgrids3;
#endif
cl_mem mem_dockpars_conformations_current;
cl_mem mem_dockpars_energies_current;
#if defined(SINGLE_COPY_POP_ENE)
cl_mem mem_evals_performed;
cl_mem mem_gens_performed;
#else
cl_mem mem_evals_and_generations_performed;
#endif
#if !defined(SW_EMU)
// IMPORTANT: enable this dummy global argument only for "hw" build.
......@@ -300,12 +99,7 @@ cl_mem mem_evals_and_generations_performed;
cl_mem mem_dummy;
#endif
//#if defined (FIXED_POINT_INTERE)
#if 0
//#include "defines_fixedpt_64.h"
fixedpt64* cpu_fixedpt64grids;
#endif
//// --------------------------------
//// Docking
......@@ -334,102 +128,248 @@ parameters argc and argv:
are the corresponding command line arguments parameter clock_start_program:
contains the state of the clock tick counter at the beginning of the program
filled with clock() */
{
//// ------------------------
//// OpenCL Host Setup
//// ------------------------
if(!init()) {
return -1;
}
printf("Init complete!\n"); fflush(stdout);
{
// The get_xil_devices will return vector of Xilinx Devices
std::vector<cl::Device> devices = xcl::get_xil_devices();
cl::Device device = devices[0];
//Creating Context and Command Queue for selected Device
cl::Context context(device);
std::string device_name = device.getInfo<CL_DEVICE_NAME>();
std::cout << "Found Device=" << device_name.c_str() << std::endl;
#ifdef ENABLE_KRNL_GA
cl::CommandQueue command_queue_ga (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_CONFORM
cl::CommandQueue command_queue_conform (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_INTERE
cl::CommandQueue command_queue_intere (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_INTRAE
cl::CommandQueue command_queue_intrae (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_PRNG_BT_USHORT_FLOAT
cl::CommandQueue command_queue_prng_bt_ushort_float (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_PRNG_GG_UCHAR
cl::CommandQueue command_queue_prng_gg_uchar (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_PRNG_GG_FLOAT
cl::CommandQueue command_queue_prng_gg_float (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_PRNG_LS123_USHORT
cl::CommandQueue command_queue_prng_ls123_ushort (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_PRNG_LS_FLOAT
cl::CommandQueue command_queue_prng_ls_float (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_PRNG_LS2_FLOAT
cl::CommandQueue command_queue_prng_ls2_float (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_PRNG_LS3_FLOAT
cl::CommandQueue command_queue_prng_ls3_float (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_PRNG_LS4_FLOAT
cl::CommandQueue command_queue_prng_ls4_float (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_PRNG_LS5_FLOAT
cl::CommandQueue command_queue_prng_ls5_float (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_PRNG_LS6_FLOAT
cl::CommandQueue command_queue_prng_ls6_float (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_PRNG_LS7_FLOAT
cl::CommandQueue command_queue_prng_ls7_float (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_PRNG_LS8_FLOAT
cl::CommandQueue command_queue_prng_ls8_float (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_PRNG_LS9_FLOAT
cl::CommandQueue command_queue_prng_ls9_float (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_LS
cl::CommandQueue command_queue_ls (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_LS2
cl::CommandQueue command_queue_ls2 (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_LS3
cl::CommandQueue command_queue_ls3 (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_LS4
cl::CommandQueue command_queue_ls4 (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_LS5
cl::CommandQueue command_queue_ls5 (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_LS6
cl::CommandQueue command_queue_ls6 (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_LS7
cl::CommandQueue command_queue_ls7 (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_LS8
cl::CommandQueue command_queue_ls8 (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_LS9
cl::CommandQueue command_queue_ls9 (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
#ifdef ENABLE_KRNL_IGL_ARBITER
cl::CommandQueue command_queue_igl_arbiter (context, device, CL_QUEUE_PROFILING_ENABLE);
#endif
// import_binary() command will find the OpenCL binary file created using the
// xocc compiler load into OpenCL Binary and return as Binaries
// OpenCL and it can contain many functions which can be executed on the
// device.
std::string binaryFile = xcl::find_binary_file(device_name,"Krnl_GA");
cl::Program::Binaries bins = xcl::import_binary_file(binaryFile);
devices.resize(1);
cl::Program program(context, devices, bins);
// This call will extract a kernel out of the program we loaded in the
// previous line. A kernel is an OpenCL function that is executed on the
// FPGA. This function is defined in the device/Krnl_GA.cl file.
#ifdef ENABLE_KRNL_GA
cl::Kernel kernel_ga (program, "Krnl_GA");
#endif
#ifdef ENABLE_KRNL_CONFORM
cl::Kernel kernel_conform (program, "Krnl_Conform");
#endif
#ifdef ENABLE_KRNL_INTERE
cl::Kernel kernel_intere (program, "Krnl_InterE");
#endif
#ifdef ENABLE_KRNL_INTRAE
cl::Kernel kernel_intrae (program, "Krnl_IntraE");
#endif
#ifdef ENABLE_KRNL_PRNG_BT_USHORT_FLOAT
cl::Kernel kernel_prng_bt_ushort_float (program, "Krnl_Prng_BT_ushort_float");
#endif
#ifdef ENABLE_KRNL_PRNG_GG_UCHAR
cl::Kernel kernel_prng_gg_uchar (program, "Krnl_Prng_GG_uchar");
#endif
#ifdef ENABLE_KRNL_PRNG_GG_FLOAT
cl::Kernel kernel_prng_gg_float (program, "Krnl_Prng_GG_float");
#endif
#ifdef ENABLE_KRNL_PRNG_LS123_USHORT
cl::Kernel kernel_prng_ls123_ushort (program, "Krnl_Prng_LS123_ushort");
#endif
#ifdef ENABLE_KRNL_PRNG_LS_FLOAT
cl::Kernel kernel_prng_ls_float (program, "Krnl_Prng_LS_float");
#endif
#ifdef ENABLE_KRNL_PRNG_LS2_FLOAT
cl::Kernel kernel_prng_ls2_float (program, "Krnl_Prng_LS2_float");
#endif
#ifdef ENABLE_KRNL_PRNG_LS3_FLOAT
cl::Kernel kernel_prng_ls3_float (program, "Krnl_Prng_LS3_float");
#endif
#ifdef ENABLE_KRNL_PRNG_LS4_FLOAT
cl::Kernel kernel_prng_ls4_float (program, "Krnl_Prng_LS4_float");
#endif
#ifdef ENABLE_KRNL_PRNG_LS5_FLOAT
cl::Kernel kernel_prng_ls5_float (program, "Krnl_Prng_LS5_float");
#endif
#ifdef ENABLE_KRNL_PRNG_LS6_FLOAT
cl::Kernel kernel_prng_ls6_float (program, "Krnl_Prng_LS6_float");
#endif
#ifdef ENABLE_KRNL_PRNG_LS7_FLOAT
cl::Kernel kernel_prng_ls7_float (program, "Krnl_Prng_LS7_float");
#endif
#ifdef ENABLE_KRNL_PRNG_LS8_FLOAT
cl::Kernel kernel_prng_ls8_float (program, "Krnl_Prng_LS8_float");
#endif
#ifdef ENABLE_KRNL_PRNG_LS9_FLOAT
cl::Kernel kernel_prng_ls9_float (program, "Krnl_Prng_LS9_float");
#endif
#ifdef ENABLE_KRNL_LS
cl::Kernel kernel_ls (program, "Krnl_LS");
#endif
#ifdef ENABLE_KRNL_LS2
cl::Kernel kernel_ls2 (program, "Krnl_LS2");
#endif
#ifdef ENABLE_KRNL_LS3
cl::Kernel kernel_ls3 (program, "Krnl_LS3");
#endif
#ifdef ENABLE_KRNL_LS4
cl::Kernel kernel_ls4 (program, "Krnl_LS4");
#endif
#ifdef ENABLE_KRNL_LS5
cl::Kernel kernel_ls5 (program, "Krnl_LS5");
#endif
#ifdef ENABLE_KRNL_LS6
cl::Kernel kernel_ls6 (program, "Krnl_LS6");
#endif
#ifdef ENABLE_KRNL_LS7
cl::Kernel kernel_ls7 (program, "Krnl_LS7");
#endif
#ifdef ENABLE_KRNL_LS8
cl::Kernel kernel_ls8 (program, "Krnl_LS8");
#endif
#ifdef ENABLE_KRNL_LS9
cl::Kernel kernel_ls9 (program, "Krnl_LS9");
#endif
#ifdef ENABLE_KRNL_IGL_ARBITER
cl::Kernel kernel_igl_arbiter (program, "Krnl_IGL_Arbiter");
#endif
Liganddata myligand_reference;
//Dockparameters dockpars;
clock_t clock_start_docking;
clock_t clock_stop_docking;
clock_t clock_stop_program_before_clustering;
//#if defined (FIXED_POINT_INTERE)
#if 0
size_t size_fixedpt64grids;
#else
size_t size_floatgrids;
Liganddata myligand_reference;
//allocating GPU memory for floatgrids,
size_t size_floatgrids_nbytes = (sizeof(float)) * (mygrid->num_of_atypes+2) * (mygrid->size_xyz[0]) * (mygrid->size_xyz[1]) * (mygrid->size_xyz[2]);
#if defined(SEPARATE_FGRID_INTERE)
size_t size_floatgrids2;
size_t size_floatgrids3;
#endif
size_t size_populations_nbytes = mypars->num_of_runs * mypars->pop_size * ACTUAL_GENOTYPE_LENGTH * sizeof(float);
size_t size_populations_nelems = mypars->num_of_runs * mypars->pop_size * ACTUAL_GENOTYPE_LENGTH;
#endif
size_t size_energies_nbytes = mypars->num_of_runs * mypars->pop_size * sizeof(float);
size_t size_energies_nelems = mypars->num_of_runs * mypars->pop_size;
size_t size_populations;
size_t size_energies;
size_t size_prng_seeds;
#if defined(SINGLE_COPY_POP_ENE)
size_t size_evals_of_runs;
#endif
//allocating and initializing CPU memory for initial population
vector<float,aligned_allocator<float>> cpu_init_populations (size_populations_nelems, 0.0f);
//allocating CPU memory for final population
vector<float,aligned_allocator<float>> cpu_final_populations (size_populations_nelems);
clock_t clock_start_docking;
clock_t clock_stop_docking;
clock_t clock_stop_program_before_clustering;
//allocating CPU memory for initial populations
#if defined(SINGLE_COPY_POP_ENE)
size_populations = mypars->num_of_runs * mypars->pop_size * ACTUAL_GENOTYPE_LENGTH * sizeof(float);
#else
//size_populations = mypars->pop_size * GENOTYPE_LENGTH_IN_GLOBMEM * sizeof(float);
size_populations = mypars->pop_size * ACTUAL_GENOTYPE_LENGTH * sizeof(float);
#endif
cpu_init_populations = (float*) alignedMalloc(size_populations);
memset(cpu_init_populations, 0, size_populations);
//allocating CPU memory for results
#if defined(SINGLE_COPY_POP_ENE)
size_energies = mypars->num_of_runs * mypars->pop_size * sizeof(float);
#else
size_energies = mypars->pop_size * sizeof(float);
#endif
cpu_energies = (float*) alignedMalloc(size_energies);
cpu_result_ligands = (Ligandresult*) alignedMalloc(sizeof(Ligandresult)*(mypars->num_of_runs));
cpu_final_populations = (float*) alignedMalloc(size_populations);
//allocating memory in CPU for reference orientation angles
#if defined(SINGLE_COPY_POP_ENE)
cpu_ref_ori_angles = (float*) alignedMalloc(mypars->num_of_runs*3*sizeof(float));
#else
cpu_ref_ori_angles = (float*) alignedMalloc(3*sizeof(float));
#endif
//allocating CPU memory for results
vector<float,aligned_allocator<float>> cpu_energies (size_energies_nelems);
//allocating CPU memory for resulting ligands
vector<Ligandresult,aligned_allocator<Ligandresult>> cpu_result_ligands (mypars->num_of_runs);
//allocating memory in CPU for reference orientation angles
vector<float,aligned_allocator<float>> cpu_ref_ori_angles (mypars->num_of_runs*3);
//generating initial populations and random orientation angles of reference ligand
//(ligand will be moved to origo and scaled as well)
myligand_reference = *myligand_init;
gen_initpop_and_reflig(mypars, cpu_init_populations, cpu_ref_ori_angles, &myligand_reference, mygrid);
//allocating memory in CPU for pseudorandom number generator seeds and
//generating them (seed for each thread during GA)
unsigned int num_of_prng_blocks = 25;
size_prng_seeds = num_of_prng_blocks * mypars->num_of_runs * sizeof(unsigned int);
cpu_prng_seeds = (unsigned int*) alignedMalloc(size_prng_seeds);
genseed(time(NULL)); //initializing seed generator
for (unsigned int i=0; i<num_of_prng_blocks*mypars->num_of_runs; i++) {
#if defined (REPRO)
cpu_prng_seeds[i] = 1u;
#else
gen_initpop_and_reflig(mypars, cpu_init_populations, cpu_ref_ori_angles, &myligand_reference, mygrid);
//allocating memory in CPU for pseudorandom number generator seeds
const unsigned int num_of_prng_blocks = 25;
size_t size_prng_seeds_nelems = num_of_prng_blocks * mypars->num_of_runs;
vector<unsigned int,aligned_allocator<unsigned int>> cpu_prng_seeds (size_prng_seeds_nelems);
//initializing seed generator
genseed(time(NULL));
//generating seeds (for each thread during GA)
for (unsigned int i=0; i<size_prng_seeds_nelems; i++) {
cpu_prng_seeds[i] = genseed(0u);
#endif
}
//srand(time(NULL));
#if defined(SINGLE_COPY_POP_ENE)
size_t size_evals_of_runs_nbytes = mypars->num_of_runs*sizeof(int);
size_t size_evals_of_runs_nelems = mypars->num_of_runs;
// allocating memory in CPU for evaluation counters
size_evals_of_runs = mypars->num_of_runs*sizeof(int);
cpu_evals_of_runs = (int*) alignedMalloc(size_evals_of_runs);
memset(cpu_evals_of_runs, 0, size_evals_of_runs);
// allocating memory in CPU for generation counters
cpu_gens_of_runs = (int*) alignedMalloc(size_evals_of_runs);
memset(cpu_gens_of_runs, 0, size_evals_of_runs);
#endif
vector<int,aligned_allocator<int>> cpu_evals_of_runs (size_evals_of_runs_nelems, 0);
// allocating memory in CPU for generation counters
vector<int,aligned_allocator<int>> cpu_gens_of_runs (size_evals_of_runs_nelems, 0);
//preparing the constant data fields for the GPU
// ----------------------------------------------------------------------
......@@ -438,47 +378,43 @@ filled with clock() */
// and return them <here> (<here> = where prepare_const_fields_for_gpu() is called),
// so we can send them to Kernels from <here>, instead of from calcenergy.cpp as originally.
// ----------------------------------------------------------------------
#if defined(SINGLE_COPY_POP_ENE)
if (prepare_conststatic_fields_for_gpu(&myligand_reference, mypars, cpu_ref_ori_angles, &KerConstStatic) == 1)
#else
if (prepare_conststatic_fields_for_gpu(&myligand_reference, mypars, &KerConstStatic) == 1)