简体   繁体   English

在Android中执行2个大浮点数组相加的快速方法。 可选的JNI或Opengl ES

[英]Fast way to perform addition of 2 LARGE float arrays in Android. Optional JNI or Opengl ES

I simply need to add floatArray1 to floatArray2 storing the result in floatArray2.. no third array.. all arrays are one dimensional but are very large... probibly as large as the os will let me get away with. 我只需要将floatArray1添加到floatArray2中即可将结果存储在floatArray2中。.没有第三个数组..所有数组都是一维的,但非常大...可能与os一样大,这让我无法理解。 Max i would need is two float arrays with 40,000 floats each... but i could get away with 1/10th that i suppose minimum. 我需要的最大是两个浮点数数组,每个浮点数数组分别为40,000个浮点数...但是我可以逃脱我假设的最小值的1/10。

Would love to do this in 1/30th or 1/60th of a second but that does not seem possible? 是否愿意在1/30或1/60秒内执行此操作,但这似乎不可能? Also if the code is JNI,NDK or OpenGL ES thats fine.. does android have an assembly language or like machine code i could use somehow? 另外,如果代码是JNI,NDK或OpenGL ES,那就很好.. android是否具有汇编语言或类似的机器代码,我可以使用某种方式?

Since a float is worth 32 bit and you have 40000 floats in each array you would need: 由于浮点数值得32位,并且每个数组中有40000个浮点数,因此需要:

40000 * 32 * 2 = 2.560.000 bit 40000 * 32 * 2 = 2.560.000位

Which is 320.000 Byte. 这是320.000字节。 Not to much memory wise i would say since the default limit for an android app is 16MB. 我不会说太多的内存,因为android应用程序的默认限制是16MB。

Regarding performance you would definitely gain some speed using JNI. 关于性能,使用JNI绝对可以提高速度。 OpenGL would not give you enough benefit i would think since the OpenGL context creation takes some time as well. OpenGL不会给您带来足够的好处,因为OpenGL上下文创建也需要一些时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM