NATIVEMETHOD(jlong, NativeBase, nativeUseCount)( JNIEnv*, jobject, jlong addrA, jlong addrB ) { TwoAddrs bufA(addrA, addrB); return bufA.as_NativeObjPtr().use_count(); }
NATIVEMETHOD(void, NativeBase, nativeReset)( JNIEnv*, jobject, jlong addrA, jlong addrB ) { TwoAddrs bufA(addrA, addrB); bufA.as_NativeObjPtr().reset(); // The Scala object fields are cleared in the wrapper }
NATIVEMETHOD(void, NativeBase, copyAssign)( JNIEnv* env, jobject thisJ, jobject srcJ ) { if (thisJ == srcJ) return; auto info = get_info(env, __LINE__); TwoAddrs bufA(env, thisJ, info); TwoAddrs bufB(env, srcJ, info); bufA.as_NativeObjPtr() = bufB.as_NativeObjPtr(); bufA.copy_to_scala(env, thisJ, info); }
int main(int, char **) { Halide::Buffer<uint8_t> bufA(NN, NN); Halide::Buffer<uint8_t> output_buf(NN, NN); Halide::Buffer<uint8_t> reference_buf(NN, NN); init_buffer(output_buf, (uint8_t) 177); // Dummy data for (int i = 0; i < NN; i++) { for (int j = 0; j < NN; j++) { bufA(j, i) = i * 10 + j; } } for (int i = 0; i < NN; i++) { for (int j = 0; j < NN; j++) { // Same access pattern as in generator reference_buf((i + j * (NN - 1)) % NN, (i + j * 2) % NN) = bufA((j + 3) % NN, i); } } func(bufA.raw_buffer(), output_buf.raw_buffer()); compare_buffers("test", output_buf, reference_buf); return 0; }