text
stringlengths 0
2.2M
|
---|
constexpr size_t kNumEntries = 2;
|
constexpr size_t kBufSize = 4096;
|
auto ioUring = getAIO<IoUring>(kNumEntries, folly::AsyncBase::NOT_POLLABLE);
|
SKIP_IF(!ioUring) << "IOUring not available";
|
auto tempFile = folly::test::TempFileUtil::getTempFile(kDefaultFileSize);
|
int fd = ::open(tempFile.path().c_str(), O_DIRECT | O_RDWR);
|
SKIP_IF(fd == -1) << "Tempfile can't be opened with O_DIRECT: "
|
<< folly::errnoStr(errno);
|
SCOPE_EXIT { ::close(fd); };
|
folly::test::async_base_test_lib_detail::TestUtil::ManagedBuffer
|
regFdWriteBuf =
|
folly::test::async_base_test_lib_detail::TestUtil::allocateAligned(
|
kBufSize),
|
readBuf =
|
folly::test::async_base_test_lib_detail::TestUtil::allocateAligned(
|
kBufSize),
|
regFdReadBuf =
|
folly::test::async_base_test_lib_detail::TestUtil::allocateAligned(
|
kBufSize);
|
::memset(regFdWriteBuf.get(), '0', kBufSize);
|
::memset(readBuf.get(), 'A', kBufSize);
|
::memset(regFdReadBuf.get(), 'Z', kBufSize);
|
struct iovec iov[2];
|
iov[0].iov_base = regFdWriteBuf.get();
|
iov[0].iov_len = kBufSize;
|
iov[1].iov_base = regFdReadBuf.get();
|
iov[1].iov_len = kBufSize;
|
CHECK_EQ(ioUring->register_buffers(iov, 2), 0);
|
IoUring::Op regFdWriteOp, readOp, regFdReadOp;
|
size_t completed = 0;
|
regFdWriteOp.setNotificationCallback(
|
[&](folly::AsyncBaseOp*) { ++completed; });
|
regFdWriteOp.pwrite(fd, regFdWriteBuf.get(), kBufSize, 0, 0 /*buf_index*/);
|
readOp.setNotificationCallback([&](folly::AsyncBaseOp*) { ++completed; });
|
readOp.pread(fd, readBuf.get(), kBufSize, 0);
|
regFdReadOp.setNotificationCallback(
|
[&](folly::AsyncBaseOp*) { ++completed; });
|
regFdReadOp.pread(fd, regFdReadBuf.get(), kBufSize, 0, 1 /*buf_index*/);
|
// write
|
ioUring->submit(®FdWriteOp);
|
ioUring->wait(1);
|
CHECK_EQ(completed, 1);
|
CHECK_EQ(regFdWriteOp.result(), kBufSize);
|
// read - both via regular and registered buffers
|
completed = 0;
|
ioUring->submit(&readOp);
|
ioUring->submit(®FdReadOp);
|
ioUring->wait(kNumEntries);
|
CHECK_EQ(completed, kNumEntries);
|
CHECK_EQ(readOp.result(), kBufSize);
|
CHECK_EQ(regFdReadOp.result(), kBufSize);
|
// make sure we read the same data
|
CHECK_EQ(::memcmp(readBuf.get(), regFdWriteBuf.get(), kBufSize), 0);
|
CHECK_EQ(::memcmp(regFdReadBuf.get(), regFdWriteBuf.get(), kBufSize), 0);
|
}
|
} // namespace async_base_test_lib_detail
|
} // namespace test
|
} // namespace folly
|
#include <ATen/Utils.h>
|
#include <torch/csrc/jit/ir/constants.h>
|
#include <torch/csrc/jit/ir/ir.h>
|
#include <torch/csrc/jit/ir/subgraph_matcher.h>
|
#include <torch/csrc/jit/passes/frozen_conv_add_relu_fusion.h>
|
#include <torch/csrc/jit/passes/graph_rewrite_helper.h>
|
#include <torch/csrc/jit/passes/remove_mutation.h>
|
#include <torch/csrc/jit/passes/subgraph_rewrite.h>
|
#ifdef USE_CUDA
|
#include <ATen/cuda/CUDAConfig.h>
|
#endif
|
namespace torch {
|
namespace jit {
|
std::function<void(std::shared_ptr<Graph>&)>& getFuseFrozenConvAddReluImpl() {
|
static std::function<void(std::shared_ptr<Graph>&)> impl;
|
return impl;
|
}
|
// Implementation is in frozen_conv_add_relu_fusion.cpp; at runtime the
|
// implementation is registered in _fuseFrozenConvAddReluImpl. This allows
|
// the GPU code to be built separately from CPU-only code. If you're
|
// expecting conv-add-relu fusion to occur but it's not happening, it's
|
// possible that the GPU code isn't being built or linked properly.
|
Subsets and Splits