Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/cuda/src/lib/include/diderot/tensor.h
ViewVC logotype

Diff of /branches/cuda/src/lib/include/diderot/tensor.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5627, Tue Sep 7 16:19:47 2021 UTC revision 5628, Tue Sep 7 16:23:43 2021 UTC
# Line 47  Line 47 
47      REAL _data[N];      REAL _data[N];
48      HD      HD
49      tensor () { }      tensor () { }
50        HD
51        tensor(const tensor &t) {
52            this->copy(t.base());
53        }
54        HD
55      tensor (std::initializer_list< REAL > const &il)      tensor (std::initializer_list< REAL > const &il)
56      {      {
57          int32_t i = 0;          this->copy(il);
         for (auto it = il.begin(); it != il.end(); ++i, ++it) {  
             this->_data[i] = *it;  
         }  
58      }      }
59      HD tensor (const REAL *src)      HD tensor (const REAL *src)
60      {      {
61          this->copy(src);          this->copy(src);
62      }      }
63      ~tensor () { }      HD
64        ~tensor () = default;
65    
66      HD void copy (const REAL *src)      HD void copy (const REAL *src)
67      {      {
68  #ifdef DIDEROT_TARGET_CUDA  #ifdef DIDEROT_TARGET_CUDA
69  #if defined(__CUDA_ARCH__)          for (int i=0; i< N; i++) {
70          cudaMemcpy(this->_data, src, N*sizeof(REAL), cudaMemcpyDeviceToDevice);              this->base()[i] = src[i];
71  #else          }
         std::memcpy(this->_data, src, N*sizeof(REAL));  
 #endif //defined(__CUDA_ARCH__)  
72  #else  #else
73          std::memcpy(this->_data, src, N*sizeof(REAL));          std::memcpy(this->_data, src, N*sizeof(REAL));
74  #endif // DIDEROT_TARGET_CUDA  #endif // DIDEROT_TARGET_CUDA
75      }      }
76        HD
77      void copy (std::initializer_list< REAL > const &il)      void copy (std::initializer_list< REAL > const &il)
78      {      {
79          int32_t i = 0;          int32_t i = 0;

Legend:
Removed from v.5627  
changed lines
  Added in v.5628

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0