303 Commits

Author SHA1 Message Date
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
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
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
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
Stephen McGroarty
88891e63c0 Remove the CREATE_FLAG_OPT_LEVEL_0 from the Java API.
The flag was previously used to set the optimization level
of the bcc compiler to -O0. However, this functionality is
now accomplished through deriving the optimization level
from the input bitcode. That patch can be found here:
https://android-review.googlesource.com/169330

Change-Id: I9c57d941bb35c6f737a31fcd74f31d9de25a16a8
Signed-off-by: Stephen McGroarty <stephen@codeplay.com>
2015-09-02 16:11:28 +01:00
Stephen Hines
b3a1674a47 am ed3ffe0f: am 6430812a: Merge "RenderScript: implement a Script entry point for calling a reduce-style kernel."
* commit 'ed3ffe0fc86de016ff2b4231e2fcc74a6119f6c7':
  RenderScript: implement a Script entry point for calling a reduce-style kernel.
2015-07-23 22:54:59 +00:00
Stephen Hines
6430812a93 Merge "RenderScript: implement a Script entry point for calling a reduce-style kernel." 2015-07-23 22:26:05 +00:00
Matt Wala
36eb1f74b3 RenderScript: implement a Script entry point for calling a
reduce-style kernel.

Bug: 22631253

This adds a new (currently hidden) API to the Script class and the
corresponding code for the RenderScript JNI layer.

Change-Id: I40f19aaeb90411b859bd6b0bffc3f071fa327c21
2015-07-21 11:07:10 -07:00
Miao Wang
3fd9bf4e24 am 15d68941: Merge "[RenderScript] Add docs advising users about dstAtop bug." into mnc-dev
* commit '15d6894170f2ee1a6eae57c915fcc27a56c9de17':
  [RenderScript] Add docs advising users about dstAtop bug.
2015-07-20 23:52:46 +00:00
Miao Wang
37e1d0ce1e [RenderScript] Add docs advising users about dstAtop bug.
Bug: 22047392
Change-Id: I736a697276020687c20dff515aabb1be1776f8c0
(cherry picked from commit ffb1a9bed0788d3547f085bfb9d254004e0db1e3)
2015-07-20 16:44:14 -07:00
Miao Wang
ffb1a9bed0 [RenderScript] Add docs advising users about dstAtop bug.
Bug: 22047392
Change-Id: I736a697276020687c20dff515aabb1be1776f8c0
2015-07-20 16:04:59 -07:00
Stephen Hines
dd67c9d6a8 am 0f5b7bc2: am 79a1bde2: Merge "Add a flag to the API to specify -O0 on the bcc command line."
* commit '0f5b7bc2fe2ae554ab1f044eb5b10aab5f4812cb':
  Add a flag to the API to specify -O0 on the bcc command line.
2015-07-17 23:14:36 +00:00
Stephen Hines
79a1bde2e0 Merge "Add a flag to the API to specify -O0 on the bcc command line." 2015-07-17 22:45:16 +00:00
verena beckham
c9659ea3a2 Add a flag to the API to specify -O0 on the bcc command line.
Add a flag CREATE_FLAG_OPT_LEVEL_0 to set the optimization level to 0 when calling bcc.
This will result in an object file that is easier to debug.

Change-Id: I0384dca098fa0d9ae0f2e02e798da9de342c1122
Signed-off-by: verena beckham <verena@codeplay.com>
2015-07-16 19:45:09 -07:00
Miao Wang
3ef2041cee fix BNNM docs
bug: 22507076
Change-Id: I5fdffdde597d97b1dde77574d096b81bff4aa382
(cherry picked from commit d7d413ad0bfaea2d4bb4adcd8011239c2f5f74ae)
2015-07-16 10:28:35 -07:00
Miao Wang
9ee3b6f136 am ad904cf3: Merge "fix BNNM docs" into mnc-dev
* commit 'ad904cf34219897da731eb65f9de53176cc39b20':
  fix BNNM docs
2015-07-15 22:33:14 +00:00
Miao Wang
d7d413ad0b fix BNNM docs
bug: 22507076
Change-Id: I5fdffdde597d97b1dde77574d096b81bff4aa382
2015-07-15 11:35:28 -07:00
Miao Wang
c02720316d resolved conflicts for merge of a1867fb0 to mnc-dev-plus-aosp
Change-Id: Id0266c63c98b4cb37f49eb2e0fb9a98cbc7ee1de
2015-06-30 23:35:23 -07:00
Miao Wang
2514806817 [RenderScript] update the type of offsets for BLAS.BNNM
bug: 22184114

Change-Id: I7e7132aa3563f32de32640567b381f8f5bddf491
(cherry picked from commit 6099ee6e081904e73e0fad331e326b0607b6b1dc)
2015-06-30 22:29:47 -07:00