@@ -48,7 +48,10 @@ protected static class IcdEntity extends StructObject {
4848 @ Field (0 )
4949 public Pointer <?> icdDispatchTable = ProxiedOpenCLImplementation .icdDispatchTable ;
5050 @ Field (1 )
51- public int platformIndex ;
51+ public int implementationIndex ;
52+ @ Field (2 )
53+ public int entityIndex ;
54+
5255
5356 public IcdEntity () {
5457 super ();
@@ -57,31 +60,26 @@ public IcdEntity(Pointer<? extends IcdEntity> peer, Object... targs) {
5760 super (peer );
5861 }
5962 }
60- protected static class PlatformId extends IcdEntity {
61-
62- public PlatformId () {
63- super ();
64- }
65- public PlatformId (Pointer <? extends PlatformId > peer , Object ... targs ) {
66- super (peer );
67- }
68-
63+
64+ public static IcdEntity createEntity (int implementationIndex , int entityIndex ) {
65+ IcdEntity entity = new IcdEntity ();
66+ entity .implementationIndex = implementationIndex ;
67+ entity .entityIndex = entityIndex ;
68+ BridJ .writeToNative (entity );
69+ return entity ;
6970 }
7071
71- private final List <IOpenCLImplementation > platforms ;
72- private final List <PlatformId > platformIds ;
72+ private final List <IOpenCLImplementation > implementations ;
73+ private final List <IcdEntity > platformIds ;
7374
74- public ProxiedOpenCLImplementation (List <IOpenCLImplementation > platforms ) {
75- this .platforms = new ArrayList <IOpenCLImplementation >(platforms );
75+ public ProxiedOpenCLImplementation (List <IOpenCLImplementation > implementations ) {
76+ this .implementations = new ArrayList <IOpenCLImplementation >(implementations );
7677
77- List <PlatformId > platformIds = new ArrayList <PlatformId >();
78- for (IOpenCLImplementation implementation : this .platforms ) {
79- PlatformId platformId = new PlatformId ();
80- platformId .platformIndex = platforms .size ();
81- BridJ .writeToNative (platformId );
82-
83- platforms .add (implementation );
84- platformIds .add (platformId );
78+ List <IcdEntity > platformIds = new ArrayList <IcdEntity >();
79+ for (IOpenCLImplementation implementation : this .implementations ) {
80+ int implementationIndex = implementations .size ();
81+ implementations .add (implementation );
82+ platformIds .add (createEntity (implementationIndex , implementationIndex ));
8583 }
8684 this .platformIds = platformIds ;
8785 }
@@ -92,7 +90,7 @@ protected IOpenCLImplementation getImplementation(long icdEntityPeer) {
9290 IcdEntity icdEntity = icdEntityPtr .get ();
9391 if (!icdDispatchTable .equals (icdEntity .icdDispatchTable ))
9492 throw new IllegalArgumentException ("Not an ICD entity, or different ICD dispatch table: " + icdEntityPeer );
95- IOpenCLImplementation implementation = platforms .get (icdEntity .platformIndex );
93+ IOpenCLImplementation implementation = implementations .get (icdEntity .implementationIndex );
9694 return implementation ;
9795 }
9896
@@ -692,7 +690,7 @@ public int clSetUserEventStatus(long cl_event1, int cl_int1) {
692690
693691 @ Override
694692 public int clUnloadCompiler () {
695- for (IOpenCLImplementation implementation : platforms ) {
693+ for (IOpenCLImplementation implementation : implementations ) {
696694 int res = implementation .clUnloadCompiler ();
697695 if (res != CL_SUCCESS )
698696 return res ;
0 commit comments