CUSP最新版本0.6,项目已经停止开发多年,比较老旧,在新版本CUDA下编译使用CUSP会有一些小错误,主要是头文件缺失或是缺少引用错误。
环境
| 环境 | 说明 | 备注 |
|---|---|---|
| win10 | Windows 10 家庭中文版 | |
| cl.exe | 19.31.31107 | VS 2022 |
| cuda | 11.6 | |
| thrust | 1.15 | |
| cusp | 0.6 | |
| GPU | GeForce MX350 | 计算能力6.1 |
| IDE | VS Code | 运行: 启动菜单->Visual Studio 2022->x64 Native Tools Command Prompt for VS 2022, 打开cmd终端,在cmd里启动code, 所有vs 2022环境已经在code里配置OK |
碰到错误及修正
| 错误 | 解决办法 | 备注 |
|---|---|---|
| cusp/system/cuda/detail/runtime_introspection.inl(19): fatal error C1083: 无法打开包括文件: “thrust/detail/util/blocking.h” | 在thrust历史项目中查找到blocking.h,拷贝到具体位置即可 | blocking.h在thrust新版本中被剔除了 |
| cusp/system/cuda/detail/runtime_introspection.inl(90) error: identifier “__thrust_compiler_fence” is undefined | 在cusp/system/cuda/detail/runtime_introspection.inl文件中包含#include |
示例程序
#include#include #include //compile: nvcc -O3 -I ....github.dircusplibrary cuda_ex4.cu //nvprof .a.exe void print_version() { int thrust_major=THRUST_MAJOR_VERSION; int thrust_minor=THRUST_MINOR_VERSION; int cusp_major=CUSP_MAJOR_VERSION; int cusp_minor=CUSP_MINOR_VERSION; std::cout<<"Thrust v"< #include void test_sparse() { cusp::csr_matrix csr_host(5,8,12); cusp::csr_matrix csr_device(csr_host); cusp::hyb_matrix hyb_device(csr_device); } #include #include #include #include void test_cg() { typedef int IndexType; typedef cusp::device_memory MemorySpace; typedef float ValueType; static const int ROWS=1000; #if 0 cusp::hyb_matrix A; #else cusp::coo_matrix A; #endif cusp::gallery::poisson5pt(A,ROWS,ROWS); cusp::array1d x(A.num_rows,0); cusp::array1d b(A.num_rows,1); cusp::monitor monitor(b,1000,1e-8,0,true); #if 0 cusp::identity_operator M(A.num_rows,A.num_rows); cusp::krylov::cg(A,x,b,monitor,M); monitor.print(); #else // setup preconditioner cusp::precond::aggregation::smoothed_aggregation M(A); // solve cusp::krylov::cg(A, x, b, monitor, M); // report status monitor.print(); // print hierarchy information std::cout << "nPreconditioner statistics" << std::endl; M.print(); #endif } int main(int argc, char **argv) { print_version(); test_sparse(); //test_cg(); return(0); }
资料
- 快速入手



