397 Commits

Author SHA1 Message Date
Miao Wang
166b402861 Correctly pass number of input allocations for BLAS
Bug: 31992305

Test: Build and CTS RsBlas test pass on Angler.
Change-Id: If49c0be003d9c2a2175924dc3303703b9ab49357
(cherry picked from commit b742fcc808165fbeeb1a48761e7d629f60207de2)
2016-10-07 19:21:07 +00:00
David Gross
4a4578530a Delete simple reduction implementation.
Bug: 27298560
Change-Id: I8a89c9df753d12ee8af06008d424e77bb916cd8f
2016-06-02 14:47:12 -07:00
Miao Wang
c242fa6b5d [RenderScript] Fix ScriptIntrinsicBlur documentation.
Bug: 28177406
Change-Id: Icccf35857cf29f827a78704e7751c8791cda0d7b
2016-05-18 16:28:55 -07:00
Miao Wang
3231e8e022 Update documentation about copyTo and copyFrom.
Bug: 23159764
Bug: 26862970

  - Add detailed description of AutoPadding
  - Add comments to all the copy related APIs.
  - Fix typos in the comments.

Change-Id: I2d045e0d90efd94f1407f88d3e35bcd42ea93fb9
2016-05-18 16:28:47 -07:00
Yang Ni
1b4df1697f Fixed BaseObj finalizer and destroy()
Bug: 28242626
Bug: 27972184
Bug: 27973681

This is resolving issues in ScriptGroup (V1) again.
In ScriptGroup.destroy(), we also need to consider the old API where
mClosures is not initialized.

Also cleaned up the finalizer for ScriptGroup and Allocation:
Since BaseObj.finalize() calls BaseObj.helpDestroy(), instead of
BaseObj.destroy(), there is no possibility that the finalizers of
child objects may race their parents finalizers. Note that
helpDestroy() does not try to recurse on child objects.

Change-Id: I9dbb2b60f8478f656f8a418c2b5fc8d6848aeef0
2016-04-22 10:21:18 -07:00
Yang Ni
c74d2a8b87 Merge "Made Element accessors thread-safe" into nyc-dev 2016-04-20 16:44:39 +00:00
Yang Ni
33703f0c4e Made Element accessors thread-safe
Bug: 28177082
Change-Id: I8f3f2d8ce559e93cba29f8eedd5b95d1389deb23
2016-04-18 17:25:58 -07:00
Yang Ni
07837d6dab Fixed ScriptGroup finalizer for old API
Bug: 28242626

ScriptGroup finalizer clears out the list of closures, which is
uninitialized for the old API.

Need to check null first, before accessing the list.

Change-Id: Ibf914e17a0878c8c561f823c5f6f6f6619594de1
2016-04-18 14:27:02 -07:00
Yang Ni
0f10f043be Merge "Destroy Type created by Allocation.createSized()" into nyc-dev 2016-04-12 23:37:01 +00:00
Yang Ni
e1798e4284 Destroy Type created by Allocation.createSized()
Bug: 27972184
Change-Id: I4f80c74079087eab20b75a701c56cde141322462
(cherry picked from commit 3444dbe025ad78cae9fd77a4d2203a1a806ae1af)
2016-04-12 15:11:31 -07:00
Yang Ni
44d1b3bfba Destroy Closures in ScriptGroup
Bug: 27973681

Implemented correct destruction in ScriptGroup.destroy() and
Clsoure.destroy(), which properly destroys child BaseObj's.

Change-Id: I946f62c2979d6a338b8883514cacad472a213c5c
(cherry picked from commit 44e2f45f0cab4a429e59f07c1e5bf0eef08c7819)
2016-04-12 09:01:44 -07:00
Yang Ni
4a70df58a3 Avoid destroying Device separately
Bug: 27983025

Device should be destroyed inside the destructor of the associated
Context.

Change-Id: I921a89974e1174f837349a89aef9b03efa4882f5
2016-04-04 10:23:57 -07:00
Yang Ni
0c6ed67c3a Merge "Added CloseGuard for BaseObj" into nyc-dev 2016-04-01 00:33:58 +00:00
Yang Ni
6484b6be5c Added CloseGuard for BaseObj
Bug: 27719830

To turn on warnings, apps have to add to their Activity.onCreate() method
the following code.

        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
                               .detectLeakedClosableObjects()
                               .penaltyLog()
                               .build());

