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/util.cuh
ViewVC logotype

Diff of /branches/cuda/src/lib/include/diderot/util.cuh

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

revision 5625, Thu Aug 5 22:07:32 2021 UTC revision 5626, Thu Aug 19 23:05:45 2021 UTC
# Line 11  Line 11 
11   * COPYRIGHT (c) 2017 The University of Chicago   * COPYRIGHT (c) 2017 The University of Chicago
12   * All rights reserved.   * All rights reserved.
13   */   */
   
14  #ifndef _DIDEROT_UTIL_HXX_  #ifndef _DIDEROT_UTIL_HXX_
15  #define _DIDEROT_UTIL_HXX_  #define _DIDEROT_UTIL_HXX_
16    
17    
18  namespace diderot {  namespace diderot {
19    
20  // similar to the std::array type, but stripped down  // similar to the std::array type, but stripped down
# Line 24  Line 24 
24      typedef value_type &reference;      typedef value_type &reference;
25      typedef const value_type &const_reference;      typedef const value_type &const_reference;
26    
27        HD
28        array() = default;
29    
30        template <typename... Args>
31        HD
32        array(Args&&... values) : _elems{values...} {}
33    
34        HD
35        array(array *copy) {
36            std::copy(std::begin(copy->_elems), std::end(copy->_elems), std::begin(_elems));
37        }
38    
39      value_type      _elems[SZ];      value_type      _elems[SZ];
40    
41      HD      HD
42      reference operator[] (size_t i) noexcept { return _elems[i]; }      reference operator[] (size_t i) noexcept { return _elems[i]; }
43    
44      HD      HD
45      const_reference operator[] (size_t i) const noexcept { return _elems[i]; }      const_reference operator[] (size_t i) const noexcept { return _elems[i]; }
46    
47      HD      HD
48      value_type *data () noexcept { return _elems; }      value_type *data () noexcept { return _elems; }
49    
50      HD      HD
51      const value_type* data () const noexcept { return _elems; }      const value_type* data () const noexcept { return _elems; }
52    
53      HD      HD
54      size_t size () const noexcept { return SZ; }      size_t size () const noexcept { return SZ; }
55    
# Line 44  Line 61 
61          return cudaMemcpy(tgt->_elems, this->_elems, sizeof(T) * SZ, cudaMemcpyHostToDevice);          return cudaMemcpy(tgt->_elems, this->_elems, sizeof(T) * SZ, cudaMemcpyHostToDevice);
62      }      }
63  };  };
64    
65  HD  HD
66  inline float sign (float x) { return (x > 0) - (x < 0); }  inline float sign (float x) { return (x > 0) - (x < 0); }
67    
68  HD  HD
69  inline double sign (double x) { return (x > 0) - (x < 0); }  inline double sign (double x) { return (x > 0) - (x < 0); }
70    
71  namespace __details {  namespace __details {
72    
73  //! set the properties of an output stream (precision and alphabool)  //! set the properties of an output stream (precision and alphabool)
74  inline void config_ostream (std::ostream &os)  inline void config_ostream(std::ostream &os) {
 {  
75      os << std::boolalpha;      os << std::boolalpha;
76  #ifdef DIDEROT_SINGLE_PRECISION  #ifdef DIDEROT_SINGLE_PRECISION
77      // based on https://en.wikipedia.org/wiki/Single-precision_floating-point_format      // based on https://en.wikipedia.org/wiki/Single-precision_floating-point_format

Legend:
Removed from v.5625  
changed lines
  Added in v.5626

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