栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

CUSP库使用实践

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

CUSP库使用实践

CUSP Library 使用实践

CUSP最新版本0.6,项目已经停止开发多年,比较老旧,在新版本CUDA下编译使用CUSP会有一些小错误,主要是头文件缺失或是缺少引用错误。


环境
环境说明备注
win10Windows 10 家庭中文版
cl.exe19.31.31107VS 2022
cuda11.6
thrust1.15
cusp0.6
GPUGeForce MX350计算能力6.1
IDEVS 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_operatorM(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);
}

资料
  • 快速入手
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/938425.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号