For Slang generated ScriptC derived classes, we assume their
constructors won't throw exceptions after calling the ScriptC
constructor. In addition, ScriptIntrinsic derived classes do not seem
to throw exceptions in their constructors either. Therefore, we can
leave the guard.open() call in the Script constructor. This may be
only an approximation, but allows us to add CloseGuard for script
objects without making changes to slang.

Change-Id: I77ed45239a60b85af5c811dee6c124fb53da9060
(cherry picked from commit eb4dd08ec132f83745b8b28fa7da58eb4478b5b9)
2016-03-31 15:57:23 -07:00
Miao Wang
ab9ab56e3d Merge "[RenderScript] Update documentation for Allocation.setAutoPadding()." into nyc-dev 2016-03-30 00:51:55 +00:00
Miao Wang
9ee7607615 [RenderScript] Update documentation for Allocation.setAutoPadding().
Bug: 26862970
Change-Id: Iaa88ac0266e5d2cac2837f1d13353aacc6177274
2016-03-29 17:42:40 -07:00
Miao Wang
2d92afbef7 Merge "[RenderScript] Fix IntrinsicConvolve documentation." into nyc-dev 2016-03-29 23:55:44 +00:00
Miao Wang
44fa90868c Merge "[RenderScript] Update the documentation of Script.LaunchOptions" into nyc-dev 2016-03-29 23:55:26 +00:00
Miao Wang
3d23dce433 [RenderScript] Fix IntrinsicConvolve documentation.
Bug: 25117120

  - Better format.
  - Typo fixes.

Change-Id: Ic6f8d1dacecdaf9993dd8298de7a801f5fd2a937
2016-03-29 15:29:10 -07:00
Miao Wang
53fdcfbe63 [RenderScript] Update the documentation of Script.LaunchOptions
Bug: 26916665

  - Add description of the endArg.
  - Update the example.
  - Update the incorrect description.

Change-Id: Idd07db5d790e2d6462fff9cb580115ec45cfd4f0
2016-03-29 15:14:21 -07:00
Pirama Arumuga Nainar
3934dadd58 [RenderScript] Fail with Exception from validateObjectIsPrimitiveArray
Bug: http://b/25982676

Instead of returning null from validateObjectIsPrimitiveArray, fail with
an exception.  The callers of this function do not check for null.

Change-Id: Idd2b50a7b137e8d2db7a334bb9a48c1b19ee2403
2016-03-28 12:01:48 -07:00
Yang Ni
15fcf61dc0 Correctly init code cache path for RS
Bug: 27439261

Script Group needs to know the code cache path before it can call bcc to
merge kernels. However, before this change, the code cache path has been
initialized by the ScriptC class.

In the case where a script group (or even the entire app) does not contain any
regular script but only intrinsics, the code cache would remain uninitialized.

Fixed this by initializing the code cache path in the RenderScript class
the first time when the accessor method is called.

Change-Id: I87f9e62e0f3b479f94e43daa3e9695a5b38710db
(cherry picked from commit 689f63770048589e1001ce99faf1d2eaf9780a80)
2016-03-21 16:53:22 -07:00
Yang Ni
2b551f4c42 Use proper ScriptCall size in nScriptForEach()
Bug: 26498479

Although the size of struct ScriptCall is not used underneath in the
runtime or drivers, assign the correct value here to avoid confusion.

Change-Id: I8db19538b9f70f3bf9ee849a8724da3d9ee04785
(cherry picked from commit e8f2e445fdb138416043a16659bbf86fbbd3fff8)
2016-03-16 08:20:07 -07:00
Yang Ni
267fc8b361 Merge "Revert "Set flags in RS JNI calls for rsObj creation"" into nyc-dev 2016-03-08 21:00:54 +00:00
Yang Ni
3f3965ec13 Revert "Set flags in RS JNI calls for rsObj creation"
This reverts commit 972a409a3df6f105aa99a3d721e37111c70ef44c.

Change-Id: Icdac5cebf9944e7b237c91db05e5a7f47b6b67e8
2016-03-08 20:59:48 +00:00
Pirama Arumuga Nainar
a2dde698a6 Merge "[RenderScript] Enable untyped variants of Allocation-copy functions for FLOAT_16" into nyc-dev 2016-03-03 20:13:09 +00:00
Pirama Arumuga Nainar
a74efc96ea Merge "[RenderScript] Allow copyTo(short[]) etc for Float16 Allocations" into nyc-dev 2016-03-03 20:12:51 +00:00
Yang Ni
972a409a3d Set flags in RS JNI calls for rsObj creation
Bug: 25570907

