Friday, October 19, 2018

Digest for comp.lang.c++@googlegroups.com - 8 updates in 4 topics

Christian Gollwitzer <auriocus@gmx.de>: Oct 19 10:42PM +0200

Hi,
 
I've got a strange error message while developing a program for OpenCL
when compiling on gcc 4.8.5
 
clfdk.cpp:322:23: error: cannot bind packed field 'geom.fdk_geom::Pmat'
to 'cl_float4 (&)[4]'
mat4copy(P, geom.Pmat);
 
The error has not occured with previous versions, or with clang++ or
VC++, so I'd like to know, if this is a compiler bug/missing feature.
 
mat4copy is defined as a template:
 
// 4x4 matrix assignment, for incompatible types
template <typename mat4like1, typename mat4like2>
void mat4copy(mat4like1 src, mat4like2 &dest) {
for (int i = 0; i < 4; ++i) {
for(int j = 0; j < 4; ++j)
{
dest[i].s[j]=src[i].s[j];
}
}
}
 
It should perform elementwise assignment of collections of 4 cl_float4
datatypes, which are defined as structs of 4 floats in the OpenCL system
header.
 
I use a structure to pass data from the CPU to the GPU, which is defined as:
 
==========================
#ifdef __OPENCL_VERSION__
// On the device
#define ffloat float
#define fint int
 
#else
// On the host
#include "cl.hpp"
#define HOST_COMPILER
 
#define ffloat cl_float
#define fint cl_int
#define float4 cl_float4
 

No comments: