2025年CUSP库使用实践

CUSP库使用实践CUSP Library 使用实践 CUSP 最新版本 0 6 项目已经停止开发多年 比较老旧 在新版本 CUDA 下编译使用 CUSP 会有一些小错误 主要是头文件缺失或是缺少引用错误 环境 环境 说明 备注 win10 Windows 10 家庭中文版 cl exe 19 31 31107 VS 2022 cuda 11 6 thrust

大家好,我是讯享网,很高兴认识大家。

CUSP Library 使用实践

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 <thrust/detail/config/compiler_fence.h>

示例程序
#include <thrust/version.h> #include <cusp/version.h> #include <iostream> //compile: nvcc -O3 -I ..\..\github.dir\cusplibrary\ 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"<<thrust_major<<"."<<thrust_minor<<std::endl; std::cout<<"CUSP v"<<cusp_major<<"."<<cusp_minor<<std::endl; return; } #include <cusp/csr_matrix.h> #include <cusp/hyb_matrix.h> void test_sparse() { 
    cusp::csr_matrix<int,float,cusp::host_memory> csr_host(5,8,12); cusp::csr_matrix<int,float,cusp::device_memory> csr_device(csr_host); cusp::hyb_matrix<int,float,cusp::device_memory> hyb_device(csr_device); } #include<cusp/monitor.h> #include<cusp/gallery/poisson.h> #include<cusp/krylov/cg.h> #include <cusp/precond/aggregation/smoothed_aggregation.h> void test_cg() { 
    typedef int IndexType; typedef cusp::device_memory MemorySpace; typedef float ValueType; static const int ROWS=1000; #if 0  cusp::hyb_matrix<IndexType,ValueType,MemorySpace> A; #else  cusp::coo_matrix<IndexType, ValueType, MemorySpace> A; #endif cusp::gallery::poisson5pt(A,ROWS,ROWS); cusp::array1d<ValueType,MemorySpace> x(A.num_rows,0); cusp::array1d<ValueType,MemorySpace> b(A.num_rows,1); cusp::monitor<ValueType> monitor(b,1000,1e-8,0,true); #if 0 cusp::identity_operator<ValueType,MemorySpace>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<IndexType, ValueType, MemorySpace> 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); } 

讯享网
资料
  • 快速入手
小讯
上一篇 2025-02-07 20:36
下一篇 2025-01-17 09:28

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/33627.html