Added a flag to all RS runtime API for rsObj creation to indicate a
call is from Java. This flag will help us avoid incrementing the user
ref count for rsObj's created from Single-Source RS, and therefore
avoid memory leaks for such objects.

Change-Id: Id3604f93b166089e3aca896d1c6c509b3ea19bcf
(cherry picked from commit ad88055821a7aba3318f066c4e5f87bd0315462c)
2016-03-03 08:47:33 -08:00
Pirama Arumuga Nainar
85e8c51dbf [RenderScript] Enable untyped variants of Allocation-copy functions for FLOAT_16
http://b/27251511

Handle FLOAT_16 case to PER_ARRAY_TYPE macro to enable untyped variants
of Allocation-copy functions.

Untyped variants of Allocation-copy functions call
validateObjectIsPrimitiveArray(), with checkType parameter set to true,
to validate and obtain the Element type of the Allocation.  When
checkType is true, validateObjectIsPrimitiveArray() returns the actual
Element type of the Allocation (instead of the canonical SIGNED type).
Because of this, FLOAT_16 element type can reach the JNI layer,
necessitating this change to PER_ARRAY_TYPE macro.

Change-Id: I3651e5ae0ab0cd6bb4ad3157841e2910ac8699dc
2016-03-02 18:16:45 -08:00
Pirama Arumuga Nainar
f51bb356de [RenderScript] Allow copyTo(short[]) etc for Float16 Allocations
http://b/27251511

Allow copyTo(short[]), copyFrom(short[]), and their 1D range and 2D
range variants to copy data between short[] arrays and Float16
Allocations.

Change-Id: I370584685c3b773c165bd718974ca736ed548339
2016-03-01 17:25:11 -08:00
Miao Wang
f94e77da7e [RenderScript] Fix potential leak in RS JNI
Bug: 27145639
Change-Id: I80cf2971d803a3366a63caa3612a503a88639040
(cherry picked from commit a4ad5f840173ecbfb679153a4f9460d2b06538e7)
2016-02-17 11:01:51 -08:00
Stephen Hines
0ff759ccae Merge "Remove the CREATE_FLAG_OPT_LEVEL_0 from the Java API." am: 49aee686d8
am: c033f493f2

* commit 'c033f493f23574dc69bf8ecd0f04af8910b4a47e':
  Remove the CREATE_FLAG_OPT_LEVEL_0 from the Java API.
2016-01-30 17:57:30 +00:00
Stephen Hines
49aee686d8 Merge "Remove the CREATE_FLAG_OPT_LEVEL_0 from the Java API." 2016-01-30 17:44:52 +00:00
Miao Wang
c29bcd0dcd [RenderScript] Unhide new Allocation APIs
Bug: 23535524

  - ByteBuffer getByteBuffer()
  - long getStride()
  - Allocation[] createAllocations(rs, type, usage, num)
  - long getTimeStamp()

Change-Id: I0cad88c81f9f48c7aca59af159c49f506b234aee
2016-01-27 14:42:03 -08:00
Miao Wang
a1c7bc7550 Merge "[RenderScript] Implement APIs for better multi-frame process support." am: 6ebdbfa549
am: d90b4a3266

* commit 'd90b4a3266ab2af3cbc6f131a0ed320f7a795a09':
  [RenderScript] Implement APIs for better multi-frame process support.
2016-01-27 22:02:17 +00:00
Miao Wang
8c1509249c [RenderScript] Implement APIs for better multi-frame process support.
Bug: 23535524

 Two APIs added for multiframe processing:
 - createAllocations(...): To create an array of Allocations sharing the
   same Type and Usage. For USAGE_IO_INPUT Allocations, they also share
   the same BufferQueue.
 - getTimeStamp(): API to retrieve the time stamp associated with the
   most recent buffer.

Change-Id: I6b7b35d7dca5e87ee2f3db2ee17cb9cf824bcfe1
2016-01-26 14:40:44 -08:00
Miao Wang
a11c28589e Merge "[RenderScript] Add API to map Allocation mallocptr to Java ByteBuffer" am: ed50f333fb
am: 5f210ae042

* commit '5f210ae04239f4a374763ea9ffe7176f5455017a':
  [RenderScript] Add API to map Allocation mallocptr to Java ByteBuffer
