nvcc生成无效错误,编译JNI代码

问题描述 投票:0回答:1
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176

错误是:

MyFile.cu(231): error: expression must have pointer type

相关代码:

JNIEXPORT jboolean JNICALL Java_MyFile_convergeMatrixCuda (
    JNIEnv *env, jclass clazz, jfloatArray fxnMatrixJ, jfloatArray mulMatrixJ, jfloatArray addMatrixJ, 
    jfloatArray resultsJ, jint numRowsJ, jint numColsJ, jint maxIterations, jfloat epsilonJ)
{
    int     numRows = (int) numRowsJ;
    int     numCols = (int) numColsJ;
    int     maxIter = (int) maxIterations;
    float   epsilon = (float) epsilonJ;
    float   *fxnMatrixH = (*env)->GetFloatArrayElements (env, fxnMatrixJ, NULL);

GetFloatArrayElements返回浮点数*。用“ env-> GetFloatArrayElements”替换“(* env)-> GetFloatArrayElements”会得到以下错误:

float   *fxnMatrixH = env->GetFloatArrayElements (env, fxnMatrixJ, NULL);

MyFile.cu(231): error: argument of type "JNIEnv *" is incompatible with parameter of type "jfloatArray"

MyFile.cu(231): error: argument of type "jfloatArray" is incompatible with parameter of type "jboolean *"

MyFile.cu(231): error: too many arguments in function call

nvcc在编译非JNI代码时确实可以正常工作

java-native-interface nvcc
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.