Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/marian.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2018-01-12 00:42:22 +0300
committerHieu Hoang <hieuhoang@gmail.com>2018-01-12 00:42:22 +0300
commit28e71c94ffacbcab318f930009c4ffe9f056d774 (patch)
tree450216fa61bb01bd49478f465683d159334b0cfd
parentbfd0a3675836d961a3391fc8f15938a5a9245042 (diff)
create copyFrom
-rw-r--r--src/amun/gpu/decoder/encoder_decoder.cu2
-rw-r--r--src/amun/gpu/mblas/vector.h30
2 files changed, 12 insertions, 20 deletions
diff --git a/src/amun/gpu/decoder/encoder_decoder.cu b/src/amun/gpu/decoder/encoder_decoder.cu
index 386c8f92..39663085 100644
--- a/src/amun/gpu/decoder/encoder_decoder.cu
+++ b/src/amun/gpu/decoder/encoder_decoder.cu
@@ -202,8 +202,10 @@ void EncoderDecoder::DecodeAsyncInternal()
//if (histories.NumActive() < 8) {
if (unsigned numSentToGet = SentencesToGet(histories)) {
+ BEGIN_TIMER("TopupBatch.outer");
//InitBatch(histories, sentenceLengths, sourceContext, SCU, *state);
TopupBatch(histories, numSentToGet, sentenceLengths, sourceContext, SCU, *nextState, *state);
+ PAUSE_TIMER("TopupBatch.outer");
}
else {
AssembleBeamState(histories, *nextState, *state);
diff --git a/src/amun/gpu/mblas/vector.h b/src/amun/gpu/mblas/vector.h
index adb9ae61..d79ee4be 100644
--- a/src/amun/gpu/mblas/vector.h
+++ b/src/amun/gpu/mblas/vector.h
@@ -84,11 +84,7 @@ public:
:maxSize_(0)
,data_(nullptr)
{
- newSize(vec.size());
-
- if (size()) {
- HANDLE_ERROR( cudaMemcpyAsync(data_, vec.data(), vec.size() * sizeof(T), cudaMemcpyHostToDevice, CudaStreamHandler::GetStream()) );
- }
+ copyFrom(vec);
}
explicit Vector(const Vector<T> &other)
@@ -177,6 +173,15 @@ public:
//std::cerr << "reserve3=" << newSize << std::endl;
}
+ void copyFrom(const std::vector<T> &vec)
+ {
+ newSize(vec.size());
+
+ if (size()) {
+ HANDLE_ERROR( cudaMemcpyAsync(data_, vec.data(), vec.size() * sizeof(T), cudaMemcpyHostToDevice, CudaStreamHandler::GetStream()) );
+ }
+ }
+
void clear()
{
size_ = 0;
@@ -189,21 +194,6 @@ public:
std::swap(data_, other.data_);
}
- Vector& operator=(const Vector& other)
- {
- if (this != &other) {
- newSize(other.size());
-
- HANDLE_ERROR( cudaMemcpyAsync(
- data_,
- other.data_,
- size_ * sizeof(T),
- cudaMemcpyDeviceToDevice,
- CudaStreamHandler::GetStream()) );
- }
- return *this;
- }
-
virtual std::string Debug(unsigned verbosity = 1) const;
protected: