Skip to content

Commit

Permalink
added obtain[Device|Platform]Properties() methods to CLUtils.
Browse files Browse the repository at this point in the history
added preferred vector width utility accessors to CLDevice.
put impl package on javadoc ignore list.
  • Loading branch information
mbien committed Jan 23, 2010
1 parent e8179f3 commit 8e2cfb1
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 3 deletions.
5 changes: 2 additions & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,11 @@
<fileset dir="${src.java.dir}" excludes="${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.native.dir}" excludes="${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/*.java"/>
</fileset>

<excludepackage name="com.mbien.opencl.impl"/>
</javadoc>
</target>

Expand Down
56 changes: 56 additions & 0 deletions src/com/mbien/opencl/CLDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,54 @@ public int getAddressBits() {
return (int)deviceInfo.getLong(CL_DEVICE_ADDRESS_BITS);
}

/**
* Preferred native vector width size for built-in short vectors.
* The vector width is defined as the number of scalar elements that can be stored in the vector.
*/
public int getPreferedShortVectorWidth() {
return (int)deviceInfo.getLong(CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT);
}

/**
* Preferred native vector width size for built-in char vectors.
* The vector width is defined as the number of scalar elements that can be stored in the vector.
*/
public int getPreferedCharVectorWidth() {
return (int)deviceInfo.getLong(CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR);
}

/**
* Preferred native vector width size for built-in int vectors.
* The vector width is defined as the number of scalar elements that can be stored in the vector.
*/
public int getPreferedIntVectorWidth() {
return (int)deviceInfo.getLong(CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT);
}

/**
* Preferred native vector width size for built-in long vectors.
* The vector width is defined as the number of scalar elements that can be stored in the vector.
*/
public int getPreferedLongVectorWidth() {
return (int)deviceInfo.getLong(CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG);
}

/**
* Preferred native vector width size for built-in float vectors.
* The vector width is defined as the number of scalar elements that can be stored in the vector.
*/
public int getPreferedFloatVectorWidth() {
return (int)deviceInfo.getLong(CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT);
}

/**
* Preferred native vector width size for built-in double vectors.
* The vector width is defined as the number of scalar elements that can be stored in the vector.
*/
public int getPreferedDoubleVectorWidth() {
return (int)deviceInfo.getLong(CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE);
}

/**
* Returns the number of parallel compute cores on the OpenCL device.
* The minimum value is 1.
Expand Down Expand Up @@ -226,6 +274,14 @@ public long getGlobalMemCachSize() {
return deviceInfo.getLong(CL_DEVICE_GLOBAL_MEM_CACHE_SIZE);
}

/**
* Returns the max number of arguments declared with the <code>constant</code>
* qualifier in a kernel. The minimum value is 8.
*/
public long getMaxConstantArgs() {
return deviceInfo.getLong(CL_DEVICE_MAX_CONSTANT_ARGS);
}

/**
* Returns true if images are supported by the OpenCL device and false otherwise.
*/
Expand Down
74 changes: 74 additions & 0 deletions src/com/mbien/opencl/CLUtils.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.mbien.opencl;

import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;

