我希望工作大约4000个固定大小(3x3,4x4)矩阵,做矩阵求逆和特征分解等事情.
在我看来,并行化这种方法的最佳方法是让许多GPU线程中的每一个都在单个问题实例上工作.
有合理的方法吗?我已经阅读:http://www.culatools.com/blog/2011/12/09/batched-operations/但据我所知,它始终是"正在处理"的东西,没有解决方案.三年后,我希望有一个很好的解决方案.
到目前为止,我看过:
Eigen::MatrixXf
并不能用nvcc V7.0.27
Eigen 3.2.90(mercurial)编译.在这一点上,我很想放弃在GPU上做这件事.遗憾的是,因为我希望算法的实时性能要求每0.1秒反转4000个3x3矩阵大约100次.
我想写它使用许多参数,我将调用一个函数a
,b
和c
.我有四种在C++ 14中实现它的选择.
对于2018年的新现代C++项目,其中一种风格最符合ISO C++的理念?其他风格指南推荐哪些款式?
class Computer {
int a, b, c;
public:
Computer(int a, int b, int c) : a(a), b(b), c(c) {}
int compute(int) const {
// do something with a, b, c
}
};
...
const Computer computer(a, b, c);
int result = computer.compute(123);
Run Code Online (Sandbox Code Playgroud)
[computer](int input){ return computer.compute(input); }
struct ComputeParams {
int a, b, c;
};
int compute(const ComputeParams ¶ms, int input) { …
Run Code Online (Sandbox Code Playgroud) 我想读取由 tcpdump 生成的 pcap 文件,该文件包含经过IPV4 分片的大型 UDP 数据包。原始数据包的大小约为 22000 字节。
在 C++ 中,我会使用 libtins 和它的 IPV4Reassembler。有没有办法在 Rust 中做类似的事情?
目前在 Rust 中,这是我到目前为止所写的内容:高度不完整的第一次尝试(使用 crate pnet
):
use pnet::packet::{
ethernet::{EtherTypes, EthernetPacket},
ip::IpNextHeaderProtocols,
ipv4::Ipv4Packet,
udp::UdpPacket,
Packet,
};
struct Ipv4Reassembler {
cap: pcap::Capture<pcap::Offline>,
}
impl Iterator for Ipv4Reassembler {
type Item = Vec<u8>;
fn next(&mut self) -> Option<Self::Item> {
let mut payload = Vec::<u8>::new();
while let Some(packet) = self.cap.next().ok() {
// todo: handle packets other than Ethernet packets
let ethernet = EthernetPacket::new(packet.data).unwrap();
match …
Run Code Online (Sandbox Code Playgroud)