diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..d8bf3b6c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: java + +jdk: +- oraclejdk8 +- openjdk6 + +cache: + directories: + - $HOME/.m2 + +env: +- MAVEN_OPTS=-Xmx512m CL_LOG_ERRORS=stdout + +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq fglrx=2:8.960-0ubuntu1 opencl-headers diff --git a/CHANGELOG b/CHANGELOG.md similarity index 58% rename from CHANGELOG rename to CHANGELOG.md index 28b78b66..36784845 100644 --- a/CHANGELOG +++ b/CHANGELOG.md @@ -1,48 +1,69 @@ -Current development version (1.0-SNAPSHOT) +## Current development version (1.0-SNAPSHOT) ... -Version 1.0.0-RC4 (20150308) +## Version 1.0.0-RC4 (20150308) - Dropped Blas artifact from main deployment (requires addional repo since ujmp is not in Maven Central) - Dropped support for JNA variant of JavaCL. Migration is highly encouraged to get more features and bugfixes: https://code.google.com/p/javacl/wiki/MigratingFromJNAToBridJ - Updated to BridJ 0.7 (brings fixes and lots of performance enhancements) - Optimized allocation of native memory throughout the library (reusing thread-local pointer pools) - Optimized (CLDevice, CLPlatform).hasExtension -- Added basic handling of structs in JavaCL Generator (issue #421, issue #422, issue #423) +- Added basic handling of structs in JavaCL Generator ([issue nativelibs4java#421] + (https://github.com/nativelibs4java/nativelibs4java/issues/421), [issue nativelibs4java#422] + (https://github.com/nativelibs4java/nativelibs4java/issues/422), [issue nativelibs4java#423] + (https://github.com/nativelibs4java/nativelibs4java/issues/423)) - Added CLBuffer.copyTo, .copyBytesTo, .copyElementsTo -- Added CLBuffer.fillBuffer to support OpenCL 1.2 clEnqueueFillBuffer (issue #232) +- Added CLBuffer.fillBuffer to support OpenCL 1.2 clEnqueueFillBuffer ([issue nativelibs4java#232] + (https://github.com/nativelibs4java/nativelibs4java/issues/232)) - Added CLDevice.getParent() - Added CLDevice.getPrintfBufferSize(), .isPreferredInteropUserSync(), .isLinkerAvailable() -- Added CLImage.copyTo (issue #508) -- Added CLImage.fillImage (issue #232) -- Added CLPlatform.unloadPlatformCompiler() with automatic switch between OpenCL 1.1 clUnloadCompiler and OpenCL 1.2 clUnloadPlatformCompiler (issue #232) -- Added CLQueue.enqueueBarrier & .enqueueMarker to support clEnqueueBarrierWithWaitList & clEnqueueMarkerWithWaitList (switching between OpenCL 1.1 and OpenCL 1.2 variants automatically) (issue #232) -- Added CLQueue.enqueueMigrateMemObjects (issue #232) +- Added CLImage.copyTo ([issue nativelibs4java#508] + (https://github.com/nativelibs4java/nativelibs4java/issues/508)) +- Added CLImage.fillImage ([issue nativelibs4java#232] + (https://github.com/nativelibs4java/nativelibs4java/issues/232)) +- Added CLPlatform.unloadPlatformCompiler() with automatic switch between OpenCL 1.1 clUnloadCompiler and OpenCL 1.2 clUnloadPlatformCompiler ([issue nativelibs4java#232] + (https://github.com/nativelibs4java/nativelibs4java/issues/232)) +- Added CLQueue.enqueueBarrier & .enqueueMarker to support clEnqueueBarrierWithWaitList & clEnqueueMarkerWithWaitList (switching between OpenCL 1.1 and OpenCL 1.2 variants automatically) ([issue nativelibs4java#232] + (https://github.com/nativelibs4java/nativelibs4java/issues/232)) +- Added CLQueue.enqueueMigrateMemObjects ([issue nativelibs4java#232] + (https://github.com/nativelibs4java/nativelibs4java/issues/232)) - Added JAVACL_LOG_CALLS=1 / -Djavacl.logCalls=true to log every native call (similar to BRIDJ_LOG_CALLS except it prints the parameter and return values) -- Added many missing CLDevice 1.2 info getters (issue #232), -- Added MapFlags.WriteInvalidateRegion (CL_MAP_WRITE_INVALIDATE_REGION from OpenCL 1.2) (issue #232) +- Added many missing CLDevice 1.2 info getters ([issue nativelibs4java#232] + (https://github.com/nativelibs4java/nativelibs4java/issues/232)), +- Added MapFlags.WriteInvalidateRegion (CL_MAP_WRITE_INVALIDATE_REGION from OpenCL 1.2) ([issue nativelibs4java#232] + (https://github.com/nativelibs4java/nativelibs4java/issues/232)) - Fixed crash in CLPlatform.getBinaries() -- Fixed excessive logs for deprecated features and missing OpenCL 1.1 and 1.2 functions (especially if version < deprecatedVersion) -- Fixed issue #387: don't call clReleaseDevice (OpenCL 1.2) unless explicitly needed -- Fixed issue #397: crash on Radeon due to bug in driver (attempts to get the source from a program created with clCreateProgramWithBinary yields a segfault) -- Fixed issue #397: major bug in CLProgram -- Fixed issue #420: horrible random native crash (double release, found with new -Dbridj.debug.pointer.releases=true). -- Fixed issue #453: don't try to load cached binaries for programs created from binaries! -- Fixed issue #455: when reading binaries, skip devices that are not allowed -- Fixed issue #479: avoid some NPEs in CLProgram.getProgramBuildInfo -- Fixed typo: CLDevice.getOpenCLVersion -> getOpenCLCVersion - -Version 1.0.0-RC3 (20130107) +- Fixed excessive logs for deprecated features and missing OpenCL 1.1 and 1.2 functions (especially if version < deprecatedVersion) +- Fixed [issue nativelibs4java#387] + (https://github.com/nativelibs4java/nativelibs4java/issues/387): don't call clReleaseDevice (OpenCL 1.2) unless explicitly needed +- Fixed [issue nativelibs4java#397] + (https://github.com/nativelibs4java/nativelibs4java/issues/397): crash on Radeon due to bug in driver (attempts to get the source from a program created with clCreateProgramWithBinary yields a segfault) +- Fixed [issue nativelibs4java#397] + (https://github.com/nativelibs4java/nativelibs4java/issues/397): major bug in CLProgram +- Fixed [issue nativelibs4java#420] + (https://github.com/nativelibs4java/nativelibs4java/issues/420): horrible random native crash (double release, found with new -Dbridj.debug.pointer.releases=true). +- Fixed [issue nativelibs4java#453] + (https://github.com/nativelibs4java/nativelibs4java/issues/453): don't try to load cached binaries for programs created from binaries! +- Fixed [issue nativelibs4java#455] + (https://github.com/nativelibs4java/nativelibs4java/issues/455): when reading binaries, skip devices that are not allowed +- Fixed [issue nativelibs4java#479] + (https://github.com/nativelibs4java/nativelibs4java/issues/479): avoid some NPEs in CLProgram.getProgramBuildInfo +- Fixed typo: CLDevice.getOpenCLVersion -> getOpenCLCVersion + +## Version 1.0.0-RC3 (20130107) - Fixed nasty regression in getBestDevice ! - Fixed ati byte order hack - Fixed byte order hack for ATI platforms - Fixes / optimized event callbacks (but broke API: CLEvent.EventCallback now only takes the completion status as argument, not the event anymore) - Fixed library probe -- Fixed handling of image2d_t and image3d_t in Maven plugin (contrib. from Remi Emonet, request #308 and issue #307) -- Fixed OpenGL interop on Windows (issue #312) -- Fixed error about mismatching byte order for byte buffers, and replaced mentions to getKernelsDefaultByteOrder() by getByteOrder() (issue #336) +- Fixed handling of image2d_t and image3d_t in Maven plugin (contrib. from Remi Emonet, request #308 and [issue nativelibs4java#307] + (https://github.com/nativelibs4java/nativelibs4java/issues/307)) +- Fixed OpenGL interop on Windows ([issue nativelibs4java#312] + (https://github.com/nativelibs4java/nativelibs4java/issues/312)) +- Fixed error about mismatching byte order for byte buffers, and replaced mentions to getKernelsDefaultByteOrder() by getByteOrder() ([issue nativelibs4java#336] + (https://github.com/nativelibs4java/nativelibs4java/issues/336)) - Fixed AMD App 2.7 Linux library loading code for - Fixed AMD download link in demos. - Added CLEvent.FIRE_AND_FORGET to avoid returning events from all the methods that accept a vararg eventsToWaitFor. @@ -55,26 +76,32 @@ Version 1.0.0-RC3 (20130107) - Deprecated CLKernel.enqueueNDRange with int[] parameters - Return CLUserEvent from CLContext.createUserEvent(); -Version 1.0.0-RC2 (20120415, commit 6bc061dfce06b941086a29f696195e82fbaffbdc) +## Version 1.0.0-RC2 (20120415, commit 6bc061dfce06b941086a29f696195e82fbaffbdc) - Release artifacts are available in Maven Central - Added support for sub-images reading/writing from/to CLImage2D (slower than with full images) -- Fixed endianness issues with CLBuffer (issue #80) -- Fixed migration of cached binaries to newer versions of OS (e.g. upgrading from Snow Leopard to Lion) (issue #81) -- Fixed handling compiler options containing spaces (issue #274) -- Fixed tutorial artifact pom repositories (issue #279) +- Fixed endianness issues with CLBuffer ([issue nativelibs4java#80] + (https://github.com/nativelibs4java/nativelibs4java/issues/80)) +- Fixed migration of cached binaries to newer versions of OS (e.g. upgrading from Snow Leopard to Lion) ([issue nativelibs4java#81] + (https://github.com/nativelibs4java/nativelibs4java/issues/81)) +- Fixed handling compiler options containing spaces ([issue nativelibs4java#274] + (https://github.com/nativelibs4java/nativelibs4java/issues/274)) +- Fixed tutorial artifact pom repositories ([issue nativelibs4java#279] + (https://github.com/nativelibs4java/nativelibs4java/issues/279)) - Fixed many Javadoc typos -- Fixed support of Intel's OpenCL Windows runtime (issue #297) +- Fixed support of Intel's OpenCL Windows runtime ([issue nativelibs4java#297] + (https://github.com/nativelibs4java/nativelibs4java/issues/297)) - Enhanced LocalSize API (added static factory methods for all primitive types) - Deprecated CLContext.getKernelsDefaultByteOrder() and CLDevice.getKernelsDefaultByteOrder() -- Added more informative exceptions when passing null pointers to CLBuffer.writeBytes (issue #257) +- Added more informative exceptions when passing null pointers to CLBuffer.writeBytes ([issue nativelibs4java#257] + (https://github.com/nativelibs4java/nativelibs4java/issues/257)) - Updated to OpenCL 1.2 headers - Added -cl-nv-verbose, -cl-nv-maxrregcount, -cl-nv-opt-level + proper log even without error when nv-verbose is set - Enhanced handling of endianness : warn when creating contexts with devices that have mismatching endianness, throw when creating buffer out of Buffer / Pointer with bad endianness - Changed signature of CLPlatform.listDevices (now takes a single CLDevice.Type, including All, instead of an EnumSet thereof) - Moved sources to github (https://github.com/ochafik/nativelibs4java/tree/master/libraries/OpenCL) -Version 1.0.0-RC1 (r2130, 20110621) +## Version 1.0.0-RC1 (r2130, 20110621) - BridJ version now becomes the default : the JNA version is still maintained and available with all Maven artifact ids suffixed with "-jna" (BridJ-based JavaCL's main artifact is now "javacl", while the JNA-based version is "javacl-jna") - added simple Fourier-analysis classes (package com.nativelibs4java.opencl.util.fft), with double and float variants, usable with primitive arrays or OpenCL buffers : @@ -90,21 +117,24 @@ Version 1.0.0-RC1 (r2130, 20110621) - added CLBuffer.copyTo(CLQueue, CLMem destination, CLEvent...) and CLBuffer.emptyClone(Usage) - added NIOUtils.indirectBuffer(size, bufferClass) - added CLContext.toString -- deprecated CLXXXBuffer in favor of CLBuffer (CLIntBuffer becomes CLBuffer, etc...) +- deprecated CLXXXBuffer in favor of CLBuffer<XXX> (CLIntBuffer becomes CLBuffer, etc...) - changed CLContext.createBuffer(Usage, length, class) to createBuffer(Usage, class, length) to match the JavaCL/BridJ API (and provoke migration issues : people should now use a primitive class rather than an NIO buffer class !!! -- complete rewrite of CLBuffer genericity to unify with the BridJ port : CLBuffer is now CLBuffer, and CLBuffer.read/write/map are no longer strongly typed (it is implicitely typed with Buffer subclasses for compatibility with existing code). The BridJ port will be favoured, and its read/write/map methods use typed Pointer. +- complete rewrite of CLBuffer genericity to unify with the BridJ port : CLBuffer<DoubleBuffer> is now CLBuffer, and CLBuffer.read/write/map are no longer strongly typed (it is implicitely typed with Buffer subclasses for compatibility with existing code). The BridJ port will be favoured, and its read/write/map methods use typed Pointer. - complete rewrite of UJMP Matrix implementation, using principles borrowed from ScalaCL -- fixed issue #66 (create temp files in ~/.javacl subdirectories instead of /tmp) +- fixed [issue nativelibs4java#66] + (https://github.com/nativelibs4java/nativelibs4java/issues/66) (create temp files in ~/.javacl subdirectories instead of /tmp) - fixed OpenGL sharing on MacOS X - fixed CLProgram.getBinaries() in some cases - fixed CLBuffer.read on indirect buffers - fixed NPE that happens with null varargs CLEvent[] array - fixed length = 1 case in reduction utility -- fixed ATI detection ("ATI Stream" now replaced by "AMD Accelerated Parallel Processing", cf. Csaba's comment in issue #39) -- fixed issue #55 : applied Kazo Csaba's patch to fix the bounds of CLBuffer.map's returned buffer +- fixed ATI detection ("ATI Stream" now replaced by "AMD Accelerated Parallel Processing", cf. Csaba's comment in [issue nativelibs4java#39] + (https://github.com/nativelibs4java/nativelibs4java/issues/39)) +- fixed [issue nativelibs4java#55] + (https://github.com/nativelibs4java/nativelibs4java/issues/55) : applied Kazo Csaba's patch to fix the bounds of CLBuffer.map's returned buffer - fixed inheritance of CLBuildException (now derives from CLException) -Version 1.0-beta-6 (r1637, 20100204) +## Version 1.0-beta-6 (r1637, 20100204) - Fixed support of ATI Stream 2.3 (CPU) - New interactive image kernel demo : lets you edit and test image kernels in a snap (bundled with a few samples) @@ -120,22 +150,29 @@ Version 1.0-beta-6 (r1637, 20100204) - Added LibCL : growing collection of OpenCL functions that can be included from any JavaCL kernel - CLKernel.enqueueNDRange has a new overload without localWorkSizes argument (it's then adjusted to a good value by the OpenCL implementation). - ScalaCLv2 was rewritten to fit nicely into Scala's collections framework. -- Added CLContext.createProgram(Map) to create from saved binaries (contribution from Kazo Csaba, issue #30) +- Added CLContext.createProgram(Map<CLDevice, byte[]>) to create from saved binaries (contribution from Kazo Csaba, [issue nativelibs4java#30] + (https://github.com/nativelibs4java/nativelibs4java/issues/30)) - Added CLProgram.addBuildOption(String) - Fixed CLBuffer.copyTo -- Demos now use the latest jogamp JOGL binaries (see the updated build instructions : http://code.google.com/p/javacl/wiki/Build) - -Version 1.0-beta-5 (r1067, 20100717) +- Demos now use the latest jogamp JOGL binaries (see the updated build instructions : [http://code.google.com/p/javacl/wiki/Build) +](http://code.google.com/p/javacl/wiki/Build) +) +## Version 1.0-beta-5 (r1067, 20100717) - Now using a nice configuration dialog when launching ParticlesDemo : has optional OpenCL settings with "Fastest", "Normal" and "Safest" presets + detailed platform and device choice (with optional OpenGL sharing choice). - Added optional context properties map argument to JavaCL.createContext (can be nulled out) -- Fixed issue #18: CLImage.write calls enqueueImageRead ! -- Documented workaround for Linux crashes (issue #20) : http://code.google.com/p/javacl/wiki/TroubleShootingJavaCLOnLinux -- Fixed issue #21: NIOUtils.put() doesn't accept ByteBuffer -- Fixed issue #25: CLEvent.waitFor bug causes segfault +- Fixed [issue nativelibs4java#18] + (https://github.com/nativelibs4java/nativelibs4java/issues/18): CLImage.write calls enqueueImageRead ! +- Documented workaround for Linux crashes ([issue nativelibs4java#20] + (https://github.com/nativelibs4java/nativelibs4java/issues/20)) : [http://code.google.com/p/javacl/wiki/TroubleShootingJavaCLOnLinux +](http://code.google.com/p/javacl/wiki/TroubleShootingJavaCLOnLinux +)- Fixed [issue nativelibs4java#21] + (https://github.com/nativelibs4java/nativelibs4java/issues/21): NIOUtils.put() doesn't accept ByteBuffer +- Fixed [issue nativelibs4java#25] + (https://github.com/nativelibs4java/nativelibs4java/issues/25): CLEvent.waitFor bug causes segfault - OpenCL 1.1 support : - CLContext.createUserEvent() - CLUserEvent.setStatus(int), setCompleted() @@ -152,13 +189,14 @@ out) - Faster enums - Check for cl_amd_fp64 in CLDevice.isDoubleSupported() - Fixed CLProgram.getBinaries() -- Fixed issue #22 (maven pom issue) +- Fixed [issue nativelibs4java#22] + (https://github.com/nativelibs4java/nativelibs4java/issues/22) (maven pom issue) -Version 1.0-beta-4 (r760, 20100121) +## Version 1.0-beta-4 (r760, 20100121) -- Changed semantics of offset & length arguments in typed CLxxxBuffer.read / write / map methods : now expressed in elements, not in bytes (e.g. 4 bytes per element for CLIntBuffer) +- Changed semantics of offset & length arguments in typed CLxxxBuffer.read / write / map methods : now expressed in elements, not in bytes (e.g. 4 bytes per element for CLIntBuffer) - Added OpenGL interoperability methods to CLContext and CLQueue (can create a CLByteBuffer from an OpenGL buffer object, a CLImage2D/3D from an OpenGL 2D/3D texture or a renderbuffer). -- Added OpenGL-compatible context creation methods to JavaCL & CLPlatform classes +- Added OpenGL-compatible context creation methods to JavaCL & CLPlatform classes - Added basic reduction support in ReductionUtils (cumulative additions, multiplications, min, max...) - Created javacl-demos package, with Particles, Hardware Report and Mandelbrot demos... - Finished migration from NativeLong to NativeSize (changes only the low-level bindings) @@ -169,29 +207,38 @@ Version 1.0-beta-4 (r760, 20100121) - Created a kernel wrapper autogenerator (Maven plugin based on JNAerator) : translates all constants on the Java side and presents kernels as methods with the correct Java argument types. It assumes OpenCL kernels (*.c, *.cl) are in src/main/opencl - Added wrappers around clGetKernelWorkGroupInfo - Fixed respect of endianness of devices that have different endianness than platform -- Fixed issue #10: "getMaxWorkItemSizes() fails on win7 64 GTX260" +- Fixed [issue nativelibs4java#10] + (https://github.com/nativelibs4java/nativelibs4java/issues/10): "getMaxWorkItemSizes() fails on win7 64 GTX260" -Version 1.0-beta-3 (r , 20091030) +## Version 1.0-beta-3 (r , 20091030) -- Fixed Issue #8 : NativeLong's can not represent size_t on windows x64 system (all user code that uses the low-level bindings needs to be updated : NativeLong -> NativeSize) +- Fixed [Issue nativelibs4java#8] + (https://github.com/nativelibs4java/nativelibs4java/issues/8) : NativeLong's can not represent size_t on windows x64 system (all user code that uses the low-level bindings needs to be updated : NativeLong -&gt; NativeSize) - Added CLContext/CLDevice.isDoubleSupported, isHalfSupported, isByteAddressableStoreSupported - Added If function to ScalaCL (operates on statements or on expressions) - Added CLAbstractEntity.release() -- Fixed Issue #4 : CLContext.createContext(CLDevice... devices) created context on only one device -- Regenerated the low level bindings with latest JNAerator : now using NativeSize class instead of NativeLong for size_t (fixes Issue #8) -- Fixed Issue #5 : fixed formatting of CLPlatform.toString() -- Fixed Issue #6 : use max X workgroup dimension for better benchmark speed -- Fixed Issue #7 : CLMem class bug in Usage.WriteOnly and Usage.ReadWrite -- Fixed Issue #11 : call clRetainMemObject when sharing a cl_mem between CLBuffer instances. +- Fixed [Issue nativelibs4java#4] + (https://github.com/nativelibs4java/nativelibs4java/issues/4) : CLContext.createContext(CLDevice... devices) created context on only one device +- Regenerated the low level bindings with latest JNAerator : now using NativeSize class instead of NativeLong for size_t (fixes [Issue nativelibs4java#8] + (https://github.com/nativelibs4java/nativelibs4java/issues/8)) +- Fixed [Issue nativelibs4java#5] + (https://github.com/nativelibs4java/nativelibs4java/issues/5) : fixed formatting of CLPlatform.toString() +- Fixed [Issue nativelibs4java#6] + (https://github.com/nativelibs4java/nativelibs4java/issues/6) : use max X workgroup dimension for better benchmark speed +- Fixed [Issue nativelibs4java#7] + (https://github.com/nativelibs4java/nativelibs4java/issues/7) : CLMem class bug in Usage.WriteOnly and Usage.ReadWrite +- Fixed [Issue nativelibs4java#11] + (https://github.com/nativelibs4java/nativelibs4java/issues/11) : call clRetainMemObject when sharing a cl_mem between CLBuffer instances. - Choose 'best' device in benchmark test -Version 1.0-beta-2 +## Version 1.0-beta-2 - JAR is now self-sufficient (includes JNA + JNAerator's runtime classes) - Added CLKernel.setLocalArg(argIndex, localArgByteLength) - Allow localWorkSizes to be null in enqueueNDRange - Added support for barriers and markers in CLQueue -- Fixed issue #2 : enqueueNDRange does not work for nDim > 1 +- Fixed [issue nativelibs4java#2] + (https://github.com/nativelibs4java/nativelibs4java/issues/2) : enqueueNDRange does not work for nDim > 1 - Added CLDevice.getMaxWorkItemSizes() - CLDevice.toString() now only prints the name - Moved method createContext from CLContext to CLPlatform @@ -211,7 +258,7 @@ Version 1.0-beta-2 - Added hashCode and equals method to most classes - Added ability to create out of order queues and change queue properties after creation -Version 1.0-beta-1 +## Version 1.0-beta-1 - New CLPlatform class (~ OpenCL implementation) which now hosts the list*Devices(...) methods - Entry point of library is now OpenCL4Java.listPlatforms() @@ -219,8 +266,8 @@ Version 1.0-beta-1 - Better separation between blocking and non blocking calls - New CLSampler class supported as argument of CLKernel - Many info getters with typesafe enums / enum sets in classes CLDevice, CLPlatform, CLKernel... -- Much more complete JavaDoc : http://nativelibs4java.sourceforge.net/sites/OpenCL4Java/apidocs/ -- Example & benchmark classes became JUnit tests and moved here : http://code.google.com/p/nativelibs4java/source/browse/#svn/trunk/lib... +- Much more complete JavaDoc : [http://nativelibs4java.sourceforge.net/sites/OpenCL4Java/apidocs/](http://nativelibs4java.sourceforge.net/sites/OpenCL4Java/apidocs/) +- Example & benchmark classes became JUnit tests and moved here : [http://code.google.com/p/nativelibs4java/source/browse/#svn/trunk/lib...](http://code.google.com/p/nativelibs4java/source/browse/#svn/trunk/lib...) While this release is rather OpenCL4Java-focused, ScalaCL also got its bunch of enhancements : - Added scalar variables IntVar, FloatVar, ShortVar... diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLBuffer.java b/Core/src/main/velocity/com/nativelibs4java/opencl/CLBuffer.java index a7fdd43d..d30051f7 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLBuffer.java +++ b/Core/src/main/velocity/com/nativelibs4java/opencl/CLBuffer.java @@ -569,10 +569,11 @@ public CLEvent copyBytesTo(CLQueue queue, CLBuffer destination, long sourceByteO #documentEventsToWaitForAndReturn() */ public CLEvent copyElementsTo(CLQueue queue, CLBuffer destination, long sourceElementOffset, long destinationElementOffset, long elementCount, CLEvent... eventsToWaitFor) { + long elementSize = getElementSize(); return copyBytesTo(queue, destination, - sourceElementOffset * getElementSize(), - destinationElementOffset * getElementSize(), - elementCount * getElementSize(), + sourceElementOffset * elementSize, + destinationElementOffset * elementSize, + elementCount * elementSize, eventsToWaitFor); } diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLDevice.java b/Core/src/main/velocity/com/nativelibs4java/opencl/CLDevice.java index 46954d8b..b30b9b47 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLDevice.java +++ b/Core/src/main/velocity/com/nativelibs4java/opencl/CLDevice.java @@ -727,15 +727,49 @@ public static long getValue(EnumSet set) { return EnumValues.getValue(set); } - public static EnumSet getEnumSet(long v) { - return EnumValues.getEnumSet(v, PartitionType.class); + public static PartitionType getEnum(long v) { + return EnumValues.getEnum(v, PartitionType.class); } } - /** TODO */ @InfoName("CL_DEVICE_PARTITION_PROPERTIES") public EnumSet getPartitionProperties() { - return PartitionType.getEnumSet(infos.getIntOrLong(getEntity(), CL_DEVICE_PARTITION_PROPERTIES)); + return getPartitionTypeInfo(CL_DEVICE_PARTITION_PROPERTIES); + } + + @InfoName("CL_DEVICE_PARTITION_TYPE") + public EnumSet getPartitionType() { + return getPartitionTypeInfo(CL_DEVICE_PARTITION_TYPE); + } + + private EnumSet getPartitionTypeInfo(int info) { + EnumSet ret = EnumSet.noneOf(PartitionType.class); + Pointer ptr = infos.getMemory(getEntity(), info); + if (ptr != null) { + Pointer props = ptr.as(SizeT.class); + for (long i = 0, n = props.getValidElements(); i < n; i++) { + long value = props.getSizeTAtIndex(i); + if (value == 0) { + break; + } + ret.add(PartitionType.getEnum(value)); + } + } + return ret; + } + + /** + * Returns the set of supported affinity domains for partitioning the device + * using {@link #createSubDevicesByAffinity(AffinityDomain)} + */ + @InfoName("CL_DEVICE_PARTITION_AFFINITY_DOMAIN") + public EnumSet getPartitionAffinityDomains() { + return AffinityDomain.getEnumSet(infos.getIntOrLong(getEntity(), CL_DEVICE_PARTITION_AFFINITY_DOMAIN)); + } + + @InfoName("CL_DEVICE_PARTITION_MAX_SUB_DEVICES") + public int getPartitionMaxSubDevices() { + return infos.getInt(getEntity(), CL_DEVICE_PARTITION_MAX_SUB_DEVICES); } /** TODO */ @@ -756,7 +790,7 @@ public long getReferenceCount() { */ public AffinityDomain getPartitionAffinityDomain() { Pointer memory = infos.getMemory(getEntity(), CL_DEVICE_PARTITION_TYPE); - long type = memory.getSizeT(); + long type = memory == null ? 0 : memory.getSizeT(); if (type != CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN) { return null; } @@ -1123,6 +1157,9 @@ public enum AffinityDomain implements com.nativelibs4java.util.ValuedEnum { public static AffinityDomain getEnum(long v) { return EnumValues.getEnum(v, AffinityDomain.class); } + public static EnumSet getEnumSet(long v) { + return EnumValues.getEnumSet(v, AffinityDomain.class); + } } /** @@ -1165,7 +1202,7 @@ public CLDevice[] createSubDevicesByCounts(long... computeUnitsForEachSubDevice) */ public CLDevice[] createSubDevicesByAffinity(AffinityDomain affinityDomain) { return createSubDevices(pointerToSizeTs( - CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, affinityDomain.value(), 0, 0 + CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, affinityDomain.value(), 0 )); } diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLException.java b/Core/src/main/velocity/com/nativelibs4java/opencl/CLException.java index 39d68ea7..44dcf91f 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLException.java +++ b/Core/src/main/velocity/com/nativelibs4java/opencl/CLException.java @@ -1,14 +1,17 @@ #parse("main/Header.vm") package com.nativelibs4java.opencl; + +import static com.nativelibs4java.opencl.JavaCL.log; import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; import static com.nativelibs4java.opencl.library.IOpenCLLibrary.*; + import com.nativelibs4java.opencl.library.OpenCLLibrary; import com.ochafik.util.string.StringUtils; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; + +import org.bridj.*; + import java.util.*; import java.lang.reflect.*; -import static com.nativelibs4java.opencl.JavaCL.log; import java.util.logging.Level; import java.util.logging.Logger; @@ -27,10 +30,10 @@ public int getCode() { return code; } - @Retention(RetentionPolicy.RUNTIME) - public @interface ErrorCode { - int value(); - } + @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) + @interface ErrorCode { + int value(); + } public static class CLVersionException extends CLException { public CLVersionException(String message) { @@ -52,8 +55,11 @@ public String getMessage() { return message + logSuffix; } - void setKernelArg(CLKernel kernel, int argIndex) { - message += " (kernel name = " + kernel.getFunctionName() + ", num args = " + kernel.getNumArgs() + ", arg index = " + argIndex; + void setKernelArg(CLKernel kernel, int argIndex, long size, Pointer ptr) { + message += " (kernel name = " + kernel.getFunctionName(); + message += ", num args = " + kernel.getNumArgs(); + message += ", arg index = " + argIndex; + message += ", arg size = " + size; CLProgram program = kernel.getProgram(); if (program != null) message += ", source = <<<\n\t" + program.getSource().replaceAll("\n", "\n\t"); @@ -264,3 +270,4 @@ public static void error(int err) { throw toThrow; } } + diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLKernel.java b/Core/src/main/velocity/com/nativelibs4java/opencl/CLKernel.java index cfc14f61..81fe07ba 100755 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLKernel.java +++ b/Core/src/main/velocity/com/nativelibs4java/opencl/CLKernel.java @@ -219,7 +219,7 @@ private void setKernelArg(int i, long size, Pointer ptr) { try { error(CL.clSetKernelArg(getEntity(), i, size, getPeer(ptr))); } catch (CLTypedException ex) { - ex.setKernelArg(this, i); + ex.setKernelArg(this, i, size, ptr); throw ex; } } @@ -231,55 +231,37 @@ public void setArg(int i, Pointer ptr) { setKernelArg(i, ptr.getValidBytes(), ptr); } +#foreach ($prim in $primitives) /** + * Sets a vector type value as the arg at index {@code i}. + * + * For instance to pass a {@code ${prim.Name}3}, one must pass a {@code ${prim.Name}[]} of size {@code 3}. + * #documentCallsFunction("clSetKernelArg") + * @param i index of the argument in the kernel's parameters list + * @param arg array of ${prim.Name}s (of length 2, 3, 4, 8 or 16, which must match the arity of the OpenCL vector type used by the kernel). */ - public void setArg(int i, float[] arg) { - setKernelArg(i, arg.length * 4, arg.length <= MAX_TMP_ITEMS ? localPointer.setFloats(arg) : pointerToFloats(arg)); + public void setArg(int i, ${prim.Name}[] arg) { + int length = normalizeVectorTypeArity(arg.length); + setKernelArg(i, length * ${prim.Size}, length <= MAX_TMP_ITEMS ? localPointer.set${prim.CapName}s(arg) : pointerTo${prim.CapName}s(arg)); } - /** -#documentCallsFunction("clSetKernelArg") - */ - public void setArg(int i, int[] arg) { - setKernelArg(i, arg.length * 4, arg.length <= MAX_TMP_ITEMS ? localPointer.setInts(arg) : pointerToInts(arg)); - } - /** -#documentCallsFunction("clSetKernelArg") - */ - public void setArg(int i, double[] arg) { - setKernelArg(i, arg.length * 8, arg.length <= MAX_TMP_ITEMS ? localPointer.setDoubles(arg) : pointerToDoubles(arg)); - } - /** -#documentCallsFunction("clSetKernelArg") - */ - public void setArg(int i, long[] arg) { - setKernelArg(i, arg.length * 8, arg.length <= MAX_TMP_ITEMS ? localPointer.setLongs(arg) : pointerToLongs(arg)); - } - /** -#documentCallsFunction("clSetKernelArg") - */ - public void setArg(int i, short[] arg) { - setKernelArg(i, arg.length * 2, arg.length <= MAX_TMP_ITEMS ? localPointer.setShorts(arg) : pointerToShorts(arg)); - } - /** -#documentCallsFunction("clSetKernelArg") - */ - public void setArg(int i, byte[] arg) { - setKernelArg(i, arg.length, arg.length <= MAX_TMP_ITEMS ? localPointer.setBytes(arg) : pointerToBytes(arg)); - } - /** -#documentCallsFunction("clSetKernelArg") - */ - public void setArg(int i, boolean[] arg) { - setKernelArg(i, arg.length, arg.length <= MAX_TMP_ITEMS ? localPointer.setBooleans(arg) : pointerToBooleans(arg)); - } - /** -#documentCallsFunction("clSetKernelArg") - */ - public void setArg(int i, char[] arg) { - setKernelArg(i, arg.length * 2, arg.length <= MAX_TMP_ITEMS ? localPointer.setChars(arg) : pointerToChars(arg)); +#end + + private static int normalizeVectorTypeArity(int length) { + switch (length) { + case 3: + // cl_3 is identical in size, alignment and behavior to cl_4. See section 6.1.5 + return 4; + case 2: + case 4: + case 8: + case 16: + return length; + default: + throw new IllegalArgumentException("Invalid vector type length: " + length + " (valid vector type sizes are 2, 3, 4, 8, 16)"); + } } - + /** #documentCallsFunction("clSetKernelArg") */ diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/JavaCL.java b/Core/src/main/velocity/com/nativelibs4java/opencl/JavaCL.java index 5b5aa07f..e993179b 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/JavaCL.java +++ b/Core/src/main/velocity/com/nativelibs4java/opencl/JavaCL.java @@ -219,9 +219,9 @@ else if (Platform.isMacOSX()) private static IOpenCLLibrary wrapWithLogs(final IOpenCLLibrary cl) { return (IOpenCLLibrary) Proxy.newProxyInstance(JavaCL.class.getClassLoader(), new Class[] { IOpenCLLibrary.class }, new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - log(Level.INFO, method.getName() + "(" + StringUtils.implode(args, ", ") + ")"); + log(Level.WARNING, method.getName() + "(" + StringUtils.implode(args, ", ") + ")"); Object ret = method.invoke(cl, args); - log(Level.INFO, "\t" + method.getName() + " -> " + ret); + log(Level.WARNING, "\t" + method.getName() + " -> " + ret); return ret; } }); diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/ReusablePointer.java b/Core/src/main/velocity/com/nativelibs4java/opencl/ReusablePointer.java index 86be0874..3b5c2a7c 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/ReusablePointer.java +++ b/Core/src/main/velocity/com/nativelibs4java/opencl/ReusablePointer.java @@ -12,8 +12,14 @@ final class ReusablePointer { public ReusablePointer(long bytesCapacity) { this.bytesCapacity = bytesCapacity; - this.pointer = Pointer.allocateBytes(bytesCapacity).withoutValidityInformation(); + this.pointer = allocateAlignedBytes(bytesCapacity).withoutValidityInformation(); } + + static Pointer allocateAlignedBytes(long count) { + // Allocate memory aligned to 128 bytes to match alignment of cl_double16. + return Pointer.allocateAlignedBytes(null /* io */, count, 128 /* alignment */, null /* beforeDeallocation */); + } + public Pointer pointerToInts(int... values) { if (values == null) return null; @@ -48,7 +54,7 @@ public Pointer allocatedBytes(int needed) { if (needed == 0) return null; if (needed > bytesCapacity) { - return (Pointer)Pointer.allocateBytes(needed); + return (Pointer)allocateAlignedBytes(needed); } else { return (Pointer)pointer; } @@ -59,4 +65,4 @@ public Pointer allocatedSizeTs(int needed) { public Pointer allocatedInts(int needed) { return allocatedBytes(needed * 4); } -} \ No newline at end of file +} diff --git a/Core/src/test/java/com/nativelibs4java/opencl/AbstractCommon.java b/Core/src/test/java/com/nativelibs4java/opencl/AbstractCommon.java index c2ec33c9..4957d898 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/AbstractCommon.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/AbstractCommon.java @@ -8,7 +8,6 @@ import org.junit.Before; import org.junit.BeforeClass; -import com.nativelibs4java.test.MiscTestUtils; import java.util.ArrayList; import java.util.List; import org.junit.After; @@ -27,12 +26,6 @@ public abstract class AbstractCommon { CLQueue queue; CLDevice device; CLImageFormat[] formatsRead2D, formatsRead3D, formatsWrite2D, formatsWrite3D, formatsReadWrite2D, formatsReadWrite3D; - /* - @BeforeClass - public static void setup() { - MiscTestUtils.protectJNI(); - } - */ static boolean listedPlatforms; @@ -68,4 +61,4 @@ public void cleanup() { platform.release(); } */ -} \ No newline at end of file +} diff --git a/Core/src/test/java/com/nativelibs4java/opencl/BinaryKernelTest.java b/Core/src/test/java/com/nativelibs4java/opencl/BinaryKernelTest.java index c67a4265..d8d9a74b 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/BinaryKernelTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/BinaryKernelTest.java @@ -8,7 +8,6 @@ import org.bridj.Pointer; import static org.bridj.Pointer.*; -import com.nativelibs4java.test.MiscTestUtils; import java.util.List; import org.junit.Ignore; import org.junit.runners.Parameterized; @@ -81,4 +80,4 @@ public void cachingTest() { sp2.setCached(true); // set to false and it works sp2.createKernel("sub"); } -} \ No newline at end of file +} diff --git a/Core/src/test/java/com/nativelibs4java/opencl/BufferTest.java b/Core/src/test/java/com/nativelibs4java/opencl/BufferTest.java index 47da5a47..79337db1 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/BufferTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/BufferTest.java @@ -15,7 +15,6 @@ import org.junit.BeforeClass; import org.junit.Test; -import com.nativelibs4java.test.MiscTestUtils; import com.nativelibs4java.util.NIOUtils; import org.bridj.*; import java.nio.ByteOrder; @@ -167,14 +166,19 @@ public void testFill() { } catch (Throwable th) {} } @Test - public void testCopyTo() { - CLBuffer b = context.createIntBuffer(CLMem.Usage.InputOutput, pointerToInts(1, 2, 3, 4)); - CLBuffer out = context.createIntBuffer(CLMem.Usage.InputOutput, 4); - CLEvent e = b.copyElementsTo(queue, out, 2, 1, 2); - assertArrayEquals(new int[] { 0, 3, 4, 0 }, out.read(queue, e).getInts()); - - e = b.copyTo(queue, out); - assertArrayEquals(new int[] { 1, 2, 3, 4 }, out.read(queue, e).getInts()); + public void testCopyTo_full() { + CLBuffer b = context.createIntBuffer(CLMem.Usage.InputOutput, pointerToInts(1, 2, 3, 4, 5, 6)); + CLBuffer out = context.createIntBuffer(CLMem.Usage.InputOutput, 6); + + CLEvent e = b.copyTo(queue, out); + assertArrayEquals(new int[] { 1, 2, 3, 4, 5, 6 }, out.read(queue, e).getInts()); } + @Test + public void testCopyTo_partial() { + CLBuffer b = context.createIntBuffer(CLMem.Usage.InputOutput, pointerToInts(1, 2, 3, 4, 5, 6)); + CLBuffer out = context.createIntBuffer(CLMem.Usage.InputOutput, 6); + CLEvent e = b.copyElementsTo(queue, out, 2, 1, 2); + assertArrayEquals(new int[] { 3, 4 }, out.read(queue, e).next().validElements(2).getInts()); + } } diff --git a/Core/src/test/java/com/nativelibs4java/opencl/ByteOrderHackTest.java b/Core/src/test/java/com/nativelibs4java/opencl/ByteOrderHackTest.java index d356b71f..46cdc3b1 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/ByteOrderHackTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/ByteOrderHackTest.java @@ -8,7 +8,6 @@ import org.bridj.Pointer; import static org.bridj.Pointer.*; -import com.nativelibs4java.test.MiscTestUtils; import java.util.List; import org.junit.runners.Parameterized; diff --git a/Core/src/test/java/com/nativelibs4java/opencl/DeviceTest.java b/Core/src/test/java/com/nativelibs4java/opencl/DeviceTest.java index 7bdd5f1e..fe2b8518 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/DeviceTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/DeviceTest.java @@ -14,34 +14,50 @@ import org.junit.*; -import com.nativelibs4java.test.MiscTestUtils; import com.nativelibs4java.util.NIOUtils; import org.bridj.*; import java.nio.ByteOrder; import static org.bridj.Pointer.*; import java.nio.ByteOrder; -import java.util.List; +import java.util.*; +import org.junit.runner.RunWith; import org.junit.runners.Parameterized; /** * * @author ochafik */ -public class DeviceTest extends AbstractCommon { +@RunWith(Parameterized.class) +public class DeviceTest { + private final CLDevice device; + public DeviceTest(CLDevice device) { - super(device); + this.device = device; + + System.out.println(device); + System.out.println("\tmax sub-devices: " + device.getPartitionMaxSubDevices()); + System.out.println("\tpartition properties: " + device.getPartitionProperties()); + System.out.println("\tpartition domains: " + device.getPartitionAffinityDomains()); } @Parameterized.Parameters public static List getDeviceParameters() { - return AbstractCommon.getDeviceParameters(); + List ret = new ArrayList(); + for (CLPlatform platform : JavaCL.listPlatforms()) { + for (CLDevice device : platform.listAllDevices(true)) { + ret.add(new Object[] { device }); + } + } + return ret; } - @Ignore + @Test public void testSplitEqually() { + if (!device.getPartitionProperties().contains(CLDevice.PartitionType.Equally)) return; + int computeUnits = device.getMaxComputeUnits(); System.out.println("computeUnits = " + computeUnits); - int subComputeUnits = 1;//computeUnits / 2; + int subComputeUnits = computeUnits / 2; CLDevice[] subDevices = device.createSubDevicesEqually(subComputeUnits); for (CLDevice subDevice : subDevices) { @@ -49,34 +65,72 @@ public void testSplitEqually() { checkParent(device, subDevice); } } - @Ignore + @Test public void testSplitByCounts() { + if (!device.getPartitionProperties().contains(CLDevice.PartitionType.ByCounts)) return; + long[] counts = new long[] { 2, 4, 8 }; CLDevice[] subDevices = device.createSubDevicesByCounts(counts); assertEquals(counts.length, subDevices.length); int i = 0; + long[] actualCounts = new long[counts.length]; for (CLDevice subDevice : subDevices) { - long count = counts[i]; - assertEquals(count, subDevice.getMaxComputeUnits()); + actualCounts[i] = subDevice.getMaxComputeUnits(); checkParent(device, subDevice); i++; } + Arrays.sort(actualCounts); + assertArrayEquals(counts, actualCounts); } - @Ignore - @Test - public void testSplitByAffinity() { - CLDevice[] subDevices = device.createSubDevicesByAffinity(CLDevice.AffinityDomain.NextPartitionable); + + public void checkSplitByAffinity(CLDevice.AffinityDomain domain) { + if (!device.getPartitionProperties().contains(CLDevice.PartitionType.ByAffinityDomain)) { + System.out.println("Split by affinity is not supported by device " + device); + return; + } + if (!device.getPartitionAffinityDomains().contains(domain)) { + System.out.println("Affinity domain " + domain + " not supported by device " + device); + return; + } + + CLDevice[] subDevices = device.createSubDevicesByAffinity(domain); assertTrue(subDevices.length > 1); for (CLDevice subDevice : subDevices) { checkParent(device, subDevice); + assertEquals(domain, subDevice.getPartitionAffinityDomain()); } } + @Test + public void testSplitByAffinity_NUMA() { + checkSplitByAffinity(CLDevice.AffinityDomain.NUMA); + } + @Test + public void testSplitByAffinity_L4Cache() { + checkSplitByAffinity(CLDevice.AffinityDomain.L4Cache); + } + @Test + public void testSplitByAffinity_L3Cache() { + checkSplitByAffinity(CLDevice.AffinityDomain.L3Cache); + } + @Test + public void testSplitByAffinity_L2Cache() { + checkSplitByAffinity(CLDevice.AffinityDomain.L2Cache); + } + @Test + public void testSplitByAffinity_L1Cache() { + checkSplitByAffinity(CLDevice.AffinityDomain.L1Cache); + } + @Test + public void testSplitByAffinity_NextPartitionable() { + checkSplitByAffinity(CLDevice.AffinityDomain.NextPartitionable); + } + private void checkParent(CLDevice parent, CLDevice child) { - assertSame(device, child.getParent()); + assertSame(parent, child.getParent()); // Force a get info CL_DEVICE_PARENT_DEVICE. - assertSame(device, new CLDevice(platform, null, child.getEntity(), false).getParent()); + assertEquals(parent, new CLDevice(device.getPlatform(), null, child.getEntity(), false).getParent()); } } diff --git a/Core/src/test/java/com/nativelibs4java/opencl/EventTest.java b/Core/src/test/java/com/nativelibs4java/opencl/EventTest.java index acfe8a20..911ad8e1 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/EventTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/EventTest.java @@ -8,7 +8,6 @@ import org.bridj.Pointer; import static org.bridj.Pointer.*; -import com.nativelibs4java.test.MiscTestUtils; import java.util.List; import org.junit.runners.Parameterized; diff --git a/Core/src/test/java/com/nativelibs4java/opencl/InfoGettersTest.java b/Core/src/test/java/com/nativelibs4java/opencl/InfoGettersTest.java index 1adff649..66fc54a8 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/InfoGettersTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/InfoGettersTest.java @@ -4,17 +4,18 @@ */ package com.nativelibs4java.opencl; -import static com.nativelibs4java.test.MiscTestUtils.testGetters; import static org.junit.Assert.assertFalse; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + import java.util.logging.Level; import java.util.logging.Logger; import org.junit.Before; import org.junit.BeforeClass; -import com.nativelibs4java.test.MiscTestUtils; - /** * * @author ochafik @@ -124,4 +125,45 @@ public void CLEventGetters() { public void CLSamplerGetters() { testGetters(createSampler()); } + + public static void testGetters(Object instance) { + if (instance == null) + return; + Logger log = Logger.getLogger(instance.getClass().getName()); + for (Method m : instance.getClass().getDeclaredMethods()) { + if (Modifier.isStatic(m.getModifiers())) + continue; + if (!Modifier.isPublic(m.getModifiers())) + continue; + if (m.getParameterTypes().length != 0) + continue; + + String name = m.getName(); + if (name.contains("ProfilingCommand")) + continue; + + boolean isToString = name.equals("toString"); + if (name.startsWith("get") && name.length() > 3 || + name.startsWith("has") && name.length() > 3 || + name.startsWith("is") && name.length() > 2 || + isToString && !Modifier.isPublic(m.getDeclaringClass().getModifiers())) + { + String msg = "Failed to call " + m; + try { + m.invoke(instance); + } catch (IllegalAccessException ex) { + if (!isToString) + log.log(Level.WARNING, msg, ex); + } catch (InvocationTargetException ex) { + Throwable cause = ex.getCause(); + if (!(cause instanceof UnsupportedOperationException)) { + log.log(Level.SEVERE, msg, ex.getCause()); + assertFalse(msg, true); + } + } catch (Exception ex) { + log.log(Level.SEVERE, msg, ex); + } + } + } + } } diff --git a/Core/src/test/java/com/nativelibs4java/opencl/KernelTest.java b/Core/src/test/java/com/nativelibs4java/opencl/KernelTest.java index 5d0c3956..af3c8064 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/KernelTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/KernelTest.java @@ -56,7 +56,18 @@ public Object testArrayArg(String type, Object array, Class targetType) { @Test public void nullArg() { - assertArrayEquals(new Pointer[] { null }, testArg("int", CLKernel.NULL_POINTER_KERNEL_ARGUMENT, Pointer.class).getPointers()); + CLBuffer out = context.createByteBuffer(Usage.InputOutput, 2) ; + CLKernel isInputNull = context.createProgram( + "kernel void isInputNull(global int* in, global bool* out) {\n" + + "*out = !in;\n" + + "}" + ).createKernel("isInputNull"); + + isInputNull.setArgs(CLKernel.NULL_POINTER_KERNEL_ARGUMENT, out); + assertTrue(out.read(queue, isInputNull.enqueueTask(queue)).as(Boolean.class).get()); + + isInputNull.setArgs(out, out); + assertFalse(out.read(queue, isInputNull.enqueueTask(queue)).as(Boolean.class).get()); } byte[] byteTup(int n) { diff --git a/Core/src/test/java/com/nativelibs4java/opencl/OpenCL4JavaBasicTest.java b/Core/src/test/java/com/nativelibs4java/opencl/OpenCL4JavaBasicTest.java index 64a13a8d..4af2e925 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/OpenCL4JavaBasicTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/OpenCL4JavaBasicTest.java @@ -12,7 +12,6 @@ import org.junit.BeforeClass; import org.junit.Test; -import com.nativelibs4java.test.MiscTestUtils; import com.nativelibs4java.util.NIOUtils; public class OpenCL4JavaBasicTest { diff --git a/Core/src/test/java/com/nativelibs4java/opencl/OpenCL4JavaBenchmarkTest.java b/Core/src/test/java/com/nativelibs4java/opencl/OpenCL4JavaBenchmarkTest.java index 866bef2c..d2ff6ce0 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/OpenCL4JavaBenchmarkTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/OpenCL4JavaBenchmarkTest.java @@ -18,7 +18,6 @@ import com.nativelibs4java.opencl.CLTestUtils.Action2; import com.nativelibs4java.opencl.CLTestUtils.ExecResult; -import com.nativelibs4java.test.MiscTestUtils; //import com.nativelibs4java.scalacl.*; /// @see http://ati.amd.com/technology/streamcomputing/intro_opencl.html#simple diff --git a/Core/src/test/java/com/nativelibs4java/opencl/OverheadTest.java b/Core/src/test/java/com/nativelibs4java/opencl/OverheadTest.java index 2d382090..65f1fdf5 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/OverheadTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/OverheadTest.java @@ -13,7 +13,6 @@ import org.bridj.Pointer; import org.bridj.Platform; import static org.bridj.Pointer.*; -import com.nativelibs4java.test.MiscTestUtils; import java.util.logging.Level; import java.util.logging.Logger; @@ -157,4 +156,4 @@ public void run() { assertTrue("CLKernel.setArg was supposed not to be more than " + maxSlower + "x slower than hand-optimized version, was " + slowerSetArg + "x slower.", slowerSetArg <= maxSlower); assertTrue("CLKernel.setArgs was supposed not to be more than " + maxSlower + "x slower than hand-optimized version, was " + slowerSetArgs + "x slower.", slowerSetArgs <= maxSlower); } -} \ No newline at end of file +} diff --git a/Core/src/test/java/com/nativelibs4java/test/MiscTestUtils.java b/Core/src/test/java/com/nativelibs4java/test/MiscTestUtils.java deleted file mode 100644 index 470e7f12..00000000 --- a/Core/src/test/java/com/nativelibs4java/test/MiscTestUtils.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package com.nativelibs4java.test; - -import static org.junit.Assert.assertFalse; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - * @author ochafik - */ -public class MiscTestUtils { - public static void protectJNI() { - //Native.setProtected(true); - } - public static void testGetters(Object instance) { - if (instance == null) - return; - Logger log = Logger.getLogger(instance.getClass().getName()); - for (Method m : instance.getClass().getDeclaredMethods()) { - if (Modifier.isStatic(m.getModifiers())) - continue; - if (!Modifier.isPublic(m.getModifiers())) - continue; - if (m.getParameterTypes().length != 0) - continue; - - String name = m.getName(); - if (name.contains("ProfilingCommand")) - continue; - - boolean isToString = name.equals("toString"); - if (name.startsWith("get") && name.length() > 3 || - name.startsWith("has") && name.length() > 3 || - name.startsWith("is") && name.length() > 2 || - isToString && !Modifier.isPublic(m.getDeclaringClass().getModifiers())) - { - String msg = "Failed to call " + m; - try { - m.invoke(instance); - } catch (IllegalAccessException ex) { - if (!isToString) - log.log(Level.WARNING, msg, ex); - } catch (InvocationTargetException ex) { - Throwable cause = ex.getCause(); - if (!(cause instanceof UnsupportedOperationException)) { - log.log(Level.SEVERE, msg, ex.getCause()); - assertFalse(msg, true); - } - } catch (Exception ex) { - log.log(Level.SEVERE, msg, ex); - } - } - } - } -} diff --git a/Generator/src/main/java/com/nativelibs4java/opencl/generator/JavaCLGenerator.java b/Generator/src/main/java/com/nativelibs4java/opencl/generator/JavaCLGenerator.java index 9c50fba9..89fcd1d7 100644 --- a/Generator/src/main/java/com/nativelibs4java/opencl/generator/JavaCLGenerator.java +++ b/Generator/src/main/java/com/nativelibs4java/opencl/generator/JavaCLGenerator.java @@ -8,8 +8,8 @@ import com.ochafik.lang.jnaerator.UnsupportedConversionException; import com.ochafik.lang.jnaerator.parser.*; import com.ochafik.lang.jnaerator.runtime.NativeSize; -import com.ochafik.util.listenable.Adapter; -import com.ochafik.util.listenable.Pair; +import com.nativelibs4java.jalico.Adapter; +import com.nativelibs4java.jalico.Pair; import com.ochafik.util.string.RegexUtils; import com.ochafik.util.string.StringUtils; import java.io.File; diff --git a/JavaCL/pom.xml b/JavaCL/pom.xml index 7a0b7da5..d4e2cb1f 100644 --- a/JavaCL/pom.xml +++ b/JavaCL/pom.xml @@ -72,7 +72,7 @@ For more info, please visit http://code.google.com/p/nativelibs4java/wiki/OpenCL org.apache.felix maven-bundle-plugin - 2.3.7 + 2.5.3 true diff --git a/MavenPlugin/pom.xml b/MavenPlugin/pom.xml index 782651c7..ac5ea2ea 100644 --- a/MavenPlugin/pom.xml +++ b/MavenPlugin/pom.xml @@ -26,7 +26,7 @@ org.apache.maven maven-plugin-api - 3.0.3 + 3.3.1 diff --git a/README.md b/README.md index e63100d6..ff2fa27c 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,24 @@ +__BEWARE__: _This project hasn't been maintained in many years. An effort to refresh the BridJ / JNAerator / JavaCL stack is in progress (Nov 2022), with no guarantees_. + +[![Maven Central](https://img.shields.io/maven-central/v/com.nativelibs4java/javacl.svg)]() [![Build Status](https://travis-ci.org/nativelibs4java/JavaCL.svg?branch=feature_travis-build)](https://travis-ci.org/nativelibs4java/JavaCL) [![Join the chat at https://gitter.im/nativelibs4java/JavaCL](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/nativelibs4java/JavaCL?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + [JavaCL](http://javacl.googlecode.com) provides OpenCL bindings for Java. It wraps low-level bindings in a clean object-oriented API, which adds a few goodies. -A comprehensive documentation is available on its [WebSite](javacl.googlecode.com) and [Wiki](https://code.google.com/p/javacl/wiki/FAQ?tm=6). +A comprehensive documentation is available on its [WebSite](http://javacl.googlecode.com) and [Wiki](https://code.google.com/p/javacl/wiki/FAQ?tm=6). It was previously hosted on [ochafik/nativelibs4java](http://github.com/ochafik/nativelibs4java). # Quick links -[![Join the chat at https://gitter.im/ochafik/JavaCL](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ochafik/JavaCL?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - -* [CHANGELOG](https://github.com/ochafik/JavaCL/blob/master/CHANGELOG) +* [CHANGELOG](./CHANGELOG.md) * [FAQ](http://code.google.com/p/javacl/wiki/FAQ) * [JavaDoc](http://nativelibs4java.sourceforge.net/javacl/api/stable/) * [Credits and License](http://code.google.com/p/bridj/wiki/CreditsAndLicense) # Building + ``` - git clone http://github.com/ochafik/JavaCL.git + git clone http://github.com/nativelibs4java/JavaCL.git mvn clean install ``` diff --git a/Tutorials/DFT/pom.xml b/Tutorials/DFT/pom.xml index e7c9c6bd..e1bcaef2 100644 --- a/Tutorials/DFT/pom.xml +++ b/Tutorials/DFT/pom.xml @@ -24,10 +24,6 @@ commons-math 2.2 - - org.scala-lang - scala-library - @@ -36,26 +32,12 @@ com.nativelibs4java maven-javacl-plugin - - net.alchim31.maven - scala-maven-plugin - org.apache.maven.plugins maven-shade-plugin - - - - - net.alchim31.maven - scala-maven-plugin - - - - diff --git a/pom.xml b/pom.xml index 5fa32e52..3954c537 100644 --- a/pom.xml +++ b/pom.xml @@ -12,10 +12,45 @@ com.nativelibs4java nativelibs4java-parent - 1.9 - .. + 1.10-SNAPSHOT - + + + + sonatype + Sonatype OSS Snapshots Repository + http://oss.sonatype.org/content/groups/public + + + + + + sonatype + Sonatype OSS Snapshots Repository + http://oss.sonatype.org/content/groups/public + + + + + + junit + junit + 4.12 + test + + + + + 0.7.1-SNAPSHOT + 0.13-SNAPSHOT + + + + scm:git:git@github.com:nativelibs4java/JavaCL.git + scm:git:git@github.com:nativelibs4java/JavaCL.git + http://github.com/nativelibs4java/JavaCL + + LibCL InteractiveImageDemo @@ -109,7 +144,7 @@ com.nativelibs4java jnaerator - ${jnaerator.version} + ${jnaerator.version}