2016-01-26 01:27:30 +00:00
Miao Wang
ed50f333fb Merge "[RenderScript] Add API to map Allocation mallocptr to Java ByteBuffer" 2016-01-26 01:11:41 +00:00
Miao Wang
0facf021ea [RenderScript] Add API to map Allocation mallocptr to Java ByteBuffer
Bug: 25926361
Bug: 23535524

  - Construct the ByteBuffer using the AllocationGetPointer.
  - Add an API to query the stride of the allocation.
  - Both ByteBuffer and Stride will be cached for normal Allocations.
    if using USAGE_IO, since after each ioReceive, the mallocPtr will
    change, getByteBuffer will always create a new one using the most
    up-to-date mallocPtr.

Change-Id: I5e84b6690e83bb062c383043275524d0e51e46eb
2016-01-25 16:12:37 -08:00
David Gross
ba038689b1 Unhide Script::reduce() interface for general reduction.
Bug: 23535724

Change-Id: I7a43622954de9f4168f7e4376f39d6ec54191c03
2016-01-25 12:17:29 -08:00
David Gross
26ef7a739b Add general reduction plumbing starting with Java Script::reduce().
Requires coordinated change in frameworks/rs.

Bug: 23535724
Change-Id: I2fee6750cf542948d8fa87a98441002c4d84f36e
2016-01-15 12:20:08 -08:00
Yang Ni
263cc90345 Various fixes in setting globals in a script group
Bug: 25602504

1) Passing floating point values into a script group was broken,
since they were casted to long values. Fixed that in the frameworks
implementation by taking the raw bits instead.

2) Passing 64-bit values into a script group was broken on 32-bit
platforms, since they were casted to pointer-sized integers
(uintptr_t) in the JNI code. Fixed that by casting to int64_t
instead.

3) Setting global variables of Allocation type in a script group was
broken. The special size value -1 was used to indicate the value is an
Allocation. However, size was casted to size_t in the JNI code.
Fixed that by using signed integers.

Change-Id: Ifff099a76be7707df7b67c388395f5a00f9cae66
2015-11-13 10:00:12 -08:00
Miao Wang
ba8766c5db [RenderScript] Add null check for return values of JNI
Get<TYPE>ArrayElements.

Bug: 20760800
Change-Id: I6ba56933a71721da88d31dbf74c48d42a924305a
2015-10-13 10:44:38 -07:00
Pirama Arumuga Nainar
115b4117a0 Fix punctuation and typos in AllocationAdapter's documentation.
Change-Id: I5574ff201b857a29f30ebe8413dbe4128dcff3ae
2015-10-08 19:51:11 +00:00
Pirama Arumuga Nainar
c9390c8baf am 46b51097: Merge "Safely handle interrupts during Thread.join()"
* commit '46b51097b92900866ac5b25762f622d3ceb1be5d':
  Safely handle interrupts during Thread.join()
2015-10-05 23:33:38 +00:00
Pirama Arumuga Nainar
83461d73bc Safely handle interrupts during Thread.join()
Interrupt current thread if InterruptedException is received during
Thread.join().  Also, log the interruption.

Change-Id: I452124915ea3f19610e6d4a3411d741f2f604af2
2015-10-05 15:45:47 -07:00
Pirama Arumuga Nainar
5fbb245230 am ca3e5aea: Merge "Retry if interrupted before mMessageThread has joined"
* commit 'ca3e5aeaa65ae1d77ce92f082ab789933eb18237':
  Retry if interrupted before mMessageThread has joined
2015-10-02 22:08:11 +00:00
Pirama Arumuga Nainar
2f25ce7753 Retry if interrupted before mMessageThread has joined
Bug: 24342101

If interrupted during mMessageThread.join(), retry the join instead of
assuming the thread has joined and continuing.  Continuing to destroy
the context will cause a segfault when the message thread attempts to
use the destroyed context.

Change-Id: I3213091a0e996449bceb403dffca3063786d5a65
2015-10-02 21:42:12 +00:00
Miao Wang
05420e77f5 am 134c504a: Merge "[RenderScript] pass correct length of ains to BLAS functions"
* commit '134c504a3ea687a0ea875057792e66705ddbfce7':
  [RenderScript] pass correct length of ains to BLAS functions
2015-09-30 23:44:22 +00:00
Miao Wang
134c504a3e Merge "[RenderScript] pass correct length of ains to BLAS functions" 2015-09-30 22:53:18 +00:00