Commit 1e897aa6 authored by Leonardo Solis's avatar Leonardo Solis
Browse files

#24, added support for multiple DDR banks in host and krnls: cannot build due...

#24, added support for multiple DDR banks in host and krnls: cannot build due to insufficient resources
parent e3f736ba
......@@ -96,10 +96,13 @@ Krnl_GA_SRCS=./device/Krnl_GA.cl
## Choosing the all kernels in design for maximum memory port property
# Krnl_GA_CLFLAGS=--max_memory_ports all
Krnl_GA_CLFLAGS=--max_memory_ports Krnl_GA \
--max_memory_ports Krnl_Conform \
--max_memory_ports Krnl_InterE \
--max_memory_ports Krnl_IntraE
## Ideal configuration, but results in routing error
#Krnl_GA_CLFLAGS=--max_memory_ports Krnl_GA \
# --max_memory_ports Krnl_Conform \
# --max_memory_ports Krnl_InterE \
# --max_memory_ports Krnl_IntraE
#Krnl_GA_CLFLAGS=--max_memory_ports Krnl_GA
# https://www.xilinx.com/support/documentation/sw_manuals/xilinx2017_4/ug1023-sdaccel-user-guide.pdf
# Page 44
......@@ -113,12 +116,37 @@ Krnl_GA_CLFLAGS=--max_memory_ports Krnl_GA \
# --sp bandwidth_1.m_axi_gmem1:bank1 \
# --sp bandwidth_1.m_axi_gmem2:bank2
Krnl_GA_LDCLFLAGS+=--sp Krnl_GA_1.m_axi_gmem0:bank0 \
--sp Krnl_Conform_1.m_axi_gmem1:bank1 \
--sp Krnl_InterE_1.m_axi_gmem2:bank2 \
--sp Krnl_IntraE_1.m_axi_gmem3:bank3
## Ideal configuration, but results in routing error
# First two args of IntraE are the 2nd and 3rd of InterE (atom_charges & atom_types),
# Therefore they are mapped to the same DDR bank
#Krnl_GA_LDCLFLAGS+=--sp Krnl_GA_1.m_axi_gmem0:bank0 \
# --sp Krnl_GA_1.m_axi_gmem1:bank0 \
# --sp Krnl_GA_1.m_axi_gmem2:bank0 \
# --sp Krnl_GA_1.m_axi_gmem3:bank0 \
# --sp Krnl_Conform_1.m_axi_gmem0:bank1 \
# --sp Krnl_Conform_1.m_axi_gmem1:bank1 \
# --sp Krnl_Conform_1.m_axi_gmem2:bank1 \
# --sp Krnl_Conform_1.m_axi_gmem3:bank1 \
# --sp Krnl_Conform_1.m_axi_gmem4:bank1 \
# --sp Krnl_InterE_1.m_axi_gmem0:bank2 \
# --sp Krnl_InterE_1.m_axi_gmem1:bank2 \
# --sp Krnl_InterE_1.m_axi_gmem2:bank2 \
# --sp Krnl_IntraE_1.m_axi_gmem0:bank2 \
# --sp Krnl_IntraE_1.m_axi_gmem1:bank2 \
# --sp Krnl_IntraE_1.m_axi_gmem2:bank3 \
# --sp Krnl_IntraE_1.m_axi_gmem3:bank3 \
# --sp Krnl_IntraE_1.m_axi_gmem4:bank3 \
# --sp Krnl_IntraE_1.m_axi_gmem5:bank3 \
# --sp Krnl_IntraE_1.m_axi_gmem6:bank3 \
# --sp Krnl_IntraE_1.m_axi_gmem7:bank3 \
# --sp Krnl_IntraE_1.m_axi_gmem8:bank3 \
# --sp Krnl_IntraE_1.m_axi_gmem9:bank3 \
# --sp Krnl_IntraE_1.m_axi_gmem10:bank3
Krnl_GA_LDCLFLAGS+=--sp Krnl_GA_1.m_axi_gmem:bank0 \
--sp Krnl_Conform_1.m_axi_gmem:bank1 \
--sp Krnl_InterE_1.m_axi_gmem:bank2 \
--sp Krnl_IntraE_1.m_axi_gmem:bank3
##
# https://www.xilinx.com/support/documentation/sw_manuals/xilinx2017_4/ug1281-sdaccel-debugging-guide.pdf
# Page 32
......@@ -139,9 +167,28 @@ ifneq ($(LAPC),none)
## # xbsak status --lapc
## Invalid codes read, skip decoding
Krnl_GA_LDCLFLAGS+=--dk protocol:Krnl_GA_1:m_axi_gmem0 \
--dk protocol:Krnl_GA_1:m_axi_gmem1 \
--dk protocol:Krnl_GA_1:m_axi_gmem2 \
--dk protocol:Krnl_GA_1:m_axi_gmem3 \
--dk protocol:Krnl_Conform_1:m_axi_gmem0 \
--dk protocol:Krnl_Conform_1:m_axi_gmem1 \
--dk protocol:Krnl_InterE_1:m_axi_gmem2 \
--dk protocol:Krnl_IntraE_1:m_axi_gmem3
--dk protocol:Krnl_Conform_1:m_axi_gmem2 \
--dk protocol:Krnl_Conform_1:m_axi_gmem3 \
--dk protocol:Krnl_Conform_1:m_axi_gmem4 \
--dk protocol:Krnl_InterE_1:m_axi_gmem0 \
--dk protocol:Krnl_InterE_1:m_axi_gmem1 \
--dk protocol:Krnl_InterE_1:m_axi_gmem2 \
--dk protocol:Krnl_IntraE_1:m_axi_gmem0 \
--dk protocol:Krnl_IntraE_1:m_axi_gmem1 \
--dk protocol:Krnl_IntraE_1:m_axi_gmem2 \
--dk protocol:Krnl_IntraE_1:m_axi_gmem3 \
--dk protocol:Krnl_IntraE_1:m_axi_gmem4 \
--dk protocol:Krnl_IntraE_1:m_axi_gmem5 \
--dk protocol:Krnl_IntraE_1:m_axi_gmem6 \
--dk protocol:Krnl_IntraE_1:m_axi_gmem7 \
--dk protocol:Krnl_IntraE_1:m_axi_gmem8 \
--dk protocol:Krnl_IntraE_1:m_axi_gmem9 \
--dk protocol:Krnl_IntraE_1:m_axi_gmem10
## Commented because error was obtained:
## No interface pins matched 'get_bd_intf_pins -of /Krnl_Conform_1 -filter NAME=~m_axi_gmem'
......@@ -160,7 +207,10 @@ SPM:=none
ifneq ($(SPM),none)
##--profile_kernel data:krnl1:cu1:m_axi_gmem0
##--profile_kernel data:krnl2:cu2:m_axi_gmem
Krnl_GA_LDCLFLAGS+=--profile_kernel Krnl_GA:Krnl_GA_1:all
Krnl_GA_LDCLFLAGS+=--profile_kernel data:Krnl_GA:Krnl_GA_1:all \
--profile_kernel data:Krnl_Conform:Krnl_Conform_1:all \
--profile_kernel data:Krnl_InterE:Krnl_InterE_1:all \
--profile_kernel data:Krnl_IntraE:Krnl_IntraE_1:all
endif
#-------------------------------
......
......@@ -450,8 +450,12 @@ float* cpu_ref_ori_angles;
#if defined (FIXED_POINT_INTERE)
cl_mem mem_KerConstStatic_fixpt64_atom_charges_const;
#endif
cl_mem mem_KerConstStatic_atom_charges_const;
cl_mem mem_KerConstStatic_atom_types_const;
cl_mem mem_KerConstStatic_InterE_atom_charges_const;
cl_mem mem_KerConstStatic_InterE_atom_types_const;
cl_mem mem_KerConstStatic_IntraE_atom_charges_const;
cl_mem mem_KerConstStatic_IntraE_atom_types_const;
cl_mem mem_KerConstStatic_intraE_contributors_const;
cl_mem mem_KerConstStatic_reqm_const;
......@@ -541,8 +545,6 @@ cl_mem mem_dummy;
......@@ -767,8 +769,38 @@ printf("%i %i\n", dockpars.num_of_intraE_contributors, myligand_reference.num_of
#else
size_floatgrids = (sizeof(float)) * (mygrid->num_of_atypes+2) * (mygrid->size_xyz[0]) * (mygrid->size_xyz[1]) * (mygrid->size_xyz[2]);
#endif
#endif
#endif
// -----------------------------------------------------------------------------------------------------
// Hardware specific
// Specifiying exact memory bank from host code
// Only valid if 4 banks are available (AWS)
cl_mem_ext_ptr_t d_bank0_ext; // Krnl_GA
cl_mem_ext_ptr_t d_bank1_ext; // Krnl_Conform
cl_mem_ext_ptr_t d_bank2_ext; // Krnl_InterE
cl_mem_ext_ptr_t d_bank3_ext; // Krnl_IntraE
d_bank0_ext.flags = XCL_MEM_DDR_BANK0;
d_bank0_ext.obj = NULL;
d_bank0_ext.param = 0;
d_bank1_ext.flags = XCL_MEM_DDR_BANK1;
d_bank1_ext.obj = NULL;
d_bank1_ext.param = 0;
d_bank2_ext.flags = XCL_MEM_DDR_BANK2;
d_bank2_ext.obj = NULL;
d_bank2_ext.param = 0;
d_bank3_ext.flags = XCL_MEM_DDR_BANK3;
d_bank3_ext.obj = NULL;
d_bank3_ext.param = 0;
// Replacing common buffer creation with
// a Xilinx-specific where DDR banks can be specified
#if 0
#if defined (FIXED_POINT_INTERE)
mallocBufferObject(context,CL_MEM_READ_ONLY, MAX_NUM_OF_ATOMS*sizeof(fixedpt64), &mem_KerConstStatic_fixpt64_atom_charges_const);
#endif
......@@ -826,7 +858,88 @@ printf("%i %i\n", dockpars.num_of_intraE_contributors, myligand_reference.num_of
mallocBufferObject(context,CL_MEM_WRITE_ONLY,size_evals_of_runs, &mem_gens_performed);
#else
mallocBufferObject(context,CL_MEM_WRITE_ONLY,2*sizeof(unsigned int), &mem_evals_and_generations_performed);
#endif
#endif
#if defined (FIXED_POINT_INTERE)
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ATOMS*sizeof(fixedpt64), &d_bank2_ext, &mem_KerConstStatic_fixpt64_atom_charges_const);
#endif
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ATOMS*sizeof(float), &d_bank2_ext, &mem_KerConstStatic_InterE_atom_charges_const); // InterE
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ATOMS*sizeof(char), &d_bank2_ext, &mem_KerConstStatic_InterE_atom_types_const); // InterE
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ATOMS*sizeof(float), &d_bank3_ext, &mem_KerConstStatic_IntraE_atom_charges_const); // IntraE
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ATOMS*sizeof(char), &d_bank3_ext, &mem_KerConstStatic_IntraE_atom_types_const); // IntraE
/*
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, 3*MAX_INTRAE_CONTRIBUTORS*sizeof(char), &d_bank3_ext, &mem_KerConstStatic_intraE_contributors_const); // IntraE
*/
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_INTRAE_CONTRIBUTORS*sizeof(cl_char3), &d_bank3_ext, &mem_KerConstStatic_intraE_contributors_const); // IntraE
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, ATYPE_NUM*sizeof(float), &d_bank3_ext, &mem_KerConstStatic_reqm_const); // IntraE
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, ATYPE_NUM*sizeof(float), &d_bank3_ext, &mem_KerConstStatic_reqm_hbond_const); // IntraE
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, ATYPE_NUM*sizeof(unsigned int), &d_bank3_ext, &mem_KerConstStatic_atom1_types_reqm_const); // IntraE
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, ATYPE_NUM*sizeof(unsigned int), &d_bank3_ext, &mem_KerConstStatic_atom2_types_reqm_const); // IntraE
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ATYPES*MAX_NUM_OF_ATYPES*sizeof(float), &d_bank3_ext, &mem_KerConstStatic_VWpars_AC_const); // IntraE
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ATYPES*MAX_NUM_OF_ATYPES*sizeof(float), &d_bank3_ext, &mem_KerConstStatic_VWpars_BD_const); // IntraE
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ATYPES*sizeof(float), &d_bank3_ext, &mem_KerConstStatic_dspars_S_const); // IntraE
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ATYPES*sizeof(float), &d_bank3_ext, &mem_KerConstStatic_dspars_V_const); // IntraE
#if defined (FIXED_POINT_CONFORM)
// fixed-point
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ROTATIONS*sizeof(fixedpt), &d_bank1_ext, &mem_KerConstStatic_rotlist_const); // Conform
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ATOMS*sizeof(cl_int3), &d_bank1_ext, &mem_KerConstStatic_ref_coords_const); // Conform
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ROTBONDS*sizeof(cl_int3), &d_bank1_ext, &mem_KerConstStatic_rotbonds_moving_vectors_const); // Conform
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ROTBONDS*sizeof(cl_int3), &d_bank1_ext, &mem_KerConstStatic_rotbonds_unit_vectors_const); // Conform
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_RUNS*sizeof(cl_int4), &d_bank1_ext, &mem_KerConstStatic_ref_orientation_quats_const); // Conform
#else
// floating-point (original)
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ROTATIONS*sizeof(int), &d_bank1_ext, &mem_KerConstStatic_rotlist_const); // Conform
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ATOMS*sizeof(cl_float3), &d_bank1_ext, &mem_KerConstStatic_ref_coords_const); // Conform
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ROTBONDS*sizeof(cl_float3), &d_bank1_ext, &mem_KerConstStatic_rotbonds_moving_vectors_const); // Conform
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_ROTBONDS*sizeof(cl_float3), &d_bank1_ext, &mem_KerConstStatic_rotbonds_unit_vectors_const); // Conform
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX, MAX_NUM_OF_RUNS*sizeof(cl_float4), &d_bank1_ext, &mem_KerConstStatic_ref_orientation_quats_const); // Conform
#endif
//#if defined (FIXED_POINT_INTERE)
#if 0
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX,size_fixedpt64grids, &d_bank2_ext, &mem_dockpars_fgrids); // InterE
#else
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX,size_floatgrids, &d_bank2_ext, &mem_dockpars_fgrids); // InterE
#if defined(SEPARATE_FGRID_INTERE)
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX,size_floatgrids2, &d_bank2_ext, &mem_dockpars_fgrids2); // InterE
mallocBufferObject(context,CL_MEM_READ_ONLY | CL_MEM_EXT_PTR_XILINX,size_floatgrids3, &d_bank2_ext, &mem_dockpars_fgrids3); // InterE
#endif
#endif
mallocBufferObject(context,CL_MEM_READ_WRITE | CL_MEM_EXT_PTR_XILINX,size_populations, &d_bank0_ext, &mem_dockpars_conformations_current); // GA
mallocBufferObject(context,CL_MEM_READ_WRITE | CL_MEM_EXT_PTR_XILINX,size_energies, &d_bank0_ext, &mem_dockpars_energies_current); // GA
#if defined(SINGLE_COPY_POP_ENE)
mallocBufferObject(context,CL_MEM_WRITE_ONLY | CL_MEM_EXT_PTR_XILINX,size_evals_of_runs, &d_bank0_ext, &mem_evals_performed); // GA
mallocBufferObject(context,CL_MEM_WRITE_ONLY | CL_MEM_EXT_PTR_XILINX,size_evals_of_runs, &d_bank0_ext, &mem_gens_performed); // GA
#else
mallocBufferObject(context,CL_MEM_WRITE_ONLY | CL_MEM_EXT_PTR_XILINX,2*sizeof(unsigned int), &d_bank0_ext, &mem_evals_and_generations_performed); // GA
#endif
// -----------------------------------------------------------------------------------------------------
#if defined(SINGLE_COPY_POP_ENE)
......@@ -840,9 +953,11 @@ printf("%i %i\n", dockpars.num_of_intraE_contributors, myligand_reference.num_of
#endif
memcopyBufferObjectToDevice(command_queue1,mem_KerConstStatic_fixpt64_atom_charges_const, &KerConstStatic.fixpt64_atom_charges_const[0], MAX_NUM_OF_ATOMS*sizeof(fixedpt64));
#endif
memcopyBufferObjectToDevice(command_queue1,mem_KerConstStatic_atom_charges_const, &KerConstStatic.atom_charges_const[0], MAX_NUM_OF_ATOMS*sizeof(float));
memcopyBufferObjectToDevice(command_queue1,mem_KerConstStatic_atom_types_const, &KerConstStatic.atom_types_const[0], MAX_NUM_OF_ATOMS*sizeof(char));
memcopyBufferObjectToDevice(command_queue1,mem_KerConstStatic_InterE_atom_charges_const, &KerConstStatic.atom_charges_const[0], MAX_NUM_OF_ATOMS*sizeof(float));
memcopyBufferObjectToDevice(command_queue1,mem_KerConstStatic_InterE_atom_types_const, &KerConstStatic.atom_types_const[0], MAX_NUM_OF_ATOMS*sizeof(char));
memcopyBufferObjectToDevice(command_queue1,mem_KerConstStatic_IntraE_atom_charges_const, &KerConstStatic.atom_charges_const[0], MAX_NUM_OF_ATOMS*sizeof(float));
memcopyBufferObjectToDevice(command_queue1,mem_KerConstStatic_IntraE_atom_types_const, &KerConstStatic.atom_types_const[0], MAX_NUM_OF_ATOMS*sizeof(char));
/*
memcopyBufferObjectToDevice(command_queue1,mem_KerConstStatic_intraE_contributors_const, &KerConstStatic.intraE_contributors_const[0], 3*MAX_INTRAE_CONTRIBUTORS*sizeof(char));
......@@ -1016,9 +1131,9 @@ printf("%i %i\n", dockpars.num_of_intraE_contributors, myligand_reference.num_of
#if defined (FIXED_POINT_INTERE)
setKernelArg(kernel3,1, sizeof(mem_KerConstStatic_fixpt64_atom_charges_const), &mem_KerConstStatic_fixpt64_atom_charges_const);
#else
setKernelArg(kernel3,1, sizeof(mem_KerConstStatic_atom_charges_const), &mem_KerConstStatic_atom_charges_const);
setKernelArg(kernel3,1, sizeof(mem_KerConstStatic_InterE_atom_charges_const), &mem_KerConstStatic_InterE_atom_charges_const);
#endif
setKernelArg(kernel3,2, sizeof(mem_KerConstStatic_atom_types_const), &mem_KerConstStatic_atom_types_const);
setKernelArg(kernel3,2, sizeof(mem_KerConstStatic_InterE_atom_types_const), &mem_KerConstStatic_InterE_atom_types_const);
setKernelArg(kernel3,3, sizeof(unsigned char), &dockpars.g1);
setKernelArg(kernel3,4, sizeof(unsigned int), &dockpars.g2);
setKernelArg(kernel3,5, sizeof(unsigned int), &dockpars.g3);
......@@ -1044,8 +1159,8 @@ printf("%i %i\n", dockpars.num_of_intraE_contributors, myligand_reference.num_of
#endif // End of ENABLE_KERNEL3
#ifdef ENABLE_KERNEL4 // Krnl_IntraE
setKernelArg(kernel4,0, sizeof(mem_KerConstStatic_atom_charges_const), &mem_KerConstStatic_atom_charges_const);
setKernelArg(kernel4,1, sizeof(mem_KerConstStatic_atom_types_const), &mem_KerConstStatic_atom_types_const);
setKernelArg(kernel4,0, sizeof(mem_KerConstStatic_IntraE_atom_charges_const), &mem_KerConstStatic_IntraE_atom_charges_const);
setKernelArg(kernel4,1, sizeof(mem_KerConstStatic_IntraE_atom_types_const), &mem_KerConstStatic_IntraE_atom_types_const);
setKernelArg(kernel4,2, sizeof(mem_KerConstStatic_intraE_contributors_const), &mem_KerConstStatic_intraE_contributors_const);
setKernelArg(kernel4,3, sizeof(dockpars.smooth), &dockpars.smooth);
......@@ -3123,8 +3238,12 @@ void cleanup() {
#if defined (FIXED_POINT_INTERE)
if(mem_KerConstStatic_fixpt64_atom_charges_const) {clReleaseMemObject(mem_KerConstStatic_fixpt64_atom_charges_const);}
#endif
if(mem_KerConstStatic_atom_charges_const) {clReleaseMemObject(mem_KerConstStatic_atom_charges_const);}
if(mem_KerConstStatic_atom_types_const) {clReleaseMemObject(mem_KerConstStatic_atom_types_const);}
if(mem_KerConstStatic_InterE_atom_charges_const) {clReleaseMemObject(mem_KerConstStatic_InterE_atom_charges_const);}
if(mem_KerConstStatic_InterE_atom_types_const) {clReleaseMemObject(mem_KerConstStatic_InterE_atom_types_const);}
if(mem_KerConstStatic_IntraE_atom_charges_const) {clReleaseMemObject(mem_KerConstStatic_IntraE_atom_charges_const);}
if(mem_KerConstStatic_IntraE_atom_types_const) {clReleaseMemObject(mem_KerConstStatic_IntraE_atom_types_const);}
if(mem_KerConstStatic_intraE_contributors_const) {clReleaseMemObject(mem_KerConstStatic_intraE_contributors_const);}
if(mem_KerConstStatic_reqm_const) {clReleaseMemObject(mem_KerConstStatic_reqm_const);}
......
......@@ -15,10 +15,19 @@
/*
*/
#if 0
int mallocBufferObject(cl_context context,
cl_mem_flags flags,
size_t size,
cl_mem* mem);
#endif
// Modified to support explicit host point
int mallocBufferObject(cl_context context,
cl_mem_flags flags,
size_t size,
void* host_pointer,
cl_mem* mem);
/*
......
#include "BufferObjects.h"
#if 0
int mallocBufferObject(cl_context context,
cl_mem_flags flags,
size_t size,
......@@ -26,6 +27,36 @@ int mallocBufferObject(cl_context context,
*mem = local_mem;
return CL_SUCCESS;
}
#endif
int mallocBufferObject(cl_context context,
cl_mem_flags flags,
size_t size,
void* host_pointer,
cl_mem* mem){
cl_mem local_mem;
local_mem = clCreateBuffer(context, flags, size, host_pointer, NULL);
if (!local_mem){
printf("Error: clCreateBuffer()\n");
fflush(stdout);
return EXIT_FAILURE;
}
#ifdef BUFFER_OBJECT_INFO_DISPLAY
cl_int err;
err = getBufferObjectInfo(local_mem);
if (err != CL_SUCCESS){
printf("Error: getBufferObjectInfo() %d\n",err);
fflush(stdout);
return EXIT_FAILURE;
}
#endif
*mem = local_mem;
return CL_SUCCESS;
}
#ifdef BUFFER_OBJECT_INFO_DISPLAY
int getBufferObjectInfo(cl_mem object){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment