小编Evg*_*niy的帖子

MSVC2015更新3可变参数模板解决方法

Visual Studio 2015更新3改进了对C++ 11的支持,但我有一个奇怪的问题,我正在寻找解决方法.

当使用MSVC为模板类型参数("完全定义的类型")编译可变参数模板代码时,一切都很好,但是如果我想使用模板模板参数("部分定义的类型"),则结果变得不正确.

#include <iostream>
using namespace std;

template <template<typename> class... TS>
struct PARTIAL {
    static void test(std::ostream& out)
    {
        out << "PARTIAL-PROBLEM" << endl;
    }
};
template <template<typename> class T>
struct PARTIAL<T>{
    static void test(std::ostream& out)
    {out << "PARTIAL-OK-END" << endl;}
};
template <template<typename> class T, template<typename> class... TS>
struct PARTIAL<T, TS...>{
    static void test(std::ostream& out)
    {
        out << "PARTIAL-OK" << endl;
        PARTIAL<TS...>::test(out);
    }
};

template <class... TS>
struct FULL {
    static void test(std::ostream& out)
    {
        out …
Run Code Online (Sandbox Code Playgroud)

c++ visual-c++ variadic-templates c++11

7
推荐指数
1
解决办法
314
查看次数

Halide CUDA GPU SGEMM 实现

我正在尝试构建基于 Halide 的图像处理算法,该算法在其中一个阶段需要 SGEMM 函数。

我发现 Halide 有两种矩阵乘法实现:

  1. 线性代数算法(apps/linear_algebra 文件夹
  2. CUDA 矩阵乘法应用程序(apps/cuda_mat_mul 文件夹

对于大小为 1024x1024 的矩阵:

首先,它们在 CPU (Intel i7) 和 Fermi GPU (GF 540M) 上运行得很好,CPU 时间接近 OpenBlas,Fermi GPU 时间接近 cuBlas(约 18ms),但此实现在 Maxwell 上比 cuBlas 慢 10 倍GPU (TitanX) - 5 毫秒与 0.4 毫秒。第二个实现 (cuda_mat_mul) 比 Fermi 上的 cuBlas 慢 3 倍 - 大约 57 毫秒 vs 18 毫秒,在 Maxwell GPU 上比 cuBlas 慢 2 倍 - 1 毫秒 vs 0.4 毫秒

正如我所见 - Halide 可以为 …

halide

5
推荐指数
0
解决办法
991
查看次数

标签 统计

c++ ×1

c++11 ×1

halide ×1

variadic-templates ×1

visual-c++ ×1