/**
*
Expand All @@ -22,4 +25,75 @@ public static String clString2JavaString(ByteBuffer chars, int clLength) {
}
}

public static Map<String, String> obtainPlatformProperties(CLPlatform platform) {

Map<String, String> map = new LinkedHashMap<String, String>();
map.put("CL_PLATFORM_NAME", platform.getName());
map.put("CL_PLATFORM_PROFILE", platform.getProfile());
map.put("CL_PLATFORM_VERSION", platform.getVersion());
map.put("CL_PLATFORM_VENDOR", platform.getVendor());
// map.put("fastest device (estimated)", platform.getMaxFlopsDevice().toString());

return map;
}

public static Map<String, String> obtainDeviceProperties(CLDevice dev) {

Map<String, String> map = new LinkedHashMap<String, String>();
map.put("CL_DEVICE_NAME", dev.getName());
map.put("CL_DEVICE_PROFILE", dev.getProfile());
map.put("CL_DEVICE_VENDOR", dev.getVendor());
map.put("CL_DEVICE_VENDOR_ID", dev.getVendorID()+"");
map.put("CL_DEVICE_VERSION", dev.getVersion());
map.put("CL_DRIVER_VERSION", dev.getDriverVersion());
map.put("CL_DEVICE_TYPE", dev.getType().toString());

map.put("CL_DEVICE_GLOBAL_MEM_SIZE", dev.getGlobalMemSize()/(1024*1024)+" MB");
map.put("CL_DEVICE_MAX_MEM_ALLOC_SIZE", dev.getMaxMemAllocSize()/(1024*1024)+" MB");
map.put("CL_DEVICE_MAX_PARAMETER_SIZE", dev.getMaxParameterSize()+" Byte");
map.put("CL_DEVICE_LOCAL_MEM_SIZE", dev.getLocalMemSize()/1024+" KB");
map.put("CL_DEVICE_LOCAL_MEM_TYPE", dev.getLocalMemType()+"");
map.put("CL_DEVICE_GLOBAL_MEM_CACHE_SIZE", dev.getGlobalMemCachSize()+"");
map.put("CL_DEVICE_GLOBAL_MEM_CACHE_TYPE", dev.getGlobalMemCacheType()+"");
map.put("CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE", dev.getMaxConstantBufferSize()+"");
map.put("CL_DEVICE_MAX_CONSTANT_ARGS", dev.getMaxConstantArgs()+"");
map.put("CL_DEVICE_ERROR_CORRECTION_SUPPORT", dev.isErrorCorrectionSupported()+"");

map.put("CL_DEVICE_MAX_CLOCK_FREQUENCY", dev.getMaxClockFrequency()+" MHz");
map.put("CL_DEVICE_PROFILING_TIMER_RESOLUTION", dev.getProfilingTimerResolution()+" ns");
map.put("CL_DEVICE_QUEUE_PROPERTIES", dev.getQueueProperties()+"");
map.put("CL_DEVICE_MAX_WORK_GROUP_SIZE", dev.getMaxWorkGroupSize()+"");
map.put("CL_DEVICE_MAX_COMPUTE_UNITS", dev.getMaxComputeUnits()+"");
map.put("CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS", dev.getMaxWorkItemDimensions()+"");
map.put("CL_DEVICE_MAX_WORK_ITEM_SIZES", Arrays.toString(dev.getMaxWorkItemSizes()));
map.put("CL_DEVICE_COMPILER_AVAILABLE", dev.isCompilerAvailable()+"");

map.put("CL_DEVICE_IMAGE_SUPPORT", dev.isImageSupportAvailable()+"");
map.put("CL_DEVICE_MAX_READ_IMAGE_ARGS", dev.getMaxReadImageArgs()+"");
map.put("CL_DEVICE_MAX_WRITE_IMAGE_ARGS", dev.getMaxWriteImageArgs()+"");
map.put("CL_DEVICE_IMAGE2D_MAX_DIMENSIONS", Arrays.asList(dev.getMaxImage2dWidth(), dev.getMaxImage2dHeight()).toString());
map.put("CL_DEVICE_IMAGE3D_MAX_DIMENSIONS", Arrays.asList(dev.getMaxImage2dWidth(), dev.getMaxImage2dHeight(), dev.getMaxImage3dDepth()).toString());
map.put("CL_DEVICE_MAX_SAMPLERS", dev.getMaxSamplers()+"");

map.put("CL_DEVICE_ADDRESS_BITS", dev.getAddressBits()+"");
map.put("cl_khr_fp16", dev.isHalfFPAvailable()+"");
map.put("cl_khr_fp64", dev.isDoubleFPAvailable()+"");
map.put("CL_DEVICE_ENDIAN_LITTLE", dev.isLittleEndianAvailable()+"");
map.put("CL_DEVICE_HALF_FP_CONFIG", dev.getHalfFPConfig()+"");
map.put("CL_DEVICE_SINGLE_FP_CONFIG", dev.getSingleFPConfig()+"");
map.put("CL_DEVICE_DOUBLE_FP_CONFIG", dev.getDoubleFPConfig()+"");
map.put("CL_DEVICE_EXTENSIONS", dev.getExtensions()+"");

map.put("CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT", dev.getPreferedShortVectorWidth()+"");
map.put("CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR", dev.getPreferedCharVectorWidth()+"");
map.put("CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT", dev.getPreferedIntVectorWidth()+"");
map.put("CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG", dev.getPreferedLongVectorWidth()+"");
map.put("CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT", dev.getPreferedFloatVectorWidth()+"");
map.put("CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE", dev.getPreferedDoubleVectorWidth()+"");

//TODO device extensions -> properties

return map;
}

}

0 comments on commit 8e2cfb1

Please sign in to comment.