use of de.mirkosertic.bytecoder.api.opencl.OpenCLType in project Bytecoder by mirkosertic.
the class OpenCLContext method toDataRef.
private static DataRef toDataRef(Object[] aArray, Class aDataType) {
if (FloatSerializable.class.isAssignableFrom(aDataType)) {
OpenCLType theType = (OpenCLType) aDataType.getAnnotation(OpenCLType.class);
int theSize = aArray.length * theType.elementCount();
FloatBuffer theBuffer = FloatBuffer.allocate(theSize);
for (Object anAArray : aArray) {
FloatSerializable theVec = (FloatSerializable) anAArray;
theVec.writeTo(theBuffer);
}
return new DataRef(Pointer.to(theBuffer), Sizeof.cl_float * theSize) {
@Override
public void updateFromBuffer() {
theBuffer.rewind();
for (Object anAArray : aArray) {
FloatSerializable theVec = (FloatSerializable) anAArray;
theVec.readFrom(theBuffer);
}
}
};
}
throw new IllegalArgumentException("Not supported datatype : " + aDataType);
}
use of de.mirkosertic.bytecoder.api.opencl.OpenCLType in project Bytecoder by mirkosertic.
the class OpenCLWriter method toStructName.
private String toStructName(BytecodeObjectTypeRef aObjectType) {
BytecodeLinkedClass theLinkedClass = linkerContext.resolveClass(aObjectType);
BytecodeClass theBytecodeClass = theLinkedClass.getBytecodeClass();
BytecodeAnnotation theAnnotation = theBytecodeClass.getAttributes().getAnnotationByType(OpenCLType.class.getName());
if (theAnnotation == null) {
throw new IllegalArgumentException("No @OpenCLType found for " + aObjectType.name());
}
return theAnnotation.getElementValueByName("name").stringValue();
}
Aggregations