静态推力定制分配器? [英] Static Thrust Custom Allocator?

查看:170
本文介绍了静态推力定制分配器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只有几个事实可以设置:

Just a couple facts for setup:


  • Thrust不会对其所有操作进行操作。

  • 您可以向 thrust :: device_vectors 提供自定义分配器。

  • Thrust doesn't operate in-place for all of it's operations.
  • You can supply custom allocators to thrust::device_vectors.

我看过 thrust :: system thrust :: system :: cuda 并没有找到任何看起来像一个静态系统分配器。我的意思是,我看不到一种方法来替换分配器,推力使用内部分配额外的内存为out-of-place算法。

I've looked in thrust::system and thrust::system::cuda and haven't found anything that looks like a static system allocator. By that I mean, I can't see a way of replacing the allocator that thrust uses internally to allocate extra memory for the out-of-place algorithms.

我也很难相信那些未就位的函数使用给定的 thrust :: device_vectors 到分配器工作内存。

I also find it hard to believe that the functions that are not in-place use the allocators for the given thrust::device_vectors to allocator working memory.

问题: thrust 有一种方法替换内部分配器用户定义了一个?

Question: Does thrust have a way of replacing the internal allocator with a user defined one?

相关问题:

意味着推力操作不在位置

自定义推力示例 allocator

推荐答案

Thrust的 custom_temporary_allocation 示例演示如何构建自己的自定义分配器用于Thrust算法内部使用的临时存储。示例使用缓存方案来执行分配,但原则上您可以使用任何您喜欢的策略。

Thrust's custom_temporary_allocation example demonstrates how to build your own custom allocator for the temporary storage used internally by Thrust algorithms. The example uses a caching scheme to perform allocation but in principle you could use any strategy you like.

基本上,这个想法是构建一个从CUDA后端派生的自定义后端特别是为了定制分配的目的。然后,当您想要使用自定义分配器的算法时,在调用算法时将Thrust指向您的自定义后端。

Basically, the idea is to build a custom backend derived from the CUDA backend specifically for the purpose of customizing allocation. Then, when you'd like to use an algorithm with your custom allocator, you point Thrust at your custom backend when you call the algorithm.

请注意,此功能需要Thrust 1.6或更好。

Note that this feature requires Thrust 1.6 or better.

这篇关于静态推力定制分配器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