-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* INSTALL * make ttl::range less generic * ttl::copy * --with-cuda * add .size() and .dims() to tensor types (#79) * add size method to tensor * dims() * deprecate from_host, to_host (#80) * support customize install prefix
- Loading branch information
Showing
13 changed files
with
150 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
if [ -z $PREFIX ]; then | ||
PREFIX=$HOME/local | ||
fi | ||
|
||
./configure --prefix=$PREFIX | ||
|
||
make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
#include <ttl/bits/std_cuda_allocator.hpp> | ||
#include <ttl/bits/std_tensor.hpp> | ||
|
||
namespace ttl | ||
{ | ||
namespace internal | ||
{ | ||
namespace experimental | ||
{ | ||
template <typename R, typename S> | ||
void copy(const basic_tensor<R, S, host_memory, readwrite> &dst, | ||
const basic_tensor<R, S, cuda_memory, readonly> &src) | ||
{ | ||
using copier = internal::cuda_copier; | ||
copier::copy<copier::d2h>(dst.data(), src.data(), src.data_size()); | ||
} | ||
|
||
template <typename R, typename S> | ||
void copy(const basic_tensor<R, S, cuda_memory, readwrite> &dst, | ||
const basic_tensor<R, S, host_memory, readonly> &src) | ||
{ | ||
using copier = internal::cuda_copier; | ||
copier::copy<copier::h2d>(dst.data(), src.data(), src.data_size()); | ||
} | ||
} // namespace experimental | ||
} // namespace internal | ||
} // namespace ttl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// # -*- mode: c++ -*- | ||
#pragma once | ||
#include <ttl/bits/std_copy.hpp> | ||
|
||
namespace ttl | ||
{ | ||
using internal::experimental::copy; | ||
} // namespace ttl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "testing.hpp" | ||
|
||
#include <ttl/algorithm> | ||
#include <ttl/cuda_tensor> | ||
#include <ttl/device> | ||
#include <ttl/experimental/copy> | ||
#include <ttl/range> | ||
#include <ttl/tensor> | ||
|
||
void test_copy(int n) | ||
{ | ||
ttl::tensor<int, 1> x_host(n); | ||
ttl::cuda_tensor<int, 1> x_cuda(n); | ||
|
||
ttl::fill(ttl::ref(x_host), 1); | ||
ttl::copy(ttl::ref(x_cuda), ttl::view(x_host)); | ||
|
||
ttl::fill(ttl::ref(x_host), 2); | ||
for (auto i : ttl::range<0>(x_host)) { ASSERT_EQ(x_host.data()[i], 2); } | ||
|
||
ttl::copy(ttl::ref(x_host), ttl::view(x_cuda)); | ||
for (auto i : ttl::range<0>(x_host)) { ASSERT_EQ(x_host.data()[i], 1); } | ||
} | ||
|
||
TEST(copy_test, test_copy) | ||
{ | ||
test_copy(1); | ||
test_copy(2); | ||
test_copy(10); | ||
test_copy(100); | ||
test_copy(1000); | ||
test_copy(1 << 20); | ||
test_copy(1 << 20); | ||
test_copy(1 << 20); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.