├── Buffers ├── Buffer.cpp ├── Buffer.h ├── CMakeLists.txt ├── CPUBuffer.cpp ├── CPUBuffer.h ├── GPUBuffer.cpp ├── GPUBuffer.h ├── Makefile ├── PinnedCPUBuffer.cpp ├── PinnedCPUBuffer.h ├── bufferExample.cpp ├── test_CPUBuffer.cpp └── test_GPUBuffer.cpp ├── CMakeLists.txt ├── IVE ├── win32 │ ├── INCLUDE │ │ ├── IM.h │ │ ├── IMInclude.h │ │ ├── IWApiConstants.h │ │ ├── cxxstd.h │ │ ├── exhdr.inc │ │ ├── fortran_types.h │ │ ├── ive_conf.h │ │ ├── ive_error.h │ │ ├── ive_fortran.h │ │ ├── ive_hash.h │ │ ├── ive_standards.h │ │ ├── ive_thread.h │ │ ├── ive_time.h │ │ └── kernel │ │ │ ├── IKInterleave.h │ │ │ ├── IMNetFuncs.h │ │ │ └── convert.h │ └── LIB │ │ ├── libimlib.a │ │ └── libive.a └── win64 │ ├── INCLUDE │ ├── IM.h │ ├── IMInclude.h │ ├── IWApiConstants.h │ ├── cxxstd.h │ ├── exhdr.inc │ ├── fortran_types.h │ ├── ive_conf.h │ ├── ive_error.h │ ├── ive_fortran.h │ ├── ive_hash.h │ ├── ive_standards.h │ ├── ive_thread.h │ ├── ive_time.h │ ├── kernel │ │ ├── IKInterleave.h │ │ ├── IMNetFuncs.h │ │ └── convert.h │ └── malloc.inc │ └── LIB │ ├── libimlib.a │ ├── libimlib.lib │ ├── libive - Copy.a │ └── libive.lib ├── VStutio_project ├── Buffers │ ├── Buffers.vcxproj │ └── Buffers.vcxproj.filters ├── VStutio_project.sln ├── VStutio_project.vcxproj └── VStutio_project.vcxproj.filters ├── cudaSirecon ├── CImg.h ├── CMakeLists.txt ├── SIM_reconstructor.hpp ├── boostfs.cpp ├── cudaSirecon.cpp ├── cudaSirecon.h ├── cudaSireconDriver.cpp ├── cudaSireconImpl.h ├── gpuFunctions.h ├── gpuFunctionsImpl.cu ├── gpuFunctionsImpl_hh.cu └── tiffhandle.cpp ├── cutilSafeCall.h └── lapack ├── win32 ├── BLAS.lib ├── LAPACK.lib ├── cblas.lib ├── clapack.lib ├── libf2c.lib └── liblapacke.lib └── win64 ├── libblas.dll ├── libblas.lib ├── liblapack.dll ├── liblapack.lib ├── liblapacke.dll ├── libtmglib.dll └── libtmglib.lib /Buffers/Buffer.cpp: -------------------------------------------------------------------------------- 1 | #include "Buffer.h" 2 | 3 | Buffer::~Buffer() { 4 | } 5 | 6 | void Buffer::dump(std::ostream& s, int numCols) 7 | { 8 | dump(s, numCols, 0, getSize()); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /Buffers/Buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef BUFFER_H 2 | #define BUFFER_H 3 | 4 | #include 5 | #include 6 | 7 | class CPUBuffer; 8 | class PinnedCPUBuffer; 9 | class GPUBuffer; 10 | 11 | /** Buffer class for managing flat memory. 12 | * 13 | * This class serves two main purposes: 14 | * 1) Manage memory resources 15 | * 2) Transfer data between different buffers that could reside on 16 | * different devices (e.g. host vs gpu or in a multi-gpu environment) 17 | * 18 | * @brief Interface for Buffer classes used for managing memory on CPUs, 19 | * GPUs, and data transfers. 20 | * */ 21 | class Buffer { 22 | 23 | public: 24 | /** Destructor*/ 25 | virtual ~Buffer(); 26 | 27 | /** Get current size of buffer.*/ 28 | virtual size_t getSize() const = 0; 29 | /** Get pointer to the memory managed by the buffer.*/ 30 | virtual void* getPtr() = 0; 31 | /** Get a const pointer to the memory managed by the buffer.*/ 32 | virtual const void* getPtr() const = 0; 33 | /** Resize the buffer. The old data becomes invalid after a call to 34 | * resize. 35 | * @param newsize New size of buffer. 36 | * */ 37 | virtual void resize(size_t newsize) = 0; 38 | 39 | /** Copy a slice of this buffer into dest. The slice in this starts 40 | * at srcBegin and ends at srcEnd. The slice is copied into dest 41 | * starting at destBegin. The parameters srcBegin, srcEnd, and 42 | * destBegin are in bytes. 43 | * @param dest Buffer that is to be set. 44 | * @param srcBegin Beginning of slice that is copied into Buffer. 45 | * @param srcEnd End of slice that is copied into Buffer. 46 | * @param destBegin Offset into dest. 47 | * */ 48 | virtual void set(Buffer* dest, size_t srcBegin, size_t srcEnd, 49 | size_t destBegin) const = 0; 50 | 51 | /** Set this buffer from a src CPUBuffer. 52 | * @param src Source buffer. 53 | * @param srcBegin Beginning of slice that is copied into this. 54 | * @param srcEnd End of slice that is copied into this. 55 | * @param destBegin Offset in dest. 56 | * */ 57 | virtual void setFrom(const CPUBuffer& src, size_t srcBegin, 58 | size_t srcEnd, size_t destBegin) = 0; 59 | /** Set this buffer from a src PinnedCPUBuffer. Data transfers 60 | * between GPUBuffer and PinnedCPUBuffer objects are done 61 | * asynchronously. 62 | * @param src Source buffer. 63 | * @param srcBegin Beginning of slice that is copied into this. 64 | * @param srcEnd End of slice that is copied into this. 65 | * @param destBegin Offset in dest. 66 | * */ 67 | virtual void setFrom(const PinnedCPUBuffer& src, size_t srcBegin, 68 | size_t srcEnd, size_t destBegin) = 0; 69 | /** Set this buffer from a src GPUBuffer. Currently only setting 70 | * from a buffer on the same device is supported. 71 | * @param src Source buffer. 72 | * @param srcBegin Beginning of slice that is copied into this. 73 | * @param srcEnd End of slice that is copied into this. 74 | * @param destBegin Offset in dest. 75 | * */ 76 | virtual void setFrom(const GPUBuffer& src, size_t srcBegin, 77 | size_t srcEnd, size_t destBegin) = 0; 78 | 79 | /** Set contents of Buffer to zero. */ 80 | virtual void setToZero() = 0; 81 | 82 | /** Dump contents of buffer to a stream 83 | * @param stream Stream to which to write. 84 | * @param numCols Number of entries per line 85 | */ 86 | void dump(std::ostream& stream, int numCols); 87 | /** Dump part of a Buffer to a stream 88 | * @param stream Stream to which to write. 89 | * @param numCols Number of entries per line 90 | * @param begin Start of part of buffer to be dumped (in bytes) 91 | * @param end End of part of the buffer to be dumped (in bytes) 92 | * */ 93 | virtual void dump(std::ostream& stream, int numCols, 94 | size_t begin, size_t end) = 0; 95 | 96 | /** Check if there are any nans in the buffer. This is an expensive 97 | * operation that is carried out on the CPU. The entire buffer is 98 | * traversed as if it were an array of floats and each entry is 99 | * checked to see whether it is nan. To avoid excessive slow down 100 | * in the application this function should typically be wrapped in a 101 | * conditional compilation section (e.g. using #ifndef NDEBUG). 102 | * @param verbose If this flag is set to true all nan entries are 103 | * printed to the std::cout. If the flag is false the function 104 | * returns when the first nan value is encountered. 105 | * */ 106 | virtual bool hasNaNs(bool verbose = false) const = 0; 107 | }; 108 | 109 | /** 110 | * \mainpage Buffer classes for managing memory allocation and data transfers 111 | * 112 | * 113 | * \section intro_sec Introduction 114 | * 115 | * The purpose of the various Buffer classes is to automate memory 116 | * allocation and deallocation and to make data transfers between 117 | * different memory spaces (e.g. CPU and GPU) easier. 118 | * 119 | * 120 | * \section allocation Memory allocation and deallocation 121 | * 122 | * In general, memory resources are allocated by creating Buffer 123 | * objects. Buffers can be resized if the memory requirements change of 124 | * if the memory is no longer needed. In case of the latter one should 125 | * resize to 0. Memory is released automatically when the Buffer object 126 | * goes out of scope. 127 | * 128 | * 129 | * \section transfers Data transfers 130 | * 131 | * Data transfers are typically done using the set method on the source 132 | * buffer with a pointer to the target buffer as an argument. The 133 | * various setFrom() methods are a lower level mechanism that allows set 134 | * to work polymorphically for any buffer as the destination. In 135 | * general the set method should be preferred over the setFrom() methods 136 | * in application code. The purpose of the other arguments of the set 137 | * method is to enable copying a slice of the source buffer to a 138 | * specific offset in the target buffer (e.g. a two dimensional slice in 139 | * the x-y plane). 140 | * 141 | * Asynchronous data transfers can be achieved by using PinnedCPUBuffer 142 | * objects on the host side. 143 | * 144 | * It is possible to sidestep the data transfer mechanisms provided by 145 | * the Buffer classes. To this end one can get the raw pointers to the 146 | * underlying memory using the getPtr() methods. 147 | * 148 | * 149 | * \section example Example 150 | * 151 | * An example of how this may be used is shown by the following program. 152 | * 153 | * \include bufferExample.cpp 154 | * 155 | * 156 | */ 157 | 158 | /** \def NDEBUG 159 | * This macro controlls whether assert statements are evaluated or not. 160 | * If NDEBUG is defined assert statements are not compiled. 161 | */ 162 | #endif 163 | 164 | -------------------------------------------------------------------------------- /Buffers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories( 2 | "${CMAKE_CURRENT_SOURCE_DIR}" 3 | ${CUDA_INCLUDE_DIRS} 4 | "${CMAKE_SOURCE_DIR}/gtest/include" 5 | ) 6 | 7 | CUDA_ADD_LIBRARY( 8 | Buffer 9 | Buffer.cpp 10 | bufferExample.cpp 11 | CPUBuffer.cpp 12 | GPUBuffer.cpp 13 | PinnedCPUBuffer.cpp 14 | ) 15 | 16 | set(HEADERS 17 | SIMrecon_TechX/Buffers/Buffer.h 18 | SIMrecon_TechX/Buffers/CPUBuffer.h 19 | SIMrecon_TechX/Buffers/GPUBuffer.h 20 | SIMrecon_TechX/Buffers/PinnedCPUBuffer.h 21 | ) 22 | 23 | install( 24 | TARGETS Buffer 25 | RUNTIME DESTINATION bin 26 | LIBRARY DESTINATION lib 27 | ARCHIVE DESTINATION lib 28 | ) 29 | 30 | set(TESTS 31 | test_CPUBuffer 32 | test_GPUBuffer 33 | ) 34 | 35 | set(LIBRARIES 36 | Buffer 37 | gtest_main 38 | gtest 39 | ) 40 | 41 | #foreach(t ${TESTS}) 42 | # CUDA_ADD_EXECUTABLE(${t} ${t}.cpp) 43 | # add_dependencies(${t} ${LIBRARIES}) 44 | # target_link_libraries(${t} ${LIBRARIES}) 45 | # add_test(${t} ${t}) 46 | #endforeach(t) 47 | 48 | install( 49 | FILES ${HEADERS} DESTINATION include) 50 | 51 | #add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} 52 | # DEPENDS ${TESTS}) 53 | -------------------------------------------------------------------------------- /Buffers/CPUBuffer.cpp: -------------------------------------------------------------------------------- 1 | #include "CPUBuffer.h" 2 | 3 | #include "PinnedCPUBuffer.h" 4 | #include "GPUBuffer.h" 5 | 6 | CPUBuffer::CPUBuffer() : 7 | size_(0), ptr_(0) 8 | { 9 | } 10 | 11 | CPUBuffer::CPUBuffer(size_t size) : 12 | size_(size), ptr_(0) 13 | { 14 | ptr_ = new char[size_]; 15 | } 16 | 17 | CPUBuffer::CPUBuffer(const Buffer& toCopy) : 18 | size_(toCopy.getSize()), ptr_(0) 19 | { 20 | ptr_ = new char[size_]; 21 | toCopy.set(this, 0, size_, 0); 22 | } 23 | 24 | CPUBuffer& CPUBuffer::operator=(const Buffer& rhs) { 25 | if (this != &rhs) { 26 | size_ = rhs. getSize(); 27 | if (ptr_ != 0) { 28 | delete [] ptr_; 29 | } 30 | ptr_ = new char[size_]; 31 | rhs.set(this, 0, size_, 0); 32 | } 33 | return *this; 34 | } 35 | 36 | CPUBuffer::~CPUBuffer() { 37 | if (ptr_) { 38 | delete [] ptr_; 39 | } 40 | } 41 | 42 | void CPUBuffer::resize(size_t newsize) { 43 | if (ptr_) { 44 | delete [] ptr_; 45 | ptr_ = 0; 46 | } 47 | size_ = newsize; 48 | if (newsize > 0) { 49 | ptr_ = new char[size_]; 50 | } 51 | } 52 | 53 | void CPUBuffer::set(Buffer* dest, size_t srcBegin, size_t srcEnd, 54 | size_t destBegin) const { 55 | dest->setFrom(*this, srcBegin, srcEnd, destBegin); 56 | } 57 | 58 | void CPUBuffer::setFrom(const CPUBuffer& src, size_t srcBegin, 59 | size_t srcEnd, size_t destBegin) { 60 | if (srcEnd - srcBegin > size_ - destBegin) { 61 | throw std::runtime_error("Buffer overflow."); 62 | } 63 | memcpy(ptr_ + destBegin, (char*)src.getPtr() + srcBegin, 64 | srcEnd - srcBegin); 65 | } 66 | 67 | void CPUBuffer::setFrom(const PinnedCPUBuffer& src, size_t srcBegin, 68 | size_t srcEnd, size_t destBegin) { 69 | setFrom((const CPUBuffer&)src, srcBegin, srcEnd, destBegin); 70 | } 71 | 72 | 73 | void CPUBuffer::setFrom(const GPUBuffer& src, size_t srcBegin, 74 | size_t srcEnd, size_t destBegin) { 75 | if (srcEnd - srcBegin > size_ - destBegin) { 76 | throw std::runtime_error("Buffer overflow."); 77 | } 78 | cudaError_t err = cudaMemcpy(ptr_ + destBegin, 79 | (char*)src.getPtr() + srcBegin, srcEnd - srcBegin, 80 | cudaMemcpyDeviceToHost); 81 | if (err != cudaSuccess) { 82 | std::cout << "Error code: " << err << std::endl; 83 | std::cout << cudaGetErrorString(err) << std::endl; 84 | throw std::runtime_error("cudaMemcpy failed."); 85 | } 86 | } 87 | 88 | void CPUBuffer::setFrom(const void* src, size_t srcBegin, 89 | size_t srcEnd, size_t destBegin) { 90 | if (srcEnd - srcBegin > size_ - destBegin) { 91 | throw std::runtime_error("Buffer overflow."); 92 | } 93 | memcpy(ptr_ + destBegin, (char*)src + srcBegin, srcEnd - srcBegin); 94 | } 95 | 96 | void CPUBuffer::takeOwnership(const void* src, size_t num) { 97 | size_ = num; 98 | if (ptr_) { 99 | delete [] ptr_; 100 | } 101 | ptr_ = (char*) src; 102 | } 103 | 104 | void CPUBuffer::setPlainArray(void* dest, size_t srcBegin, 105 | size_t srcEnd, size_t destBegin) const { 106 | memcpy(dest, ptr_ + srcBegin, srcEnd - srcBegin); 107 | } 108 | 109 | void CPUBuffer::setToZero() 110 | { 111 | memset((void*)ptr_, 0, size_); 112 | } 113 | 114 | void CPUBuffer::dump(std::ostream& stream, int numCols) 115 | { 116 | Buffer::dump(stream, numCols); 117 | } 118 | 119 | void CPUBuffer::dump(std::ostream& stream, int numCols, 120 | size_t begin, size_t end) 121 | { 122 | float* arr = (float*)ptr_; 123 | arr += begin / sizeof(float); 124 | size_t numEntries = (end - begin) / sizeof(float); 125 | int i = 0; 126 | int row = 0; 127 | while (i < numEntries - numCols) { 128 | for (int j = 0; j < numCols; ++j) { 129 | stream << arr[i] << " "; 130 | ++i; 131 | } 132 | stream << std::endl; 133 | ++row; 134 | } 135 | for(; i < numEntries; ++i) { 136 | stream << arr[i] << " "; 137 | } 138 | stream << std::endl; 139 | } 140 | 141 | bool CPUBuffer::hasNaNs(bool verbose) const 142 | { 143 | int numEntries = size_ / sizeof(float); 144 | float* arr = (float*)ptr_; 145 | int i = 0; 146 | bool haveNaNs = false; 147 | if (verbose) { 148 | for (i = 0; i < numEntries; ++i) { 149 | #ifndef _WIN32 150 | bool in = std::isnan(arr[i]); 151 | #else 152 | bool in = _isnan(arr[i]); 153 | #endif 154 | if (in) { 155 | std::cout << "NaN entry in array at: " << i << std::endl; 156 | } 157 | haveNaNs |= in; 158 | } 159 | } else { 160 | while ((!haveNaNs) && i < numEntries) { 161 | #ifndef _WIN32 162 | haveNaNs |= std::isnan(arr[i]); 163 | #else 164 | haveNaNs |= _isnan(arr[i]); 165 | #endif 166 | ++i; 167 | } 168 | } 169 | return haveNaNs; 170 | } 171 | 172 | -------------------------------------------------------------------------------- /Buffers/CPUBuffer.h: -------------------------------------------------------------------------------- 1 | #ifndef CPU_BUFFER_H 2 | #define CPU_BUFFER_H 3 | 4 | #include "Buffer.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class PinnedCPUBuffer; 13 | class GPUBuffer; 14 | 15 | /** 16 | * @brief Buffer class for managing memory on CPU side. 17 | */ 18 | class CPUBuffer : public Buffer { 19 | 20 | public: 21 | /** Constructor. */ 22 | CPUBuffer(); 23 | /** Constructor with a certain size. 24 | * @param size Size of buffer.*/ 25 | CPUBuffer(size_t size); 26 | /** Copy constructor.*/ 27 | CPUBuffer(const Buffer& toCopy); 28 | /** Assignment operator.*/ 29 | CPUBuffer& operator=(const Buffer& rhs); 30 | /** Destructor.*/ 31 | virtual ~CPUBuffer(); 32 | 33 | /** Get current size of buffer.*/ 34 | virtual size_t getSize() const { return size_; } ; 35 | /** Get pointer to the memory managed by the buffer. This is a host 36 | * pointer.*/ 37 | virtual void* getPtr() { return ptr_; } ; 38 | virtual const void* getPtr() const { return ptr_; } ; 39 | /** Resize the buffer. The old data becomes invalid after a call to 40 | * resize. 41 | * @param newsize New size of buffer. 42 | * */ 43 | virtual void resize(size_t newsize); 44 | 45 | /** Copy a slice of this buffer into dest. The slice in this starts 46 | * at srcBegin and ends at srcEnd. The slice is copied into dest 47 | * starting at destBegin. The parameters srcBegin, srcEnd, and 48 | * destBegin are in bytes. 49 | * @param dest Buffer that is to be set. 50 | * @param srcBegin Beginning of slice that is copied into Buffer. 51 | * @param srcEnd End of slice that is copied into Buffer. 52 | * @param destBegin Offset into dest. 53 | * */ 54 | virtual void set(Buffer* dest, size_t srcBegin, size_t srcEnd, 55 | size_t destBegin) const; 56 | /** Set this buffer from a src CPUBuffer. 57 | * @param src Source buffer. 58 | * @param srcBegin Beginning of slice that is copied into this. 59 | * @param srcEnd End of slice that is copied into this. 60 | * @param destBegin Offset in dest. 61 | * */ 62 | virtual void setFrom(const CPUBuffer& src, size_t srcBegin, 63 | size_t srcEnd, size_t destBegin); 64 | /** Set this buffer from a src PinnedCPUBuffer. Data transfers 65 | * between GPUBuffer and PinnedCPUBuffer objects are done 66 | * asynchronously. 67 | * @param src Source buffer. 68 | * @param srcBegin Beginning of slice that is copied into this. 69 | * @param srcEnd End of slice that is copied into this. 70 | * @param destBegin Offset in dest. 71 | * */ 72 | virtual void setFrom(const PinnedCPUBuffer& src, size_t srcBegin, 73 | size_t srcEnd, size_t destBegin); 74 | /** Set this buffer from a src GPUBuffer. Currently only setting 75 | * from a buffer on the same device is supported. 76 | * @param src Source buffer. 77 | * @param srcBegin Beginning of slice that is copied into this. 78 | * @param srcEnd End of slice that is copied into this. 79 | * @param destBegin Offset in dest. 80 | * */ 81 | virtual void setFrom(const GPUBuffer& src, size_t srcBegin, 82 | size_t srcEnd, size_t destBegin); 83 | /** Set this buffer from a plain array. 84 | * @param src Source buffer. 85 | * @param srcBegin Beginning of slice that is copied into this. 86 | * @param srcEnd End of slice that is copied into this. 87 | * @param destBegin Offset in dest. 88 | * */ 89 | virtual void setFrom(const void* src, size_t srcBegin, 90 | size_t srcEnd, size_t destBegin); 91 | 92 | /** Use a host pointer for the buffer. Note that CPUBuffer calls 93 | * delete [] on this pointer when it is destroyed. src must not be 94 | * deleted by the client code. 95 | * @param src Pointer to valid host memory. Has to be at least of 96 | * size num. 97 | * @param num Size in bytes of src.*/ 98 | void takeOwnership(const void* src, size_t num); 99 | /** Copy the contents of the buffer to a plain array. Semantics is 100 | * identical to the set method. 101 | * @param dest Plain array that is to be set. 102 | * @param srcBegin Beginning of slice that is copied into dest. 103 | * @param srcEnd End of slice that is copied into dest. 104 | * @param destBegin Offset into dest. 105 | * */ 106 | virtual void setPlainArray(void* dest, size_t srcBegin, 107 | size_t srcEnd, size_t destBegin) const; 108 | 109 | virtual void setToZero(); 110 | 111 | void dump(std::ostream& stream, int numCols); 112 | virtual void dump(std::ostream& stream, int numCols, 113 | size_t begin, size_t end); 114 | 115 | virtual bool hasNaNs(bool verbose = false) const; 116 | 117 | private: 118 | size_t size_; 119 | char* ptr_; 120 | }; 121 | 122 | #endif 123 | 124 | -------------------------------------------------------------------------------- /Buffers/GPUBuffer.cpp: -------------------------------------------------------------------------------- 1 | #include "GPUBuffer.h" 2 | 3 | #include "CPUBuffer.h" 4 | #include "PinnedCPUBuffer.h" 5 | 6 | GPUBuffer::GPUBuffer() : 7 | device_(0), size_(0), ptr_(0) 8 | { 9 | } 10 | 11 | GPUBuffer::GPUBuffer(int device) : 12 | device_(device), size_(0), ptr_(0) 13 | { 14 | } 15 | 16 | GPUBuffer::GPUBuffer(size_t size, int device) : 17 | device_(device), size_(size), ptr_(0) 18 | { 19 | cudaError_t err = cudaSetDevice(device_); 20 | if (err != cudaSuccess) { 21 | throw std::runtime_error("cudaSetDevice failed."); 22 | } 23 | err = cudaMalloc((void**)&ptr_, size_); 24 | if (err != cudaSuccess) { 25 | throw std::runtime_error("cudaMalloc failed."); 26 | } 27 | } 28 | 29 | GPUBuffer::GPUBuffer(const GPUBuffer& toCopy) : 30 | device_(toCopy.device_), size_(toCopy.size_), ptr_(0) 31 | { 32 | this->resize(size_); 33 | toCopy.set(this, 0, size_, 0); 34 | } 35 | 36 | GPUBuffer::GPUBuffer(const Buffer& toCopy, int device) : 37 | device_(device), size_(toCopy.getSize()), ptr_(0) 38 | { 39 | this->resize(size_); 40 | toCopy.set(this, 0, size_, 0); 41 | } 42 | 43 | GPUBuffer& GPUBuffer::operator=(const GPUBuffer& rhs) { 44 | if (this->device_ != rhs.device_) { 45 | throw std::runtime_error( 46 | "Different devices in GPUBuffer::operator=."); 47 | } 48 | if (this != &rhs) { 49 | size_ = rhs.getSize(); 50 | this->resize(size_); 51 | rhs.set(this, 0, size_, 0); 52 | } 53 | return *this; 54 | } 55 | 56 | GPUBuffer& GPUBuffer::operator=(const CPUBuffer& rhs) { 57 | size_ = rhs.getSize(); 58 | this->resize(size_); 59 | rhs.set(this, 0, size_, 0); 60 | return *this; 61 | } 62 | 63 | GPUBuffer::~GPUBuffer() { 64 | if (ptr_) { 65 | cudaError_t err = cudaFree(ptr_); 66 | if (err != cudaSuccess) { 67 | std::cout << "Error code: " << err << std::endl; 68 | std::cout << "ptr_: " << (long long int)ptr_ << std::endl; 69 | throw std::runtime_error("cudaFree failed."); 70 | } 71 | ptr_ = 0; 72 | } 73 | } 74 | 75 | void GPUBuffer::resize(size_t newsize) { 76 | if (ptr_) { 77 | cudaError_t err = cudaFree(ptr_); 78 | if (err != cudaSuccess) { 79 | throw std::runtime_error("cudaFree failed."); 80 | } 81 | ptr_ = 0; 82 | } 83 | cudaError_t err = cudaSetDevice(device_); 84 | if (err != cudaSuccess) { 85 | throw std::runtime_error("cudaSetDevice failed."); 86 | } 87 | size_ = newsize; 88 | if (newsize > 0) { 89 | err = cudaMalloc((void**)&ptr_, size_); 90 | if (err != cudaSuccess) { 91 | throw std::runtime_error("cudaMalloc failed."); 92 | } 93 | } 94 | } 95 | 96 | void GPUBuffer::setPtr(char* ptr, size_t size, int device) 97 | { 98 | if (ptr_) { 99 | cutilSafeCall(cudaFree(ptr_)); 100 | } 101 | ptr_ = ptr; 102 | size_ = size; 103 | device_ = device; 104 | } 105 | 106 | void GPUBuffer::set(Buffer* dest, size_t srcBegin, size_t srcEnd, 107 | size_t destBegin) const { 108 | dest->setFrom(*this, srcBegin, srcEnd, destBegin); 109 | } 110 | 111 | void GPUBuffer::setFrom(const CPUBuffer& src, size_t srcBegin, 112 | size_t srcEnd, size_t destBegin) { 113 | if (srcEnd - srcBegin > size_ - destBegin) { 114 | std::cout << "Trying to write " << srcEnd - srcBegin << " bytes\n"; 115 | std::cout << "To buffer of size " << size_ << " bytes\n"; 116 | std::cout << "With offset " << destBegin << " bytes\n"; 117 | std::cout << "Overflow by " << (int)size_ - destBegin - (srcEnd - srcBegin) << "\n"; 118 | std::cout << std::endl; 119 | throw std::runtime_error("Buffer overflow."); 120 | } 121 | cudaError_t err = cudaMemcpy(ptr_ + destBegin, 122 | (char*)src.getPtr() + srcBegin, srcEnd - srcBegin, 123 | cudaMemcpyHostToDevice); 124 | if (err != cudaSuccess) { 125 | throw std::runtime_error("cudaMemcpy failed."); 126 | } 127 | } 128 | 129 | void GPUBuffer::setFrom(const PinnedCPUBuffer& src, size_t srcBegin, 130 | size_t srcEnd, size_t destBegin) { 131 | if (srcEnd - srcBegin > size_ - destBegin) { 132 | std::cout << "Trying to write " << srcEnd - srcBegin << " bytes\n"; 133 | std::cout << "To buffer of size " << size_ << " bytes\n"; 134 | std::cout << "With offset " << destBegin << " bytes\n"; 135 | std::cout << "Overflow by " << (int)size_ - destBegin - (srcEnd - srcBegin) << "\n"; 136 | std::cout << std::endl; 137 | throw std::runtime_error("Buffer overflow."); 138 | } 139 | cudaError_t err = cudaMemcpyAsync(ptr_ + destBegin, 140 | (char*)src.getPtr() + srcBegin, srcEnd - srcBegin, 141 | cudaMemcpyHostToDevice, 0); 142 | if (err != cudaSuccess) { 143 | throw std::runtime_error("cudaMemcpy failed."); 144 | } 145 | } 146 | 147 | void GPUBuffer::setFrom(const GPUBuffer& src, size_t srcBegin, 148 | size_t srcEnd, size_t destBegin) { 149 | if (this->device_ != src.device_) { 150 | throw std::runtime_error( 151 | "Currently setFrom only supports transferring data within the " 152 | "same device or between host and device."); 153 | } 154 | if (srcEnd - srcBegin > size_ - destBegin) { 155 | throw std::runtime_error("Buffer overflow."); 156 | } 157 | cudaError_t err = cudaMemcpy(ptr_ + destBegin, 158 | (char*)src.getPtr() + srcBegin, srcEnd - srcBegin, 159 | cudaMemcpyDeviceToDevice); 160 | if (err != cudaSuccess) { 161 | throw std::runtime_error("cudaMemcpy failed."); 162 | } 163 | } 164 | 165 | void GPUBuffer::dump(std::ostream& stream, int numCols) 166 | { 167 | Buffer::dump(stream,numCols); 168 | } 169 | 170 | void GPUBuffer::setToZero() 171 | { 172 | cudaMemset(ptr_, 0, size_); 173 | } 174 | 175 | void GPUBuffer::dump(std::ostream& stream, int numCols, 176 | size_t begin, size_t end) 177 | { 178 | CPUBuffer cpuBuff(*this); 179 | cpuBuff.dump(stream, numCols, begin, end); 180 | } 181 | 182 | bool GPUBuffer::hasNaNs(bool verbose) const 183 | { 184 | CPUBuffer tmp(size_); 185 | this->set(&tmp, 0, size_, 0); 186 | return tmp.hasNaNs(verbose); 187 | } 188 | -------------------------------------------------------------------------------- /Buffers/GPUBuffer.h: -------------------------------------------------------------------------------- 1 | #ifndef GPU_BUFFER_H 2 | #define GPU_BUFFER_H 3 | 4 | #include "Buffer.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "../cutilSafeCall.h" 12 | 13 | class CPUBuffer; 14 | class PinnedCPUBuffer; 15 | 16 | /** A class for managing flat GPU memory. The GPU memory managed by a 17 | * GPUBuffer is freed when the buffer is destroyed (e.g. when it goes 18 | * out of scope). 19 | * @brief Class for managing GPU memory. 20 | * */ 21 | class GPUBuffer : public Buffer { 22 | 23 | public: 24 | /** Constructor. Creates a buffer on default cuda device 0.*/ 25 | GPUBuffer(); 26 | /** Create a buffer on a specific cuda device. 27 | * @param device Cuda device on which to create the Buffer. 28 | * */ 29 | GPUBuffer(int device); 30 | /** Create a buffer of a certain size on a specific cuda device. 31 | * @param size Size of buffer in bytes. 32 | * @param device Cuda device on which to create the Buffer. 33 | * */ 34 | GPUBuffer(size_t size, int device); 35 | /** Copy constructor.*/ 36 | GPUBuffer(const GPUBuffer& toCopy); 37 | /** Copy a GPU Buffer to a different device. 38 | * @param toCopy GPUBuffer that is to be copied. 39 | * @param device Cuda device on which to create the new GPUBuffer.*/ 40 | GPUBuffer(const Buffer& toCopy, int device); 41 | /** Set a GPUBuffer from a different GPUBuffer. 42 | * @param rhs GPUBuffer from which to set this GPUBuffer.*/ 43 | GPUBuffer& operator=(const GPUBuffer& rhs); 44 | /** Set a GPUBuffer from a CPUBuffer. 45 | * @param rhs CPUBuffer from which to set this GPUBuffer.*/ 46 | GPUBuffer& operator=(const CPUBuffer& rhs); 47 | /** Destructor. Frees the GPU memory managed by this GPUBuffer.*/ 48 | virtual ~GPUBuffer(); 49 | 50 | virtual size_t getSize() const { return size_; } ; 51 | virtual void* getPtr() { return ptr_; } ; 52 | virtual const void* getPtr() const { return ptr_; } ; 53 | /** Set the pointer managed by this GPUBuffer to ptr. The memory 54 | * managed previously by this Buffer is released. 55 | * @param ptr Device pointer to GPU memory. 56 | * @param size Size of memory pointed to by ptr. 57 | * @param device Cuda device on which the memory pointed to by ptr 58 | * is located.*/ 59 | virtual void setPtr(char* ptr, size_t size, int device); 60 | /** Change the size of the GPUBuffer. The data held by the buffer 61 | * becomes invalid, even when the size of the buffer is increased. 62 | * Setting the size of the buffer to zero frees all GPU memory. 63 | * @param newsize New size of GPU buffer.*/ 64 | virtual void resize(size_t newsize); 65 | 66 | /** Copy a slice of this buffer into dest. The slice in this starts 67 | * at srcBegin and ends at srcEnd. The slice is copied into dest 68 | * starting at destBegin. The parameters srcBegin, srcEnd, and 69 | * destBegin are in bytes. 70 | * @param dest Buffer that is to be set. 71 | * @param srcBegin Beginning of slice that is copied into Buffer. 72 | * @param srcEnd End of slice that is copied into Buffer. 73 | * @param destBegin Offset into dest. 74 | * */ 75 | virtual void set(Buffer* dest, size_t srcBegin, size_t srcEnd, 76 | size_t destBegin) const; 77 | 78 | /** Set this buffer from a src CPUBuffer. 79 | * @param src Source buffer. 80 | * @param srcBegin Beginning of slice that is copied into this. 81 | * @param srcEnd End of slice that is copied into this. 82 | * @param destBegin Offset in dest. 83 | * */ 84 | virtual void setFrom(const CPUBuffer& src, size_t srcBegin, 85 | size_t srcEnd, size_t destBegin); 86 | /** Set this buffer from a src PinnedCPUBuffer. Data transfers 87 | * between GPUBuffer and PinnedCPUBuffer objects are done 88 | * asynchronously. 89 | * @param src Source buffer. 90 | * @param srcBegin Beginning of slice that is copied into this. 91 | * @param srcEnd End of slice that is copied into this. 92 | * @param destBegin Offset in dest. 93 | * */ 94 | virtual void setFrom(const PinnedCPUBuffer& src, size_t srcBegin, 95 | size_t srcEnd, size_t destBegin); 96 | /** Set this buffer from a src GPUBuffer. Currently only setting 97 | * from a buffer on the same device is supported. 98 | * @param src Source buffer. 99 | * @param srcBegin Beginning of slice that is copied into this. 100 | * @param srcEnd End of slice that is copied into this. 101 | * @param destBegin Offset in dest. 102 | * */ 103 | virtual void setFrom(const GPUBuffer& src, size_t srcBegin, 104 | size_t srcEnd, size_t destBegin); 105 | 106 | virtual void setToZero(); 107 | 108 | void dump(std::ostream& stream, int numCols); 109 | virtual void dump(std::ostream& stream, int numCols, 110 | size_t begin, size_t end); 111 | 112 | virtual bool hasNaNs(bool verbose = false) const; 113 | 114 | private: 115 | int device_; 116 | size_t size_; 117 | char* ptr_; 118 | }; 119 | 120 | #endif 121 | 122 | -------------------------------------------------------------------------------- /Buffers/Makefile: -------------------------------------------------------------------------------- 1 | GTEST_DIR=~/gtest 2 | INC_PATH+=-I $(GTEST_DIR)/include -I/usr/local/cuda/include -I./ 3 | LIB_PATH+=-L $(GTEST_DIR)/lib -L/usr/local/cuda/lib64 4 | LIBS= 5 | LIBS+=-lgtest_main -lgtest -pthread -lcuda -lcudart 6 | 7 | #CXXFLAGS+=$(LIBS) $(INC_PATH) $(LIB_PATH) -std=c++0x -g -O0 8 | CXXFLAGS+=$(LIBS) $(INC_PATH) $(LIB_PATH) -std=c++0x -O3 9 | #CXX=/scr_3/gcc/gcc-4.6.3/bin/g++ 10 | 11 | BUFFER_OBJECT_FILES=Buffer.o CPUBuffer.o GPUBuffer.o PinnedCPUBuffer.o 12 | all: $(BUFFER_OBJECT_FILES) 13 | 14 | example: bufferExample 15 | 16 | bufferExample: bufferExample.cpp $(BUFFER_OBJECT_FILES) 17 | 18 | tests=test_CPUBuffer test_GPUBuffer 19 | 20 | CPUBuffer.o: Buffer.o CPUBuffer.h CPUBuffer.cpp 21 | GPUBuffer.o: Buffer.o GPUBuffer.h GPUBuffer.cpp 22 | PinnedCPUBuffer.o: Buffer.o PinnedCPUBuffer.h PinnedCPUBuffer.cpp 23 | 24 | test_CPUBuffer: test_CPUBuffer.cpp GPUBuffer.o CPUBuffer.o Buffer.o 25 | 26 | test_GPUBuffer: test_GPUBuffer.cpp GPUBuffer.o CPUBuffer.o Buffer.o 27 | 28 | .PHONY: check 29 | check: $(tests) 30 | for t in $(tests) ; do \ 31 | ./$$t ; \ 32 | done 33 | 34 | .PHONY: clean 35 | clean: 36 | rm -f $(tests) *.o 37 | 38 | -------------------------------------------------------------------------------- /Buffers/PinnedCPUBuffer.cpp: -------------------------------------------------------------------------------- 1 | #include "PinnedCPUBuffer.h" 2 | #include "CPUBuffer.h" 3 | #include "GPUBuffer.h" 4 | 5 | PinnedCPUBuffer::PinnedCPUBuffer() : 6 | size_(0), ptr_(0) 7 | { 8 | } 9 | 10 | PinnedCPUBuffer::PinnedCPUBuffer(size_t size) : 11 | size_(size), ptr_(0) 12 | { 13 | cudaError_t err = cudaHostAlloc((void**)&ptr_, size_, cudaHostAllocDefault); 14 | if (err != cudaSuccess) { 15 | throw std::runtime_error("cudaHostAlloc() failed."); 16 | } 17 | } 18 | 19 | PinnedCPUBuffer::PinnedCPUBuffer(const Buffer& toCopy) : 20 | size_(toCopy.getSize()), ptr_(0) 21 | { 22 | cudaError_t err = cudaHostAlloc((void**)&ptr_, size_, cudaHostAllocDefault); 23 | if (err != cudaSuccess) { 24 | throw std::runtime_error("cudaHostAlloc() failed."); 25 | } 26 | toCopy.set(this, 0, size_, 0); 27 | } 28 | 29 | PinnedCPUBuffer& PinnedCPUBuffer::operator=(const Buffer& rhs) { 30 | cudaError_t err; 31 | if (this != &rhs) { 32 | size_ = rhs. getSize(); 33 | if (ptr_ != 0) { 34 | err = cudaFreeHost(ptr_); 35 | if (err != cudaSuccess) { 36 | throw std::runtime_error("cudaFreeHost() failed."); 37 | } 38 | } 39 | err = cudaHostAlloc((void**)&ptr_, size_, cudaHostAllocDefault); 40 | if (err != cudaSuccess) { 41 | throw std::runtime_error("cudaHostAlloc failed."); 42 | } 43 | rhs.set(this, 0, size_, 0); 44 | } 45 | return *this; 46 | } 47 | 48 | PinnedCPUBuffer::~PinnedCPUBuffer() { 49 | if (ptr_) { 50 | cudaError_t err = cudaFreeHost(ptr_); 51 | if (err != cudaSuccess) { 52 | throw std::runtime_error("cudaFreeHost() failed."); 53 | } 54 | } 55 | } 56 | 57 | void PinnedCPUBuffer::resize(size_t newsize) { 58 | cudaError_t err; 59 | if (ptr_) { 60 | err = cudaFreeHost(ptr_); 61 | if (err != cudaSuccess) { 62 | throw std::runtime_error("cudaFreeHost() failed."); 63 | } 64 | ptr_ = 0; 65 | } 66 | size_ = newsize; 67 | if (newsize > 0) { 68 | err = cudaHostAlloc((void**)&ptr_, size_, cudaHostAllocDefault); 69 | if (err != cudaSuccess) { 70 | throw std::runtime_error("cudaHostAlloc() failed."); 71 | } 72 | } 73 | } 74 | 75 | void PinnedCPUBuffer::set(Buffer* dest, size_t srcBegin, size_t srcEnd, 76 | size_t destBegin) const { 77 | dest->setFrom(*this, srcBegin, srcEnd, destBegin); 78 | } 79 | 80 | void PinnedCPUBuffer::setFrom(const CPUBuffer& src, size_t srcBegin, 81 | size_t srcEnd, size_t destBegin) { 82 | if (srcEnd - srcBegin > size_ - destBegin) { 83 | throw std::runtime_error("Buffer overflow."); 84 | } 85 | memcpy(ptr_ + destBegin, (char*)src.getPtr() + srcBegin, 86 | srcEnd - srcBegin); 87 | } 88 | 89 | void PinnedCPUBuffer::setFrom(const PinnedCPUBuffer& src, size_t srcBegin, 90 | size_t srcEnd, size_t destBegin) { 91 | setFrom((const CPUBuffer&)src, srcBegin, srcEnd, destBegin); 92 | } 93 | 94 | 95 | void PinnedCPUBuffer::setFrom(const GPUBuffer& src, size_t srcBegin, 96 | size_t srcEnd, size_t destBegin) { 97 | if (srcEnd - srcBegin > size_ - destBegin) { 98 | throw std::runtime_error("Buffer overflow."); 99 | } 100 | cudaError_t err = cudaMemcpyAsync(ptr_ + destBegin, 101 | (char*)src.getPtr() + srcBegin, srcEnd - srcBegin, 102 | cudaMemcpyDeviceToHost, 0); 103 | if (err != cudaSuccess) { 104 | std::cout << "Error code: " << err << std::endl; 105 | std::cout << cudaGetErrorString(err) << std::endl; 106 | throw std::runtime_error("cudaMemcpy failed."); 107 | } 108 | } 109 | 110 | void PinnedCPUBuffer::setFrom(const void* src, size_t srcBegin, 111 | size_t srcEnd, size_t destBegin) 112 | { 113 | CPUBuffer::setFrom(src, srcBegin, srcEnd, destBegin); 114 | } 115 | 116 | bool PinnedCPUBuffer::hasNaNs(bool verbose) const 117 | { 118 | int numEntries = size_ / sizeof(float); 119 | float* arr = (float*)ptr_; 120 | int i = 0; 121 | bool haveNaNs = false; 122 | if (verbose) { 123 | for (i = 0; i < numEntries; ++i) { 124 | #ifndef _WIN32 125 | bool in = std::isnan(arr[i]); 126 | #else 127 | bool in = _isnan(arr[i]); 128 | #endif 129 | if (in) { 130 | std::cout << "NaN entry in array at: " << i << std::endl; 131 | } 132 | haveNaNs |= in; 133 | } 134 | } else { 135 | while ((!haveNaNs) && i < numEntries) { 136 | #ifndef _WIN32 137 | haveNaNs |= std::isnan(arr[i]); 138 | #else 139 | haveNaNs |= _isnan(arr[i]); 140 | #endif 141 | ++i; 142 | } 143 | } 144 | return haveNaNs; 145 | } 146 | -------------------------------------------------------------------------------- /Buffers/PinnedCPUBuffer.h: -------------------------------------------------------------------------------- 1 | #ifndef PINNED_CPU_BUFFER_H 2 | #define PINNED_CPU_BUFFER_H 3 | 4 | #include "Buffer.h" 5 | #include "CPUBuffer.h" 6 | 7 | #include 8 | 9 | class GPUBuffer; 10 | 11 | /** 12 | * @brief Buffer class for managing pinned host memory. 13 | */ 14 | class PinnedCPUBuffer : public CPUBuffer { 15 | 16 | public: 17 | /** Constructor. */ 18 | PinnedCPUBuffer(); 19 | /** Constructor with a certain size. 20 | * @param size Size of buffer.*/ 21 | PinnedCPUBuffer(size_t size); 22 | /** Copy constructor.*/ 23 | PinnedCPUBuffer(const Buffer& toCopy); 24 | /** Assignment operator.*/ 25 | PinnedCPUBuffer& operator=(const Buffer& rhs); 26 | /** Destructor.*/ 27 | virtual ~PinnedCPUBuffer(); 28 | 29 | /** Get current size of buffer.*/ 30 | virtual size_t getSize() const { return size_; } ; 31 | /** Get pointer to the memory managed by the buffer. This is a host 32 | * pointer.*/ 33 | virtual void* getPtr() { return ptr_; } ; 34 | virtual const void* getPtr() const { return ptr_; } ; 35 | /** Resize the buffer. The old data becomes invalid after a call to 36 | * resize. 37 | * @param newsize New size of buffer. 38 | * */ 39 | virtual void resize(size_t newsize); 40 | 41 | virtual void set(Buffer* dest, size_t srcBegin, size_t srcEnd, 42 | size_t destBegin) const; 43 | 44 | virtual void setFrom(const CPUBuffer& src, size_t srcBegin, 45 | size_t srcEnd, size_t destBegin); 46 | virtual void setFrom(const PinnedCPUBuffer& src, size_t srcBegin, 47 | size_t srcEnd, size_t destBegin); 48 | virtual void setFrom(const GPUBuffer& src, size_t srcBegin, 49 | size_t srcEnd, size_t destBegin); 50 | virtual void setFrom(const void* src, size_t srcBegin, 51 | size_t srcEnd, size_t destBegin); 52 | 53 | virtual bool hasNaNs(bool verbose = false) const; 54 | 55 | private: 56 | size_t size_; 57 | char* ptr_; 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /Buffers/bufferExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | int main(int argn, char** argv) 9 | { 10 | // Size of vector 11 | static const int N = 10; 12 | // 13 | // Input data 14 | float v[10] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f}; 15 | 16 | // Create a Buffer on the host side 17 | CPUBuffer v_cpu(sizeof(v)); 18 | 19 | // Set the buffer from the input data 20 | v_cpu.setFrom(v, 0, sizeof(v), 0); 21 | 22 | // Print contents of v_cpu 23 | std::cout << "Data before transfer to GPU:\n"; 24 | v_cpu.dump(std::cout, N); 25 | 26 | // Create Buffer on the GPU (cuda device ID 0) 27 | GPUBuffer v_gpu(sizeof(v), 0); 28 | 29 | // Copy data from CPU to GPU 30 | v_cpu.set(&v_gpu, 0, v_cpu.getSize(), 0); 31 | 32 | // Create another Buffer on the CPU 33 | CPUBuffer v2_cpu(sizeof(v)); 34 | 35 | // Transfer data back from GPU to the CPU 36 | v_gpu.set(&v2_cpu, 0, v_gpu.getSize(), 0); 37 | 38 | // Print contents of output buffer 39 | std::cout << "Data after transfer to GPU:\n"; 40 | v2_cpu.dump(std::cout, N); 41 | 42 | // Upon exiting the scope of the program the memory associated with 43 | // the various Buffers (CPU and GPU) is automatically deallocated. 44 | return 0; 45 | } 46 | 47 | /** \example bufferExample.cpp 48 | * @brief This is an example of how to use the Buffer classes for memory 49 | * management and data transfers. 50 | */ 51 | 52 | -------------------------------------------------------------------------------- /Buffers/test_CPUBuffer.cpp: -------------------------------------------------------------------------------- 1 | #include "Buffer.h" 2 | #include "CPUBuffer.h" 3 | #include "GPUBuffer.h" 4 | #include "gtest/gtest.h" 5 | #include 6 | 7 | 8 | int compareArrays(char* arr1, char* arr2, int size); 9 | TEST(CPUBuffer, IncludeTest) { 10 | ASSERT_EQ(0, 0); 11 | } 12 | TEST(CPUBuffer, ConstructorTest) { 13 | CPUBuffer a; 14 | ASSERT_EQ(0, a.getSize()); 15 | ASSERT_EQ(0, a.getPtr()); 16 | CPUBuffer b(4 * sizeof(float)); 17 | ASSERT_EQ(4 * sizeof(float), b.getSize()); 18 | EXPECT_TRUE(0 != b.getPtr()); 19 | } 20 | TEST(CPUBuffer, ResizeTest) { 21 | CPUBuffer a; 22 | a.resize(10); 23 | ASSERT_EQ(10, a.getSize()); 24 | EXPECT_TRUE(0 != a.getPtr()); 25 | } 26 | TEST(CPUBuffer, SetFromPlainArrayTest) { 27 | CPUBuffer a; 28 | ASSERT_EQ(0, a.getSize()); 29 | ASSERT_EQ(0, a.getPtr()); 30 | a.resize(4 * sizeof(float)); 31 | float src[4] = {11.0, 22.0, 33.0, 44.0}; 32 | float result[4] = {11.0, 22.0, 33.0, 44.0}; 33 | float out[4]; 34 | a.setFrom(src, 0, sizeof(src), 0); 35 | a.setPlainArray(out, 0, a.getSize(), 0); 36 | ASSERT_EQ(0, 37 | compareArrays((char*)out, (char*)result, sizeof(result))); 38 | } 39 | TEST(CPUBuffer, SetTest) { 40 | CPUBuffer a; 41 | ASSERT_EQ(0, a.getSize()); 42 | ASSERT_EQ(0, a.getPtr()); 43 | a.resize(4 * sizeof(float)); 44 | float src[4] = {11.0, 22.0, 33.0, 44.0}; 45 | float result[4] = {11.0, 22.0, 33.0, 44.0}; 46 | float out[4]; 47 | a.setFrom(src, 0, sizeof(src), 0); 48 | a.setPlainArray(out, 0, a.getSize(), 0); 49 | ASSERT_EQ(0, 50 | compareArrays((char*)out, (char*)result, sizeof(result))); 51 | 52 | CPUBuffer b; 53 | b.resize(a.getSize()); 54 | a.set(&b, 0, 4 * sizeof(float), 0); 55 | b.setPlainArray(out, 0, b.getSize(), 0); 56 | ASSERT_EQ(0, 57 | compareArrays((char*)out, (char*)result, sizeof(result))); 58 | } 59 | TEST(CPUBuffer, TakeOwnershipTest) { 60 | CPUBuffer a; 61 | float* src = new float[4]; 62 | src[0] = 11.0; 63 | src[1] = 22.0; 64 | src[2] = 33.0; 65 | src[3] = 44.0; 66 | float result[4] = {11.0, 22.0, 33.0, 44.0}; 67 | a.takeOwnership(src, 4 * sizeof(float)); 68 | ASSERT_EQ(0, 69 | compareArrays((char*)a.getPtr(), (char*)result, sizeof(result))); 70 | } 71 | TEST(CPUBuffer, Dump) { 72 | CPUBuffer a; 73 | float* src = new float[4]; 74 | src[0] = 11.0; 75 | src[1] = 22.0; 76 | src[2] = 33.0; 77 | src[3] = 44.0; 78 | a.takeOwnership(src, 4 * sizeof(float)); 79 | a.dump(std::cout, 2); 80 | ASSERT_EQ(0, 0); 81 | } 82 | TEST(CPUBuffer, GPUSetTest) { 83 | CPUBuffer a; 84 | ASSERT_EQ(0, a.getSize()); 85 | ASSERT_EQ(0, a.getPtr()); 86 | a.resize(4 * sizeof(float)); 87 | float src[4] = {11.0, 22.0, 33.0, 44.0}; 88 | float result[4] = {11.0, 22.0, 33.0, 44.0}; 89 | float out[4]; 90 | a.setFrom(src, 0, sizeof(src), 0); 91 | a.setPlainArray(out, 0, a.getSize(), 0); 92 | ASSERT_EQ(0, 93 | compareArrays((char*)out, (char*)result, sizeof(result))); 94 | 95 | GPUBuffer b; 96 | b.resize(a.getSize()); 97 | a.set(&b, 0, 4 * sizeof(float), 0); 98 | 99 | CPUBuffer c; 100 | c.resize(b.getSize()); 101 | ASSERT_EQ(4 * sizeof(float), c.getSize()); 102 | b.set(&c, 0, 4 * sizeof(float), 0); 103 | c.setPlainArray(out, 0, c.getSize(), 0); 104 | ASSERT_EQ(0, 105 | compareArrays((char*)out, (char*)result, sizeof(result))); 106 | } 107 | 108 | int compareArrays(char* arr1, char* arr2, int size) { 109 | int difference = 0; 110 | for (int i = 0; i < size; ++i) { 111 | difference += abs(arr1[i] - arr2[i]); 112 | } 113 | return difference; 114 | } 115 | 116 | -------------------------------------------------------------------------------- /Buffers/test_GPUBuffer.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | #include "Buffer.h" 3 | #include "GPUBuffer.h" 4 | #include "CPUBuffer.h" 5 | #include 6 | 7 | 8 | int compareArrays(char* arr1, char* arr2, int size); 9 | 10 | TEST(GPUBuffer, IncludeTest) { 11 | ASSERT_EQ(0, 0); 12 | } 13 | TEST(GPUBuffer, ConstructorTest) { 14 | GPUBuffer a; 15 | ASSERT_EQ(0, a.getSize()); 16 | ASSERT_EQ(0, a.getPtr()); 17 | GPUBuffer b(4 * sizeof(float), 0); 18 | ASSERT_EQ(4 * sizeof(float), b.getSize()); 19 | EXPECT_TRUE(0 != b.getPtr()); 20 | 21 | GPUBuffer c; 22 | GPUBuffer d(10, 0); 23 | c = d; 24 | } 25 | TEST(GPUBuffer, ResizeTest) { 26 | GPUBuffer a(0); 27 | a.resize(10); 28 | ASSERT_EQ(10, a.getSize()); 29 | EXPECT_TRUE(0 != a.getPtr()); 30 | } 31 | TEST(GPUBuffer, GPUSetTest) { 32 | CPUBuffer a; 33 | ASSERT_EQ(0, a.getSize()); 34 | ASSERT_EQ(0, a.getPtr()); 35 | a.resize(4 * sizeof(float)); 36 | float src[4] = {11.0, 22.0, 33.0, 44.0}; 37 | float result[4] = {11.0, 22.0, 33.0, 44.0}; 38 | float out[4]; 39 | a.setFrom(src, 0, sizeof(src), 0); 40 | a.setPlainArray(out, 0, a.getSize(), 0); 41 | ASSERT_EQ(0, 42 | compareArrays((char*)out, (char*)result, sizeof(result))); 43 | 44 | GPUBuffer b; 45 | b.resize(a.getSize()); 46 | a.set(&b, 0, 4 * sizeof(float), 0); 47 | 48 | GPUBuffer c; 49 | c.resize(b.getSize()); 50 | ASSERT_EQ(4 * sizeof(float), c.getSize()); 51 | b.set(&c, 0, 4 * sizeof(float), 0); 52 | 53 | CPUBuffer d; 54 | d.resize(c.getSize()); 55 | ASSERT_EQ(4 * sizeof(float), d.getSize()); 56 | c.set(&d, 0, c.getSize(), 0); 57 | d.setPlainArray(out, 0, d.getSize(), 0); 58 | ASSERT_EQ(0, 59 | compareArrays((char*)out, (char*)result, sizeof(result))); 60 | 61 | a.set(&c, 0, 2 * sizeof(float), 2 * sizeof(float)); 62 | c.dump(std::cout, 2); 63 | c.set(&d, 0, c.getSize(), 0); 64 | d.setPlainArray(out, 0, d.getSize(), 0); 65 | float result2[] = {11.0, 22.0, 11.0, 22.0}; 66 | ASSERT_EQ(0, 67 | compareArrays((char*)out, (char*)result2, sizeof(result2))); 68 | 69 | } 70 | TEST(GPUBuffer, DumpTest) { 71 | CPUBuffer a; 72 | ASSERT_EQ(0, a.getSize()); 73 | ASSERT_EQ(0, a.getPtr()); 74 | a.resize(4 * sizeof(float)); 75 | float src[4] = {11.0, 22.0, 33.0, 44.0}; 76 | float result[4] = {11.0, 22.0, 33.0, 44.0}; 77 | float out[4]; 78 | a.setFrom(src, 0, sizeof(src), 0); 79 | a.setPlainArray(out, 0, a.getSize(), 0); 80 | ASSERT_EQ(0, 81 | compareArrays((char*)out, (char*)result, sizeof(result))); 82 | 83 | GPUBuffer b; 84 | b.resize(a.getSize()); 85 | a.set(&b, 0, 4 * sizeof(float), 0); 86 | 87 | GPUBuffer c; 88 | c.resize(b.getSize()); 89 | ASSERT_EQ(4 * sizeof(float), c.getSize()); 90 | b.set(&c, 0, 4 * sizeof(float), 0); 91 | c.dump(std::cout, 2); 92 | } 93 | 94 | int compareArrays(char* arr1, char* arr2, int size) { 95 | int difference = 0; 96 | for (int i = 0; i < size; ++i) { 97 | difference += abs(arr1[i] - arr2[i]); 98 | } 99 | return difference; 100 | } 101 | 102 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | # Build instruction for CUDA SIMrecon project 3 | # 1. Prerequisites 4 | # 1.1 Cmake (> 2.8.11) 5 | # 1.2 CUDA SDK (>5.0) 6 | # 1.3a. If Linux or Mac OS X, GCC (< 4.8) 7 | # 1.3b. If Windows, Visual C++ (> 2012) 8 | # 1.4 Boost libraries (> 1.48) 9 | # 1.5 IVE libraries (download from http://msg.ucsf.edu/IVE/Download/index.html). Place the priism-4.2.9/ folder under this folder where this file is located 10 | # 11 | # 2. Make a build dir (assumed to be "build" under the main folder where this 12 | # CMakeLists.txt is located) and cd into it 13 | # 14 | # 3. On Linux or Mac at a shell prompt, type: 15 | # $ cmake -D CMAKE_BUILD_TYPE=Release .. 16 | # On Windows, one extra flag is needed. Type the following in a 17 | # VS build environment: 18 | # > cmake -D CMAKE_BUILD_TYPE=Release -G "NMake Makefiles" .. 19 | # Make sure there isn't any error or warning messages. 20 | # Always delete everything in the build dir before re-run cmake 21 | # 22 | # 4. Type "make" on Linux/Mac or "nmake" on Window to build the executable 23 | # 24 | # 5. If building is successful, an executable cudaSireconDriveris generated in 25 | # build/cudaSirecon. Run the test to make sure it works: 26 | # $ ../testData/job.sh 27 | # 28 | ####################################################################### 29 | 30 | 31 | cmake_minimum_required (VERSION 2.8) 32 | 33 | project (cudaSIMRecon) 34 | 35 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) 36 | 37 | ENABLE_TESTING() 38 | 39 | set(VERSION_MAJOR "0") 40 | set(VERSION_MINOR "0") 41 | set(VERSION_PATCH "1") 42 | set(PROJECT_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) 43 | 44 | ###################################################################### 45 | # 46 | # Set permissions before adding subdirectories 47 | # 48 | ###################################################################### 49 | set(SCI_GROUP_WRITE GROUP_WRITE) 50 | set(SCI_WORLD_FILE_PERMS WORLD_READ) 51 | set(SCI_WORLD_PROGRAM_PERMS WORLD_READ WORLD_EXECUTE) 52 | 53 | find_package(OpenMP) 54 | if(OPENMP_FOUND) 55 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") 56 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") 57 | endif() 58 | 59 | if (APPLE) 60 | # Apple's default clang complier does not support OpenMP 61 | # set(CMAKE_C_COMPILER gcc) 62 | # set(CMAKE_CXX_COMPILER g++) 63 | # set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -undefined dynamic_lookup -flat_namespace") 64 | # set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -undefined dynamic_lookup -flat_namespace") 65 | endif() 66 | 67 | 68 | # Building the documentation 69 | option(BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentation" OFF) 70 | if(BUILD_DOCUMENTATION) 71 | FIND_PACKAGE(Doxygen) 72 | if (NOT DOXYGEN_FOUND) 73 | message(FATAL_ERROR 74 | "Doxygen is needed to build the documentation. Please 75 | install it correctly") 76 | endif() 77 | #-- Configure the Template Doxyfile for our specific project 78 | configure_file(Doxyfile.in 79 | ${PROJECT_BINARY_DIR}/Doxyfile @ONLY IMMEDIATE) 80 | #-- Add a custom target to run Doxygen when ever the project is built 81 | add_custom_target (Docs ALL 82 | COMMAND ${DOXYGEN_EXECUTABLE} 83 | ${PROJECT_BINARY_DIR}/Doxyfile 84 | SOURCES 85 | ${PROJECT_BINARY_DIR}/Doxyfile) 86 | endif() 87 | 88 | find_package(CUDA) 89 | 90 | if (WITH_TIFF) 91 | if (WIN32) 92 | set(TIFF_INCLUDE_DIR "c:/libtiff") 93 | set(TIFF_LIBRARY "c:/libtiff") 94 | endif(WIN32) 95 | find_package(TIFF) 96 | set(CMAKE_CXX_FLAGS 97 | "${CMAKE_CXX_FLAGS} -D__SIRECON_USE_TIFF__") 98 | endif() 99 | 100 | if(WIN32) 101 | find_package( Boost ) 102 | else() 103 | find_package( Boost REQUIRED COMPONENTS program_options filesystem regex system) 104 | endif(WIN32) 105 | 106 | if(WIN32 OR APPLE) 107 | link_directories ( ${Boost_LIBRARY_DIRS} ) 108 | include_directories( ${Boost_INCLUDE_DIRS} ) 109 | endif() 110 | 111 | if(APPLE) 112 | find_package(X11) 113 | link_directories ( ${X11_INCLUDE_DIR}/../lib ) 114 | endif() 115 | 116 | set(CUDA_NVCC_FLAGS 117 | -gencode=arch=compute_20,code=sm_20;-gencode=arch=compute_30,code=sm_30;-gencode=arch=compute_35,code=sm_35;-gencode=arch=compute_50,code=sm_50) 118 | 119 | if(WIN32) 120 | set(CUDA_NVCC_FLAGS 121 | ${CUDA_NVCC_FLAGS};-I${Boost_INCLUDE_DIRS};--use-local-env;--cl-version=2013) 122 | endif(WIN32) 123 | 124 | add_subdirectory(Buffers) 125 | add_subdirectory(cudaSirecon) 126 | 127 | -------------------------------------------------------------------------------- /IVE/win32/INCLUDE/IM.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IM_H 2 | #define UCSF_MSG_IM_H 3 | 4 | /* @(#) $Id: IM.h,v 1.2 2002/01/18 00:24:43 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * Provides function prototypes for IM functions. 8 | */ 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | int IMOpen(int istream, const char* name, const char* attrib); 15 | void IMClose(int istream); 16 | int IMUnit(int istream); 17 | void IMRdHdr( 18 | int istream, 19 | int ixyz[3], 20 | int mxyz[3], 21 | int* imode, 22 | float *min, 23 | float *max, 24 | float *mean 25 | ); 26 | void IMWrHdr( 27 | int istream, 28 | const char title[80], 29 | int ntflag, 30 | float dmin, 31 | float dmax, 32 | float dmean 33 | ); 34 | void IMGetExHdr(int istream, void* extended); 35 | void IMGetHdr(int istream, void* header); 36 | void IMPutHdr(int istream, const void* header); 37 | void IMTrHdr(int istream, int jstream); 38 | void IMTrCel(int istream, int jstream); 39 | void IMTrExHdr(int jstream, int istream, int jsec, int isec); 40 | int IMTrFmt(int istream, int jstream); 41 | void IMTrLab(int istream, int jstream); 42 | void IMCrHdr( 43 | int istream, 44 | const int ixyz[3], 45 | const int mxyz[3], 46 | int imode, 47 | const char* labels, 48 | int nl 49 | ); 50 | void IMAlCel(int istream, const float cell[6]); 51 | void IMAlCon(int istream, int flag); 52 | void IMAlDat( 53 | int istream, int itype, int lensnum, int n1, int n2, float v1, float v2 54 | ); 55 | void IMAlDel(int istream, const float delta[3]); 56 | void IMAlDis(int flag); 57 | void IMAlExHdr(int istream, int isec, const int ivals[], const float rvals[]); 58 | void IMAlExHdrSize(int istream, int nints, int nreals, int nsecs); 59 | void IMAlExHdrZWT( 60 | int istream, int iz, int iw, int it, const int ival[], const float rval[] 61 | ); 62 | void IMAlExt(int istream, const void* extra, int istart, int nextra); 63 | int IMAlFmt(int istream, int iformat); 64 | void IMAlLab(int istream, const char* labels, int nl); 65 | void IMAlMap(int istream, const int mcrs[3]); 66 | void IMAlMode(int istream, int imode); 67 | void IMAlOrig(int istream, float xorig, float yorig, float zorig); 68 | void IMAlPrt(int flag); 69 | void IMAlRes(int istream, int mres, int mzfact); 70 | void IMAlSam(int istream, const int mxyz[3]); 71 | void IMAlSiz(int istream, const int inxyz[3], const int nxyzst[3]); 72 | void IMAlSpg(int istream, int nspg, int mbsym); 73 | void IMAlSym(int istream, int mbsym, const void* jbsym); 74 | void IMAlTlt(int istream, const float vals[3]); 75 | void IMAlTltRot(int istream, const float vals[3]); 76 | void IMAlTSt(int istream, int itst); 77 | void IMAlWav(int istream, int nwave, const float wavelen[]); 78 | void IMAlWavMM(int istream, int nwave, float dmin, float dmax); 79 | void IMAlZWT(int istream,int nz, int nw, int nt, int wflag); 80 | void IMRtCel(int istream, float cell[6]); 81 | void IMRtDat( 82 | int istream, 83 | int* itype, 84 | int* lensnum, 85 | int* n1, 86 | int* n2, 87 | float* v1, 88 | float* v2 89 | ); 90 | void IMRtDel(int istream, float delta[3]); 91 | void IMRtExHdr(int istream, int jsec, int ivals[], float rvals[]); 92 | void IMRtExHdrSize(int istream, int* nints, int* nreals); 93 | void IMRtExHdrZWT( 94 | int istream, int iz, int iw, int it, int ival[], float rval[] 95 | ); 96 | void IMRtExt(int istream, void* extra, int istart, int nextra); 97 | void IMRtFmt(int istream, int* iformat); 98 | void IMRtLab(int istream, char labels[20][80], int* nlabels); 99 | void IMRtMap(int istream, int mcrs[3]); 100 | void IMRtMode(int istream, int* mode); 101 | void IMRtMst(int istream, int nxyzst[3]); 102 | void IMRtOrig(int istream, float* xorig, float* yorig, float* zorig); 103 | void IMRtRes(int istream, int* mres, int* mzfact); 104 | void IMRtResInfo( 105 | int istream, int* nx, int* ny, int* nz, int* mxyfact, int* mzfact 106 | ); 107 | void IMRtSam(int istream, int mxyz[3]); 108 | void IMRtSiz(int istream, int inxyz[3], int mxyz[3], int nxyzst[3]); 109 | void IMRtSpg(int istream, int* nspg, int* mbsym); 110 | int IMRtStream(int wid); 111 | void IMRtSym(int istream, int* mbsym, void* jbsym); 112 | void IMRtTlt(int istream, float tilt[3]); 113 | void IMRtTSt(int istream, int* itst); 114 | void IMRtWav(int istream, int* nwave, float wavelen[]); 115 | void IMRtWavMM(int istream, int iwave, float* dmin, float* dmax); 116 | int IMRtWID(int istream); 117 | void IMRtZWT(int istream, int* nz, int* nw, int* nt, int* wflag); 118 | int IMPosn(int istream, int iz, int iy); 119 | int IMPosnRes(int istream, int ires); 120 | int IMPosnZWT(int istream, int iz, int iw, int it); 121 | void IMRdLin(int istream, void* array); 122 | void IMRdPal(int istream, void* array, const int* nx1, const int* nx2); 123 | void IMRdPas( 124 | int istream, 125 | void* array, 126 | int mx, 127 | int my, 128 | int nx1, 129 | int nx2, 130 | int ny1, 131 | int ny2 132 | ); 133 | void IMRdSec(int istream, void* array); 134 | void IMRdSecl(int istream, void* array, const int* mlines); 135 | void IMWrLin(int istream, const void* array); 136 | void IMWrPal(int istream, const void* array, int nx1, int nx2); 137 | void IMWrPas( 138 | int istream, 139 | const void* array, 140 | int mx, 141 | int my, 142 | int nx1, 143 | int nx2, 144 | int ny1, 145 | int ny2 146 | ); 147 | void IMWrSec(int istream, const void* array); 148 | void IMWrSecl(int istream, const void* array, int mlines); 149 | void IMClLim(int istream, int xyzmin[3], int xyzmax[3], int mxyz[3]); 150 | void IMFixExHdr(int istream, int izst, int izend, int izskip, int iflag); 151 | void IMFixExHdrZWT( 152 | int istream, 153 | int izst, 154 | int izend, 155 | int nwt, 156 | const int iwtable[], 157 | int itst, 158 | int itend, 159 | int itinc, 160 | int iflag 161 | ); 162 | void IMCalcDen( 163 | const float* array, 164 | int mx, 165 | int my, 166 | int nx1, 167 | int nx2, 168 | int ny1, 169 | int ny2, 170 | float* dmin, 171 | float* dmax, 172 | float* dmean 173 | ); 174 | void IMInterp( 175 | const float* array_a, 176 | float* array_b, 177 | int nxa, 178 | int nya, 179 | int nxb, 180 | int nyb, 181 | const float* amat, 182 | float xc, 183 | float yc, 184 | float xt, 185 | float yt, 186 | float scale 187 | ); 188 | 189 | /***** new calls added by api *****/ 190 | int IMRtExHdrType( 191 | int iStreamNum, int* iExtHeaderType, int* iNumInts, int* iNumFloats 192 | ); 193 | int IMRtExHdrValueZWT( 194 | int iStreamNum, int iZ, int iW, int iT, int iField, double* dValue 195 | ); 196 | int IMAlExHdrValueZWT( 197 | int iStreamNum, int iZ, int iW, int iT, int iField, double dValue 198 | ); 199 | int IMTrExHdr2( 200 | int iOutStream, 201 | int iInStream, 202 | int iz1, 203 | int iz2, 204 | int izinc, 205 | const int iProcWaveTable[IW_MAX_WAVE], 206 | int it1, 207 | int it2, 208 | int itinc 209 | ); 210 | int IMRtZWTNum(int iStream, int* iz, int* iw, int* it, int iSecNum); 211 | int IMRtSecNum(int iStream, int iz, int iw, int it, int* iSecNum); 212 | 213 | 214 | #ifdef __cplusplus 215 | } 216 | #endif 217 | 218 | #endif /* include guard */ 219 | -------------------------------------------------------------------------------- /IVE/win32/INCLUDE/IMInclude.h: -------------------------------------------------------------------------------- 1 | #ifndef USCF_MSG_IMINCLUDE_H 2 | #define UCSF_MSG_IMINCLUDE_H 3 | 4 | /* @(#)$Id: IMInclude.h,v 1.1 2001/08/09 23:20:42 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * This includes all definitions and functions needed by applications using 8 | * just the IM routines. 9 | */ 10 | 11 | #include "IWApiConstants.h" 12 | #include "IM.h" 13 | 14 | #endif /* include guard */ 15 | -------------------------------------------------------------------------------- /IVE/win32/INCLUDE/IWApiConstants.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IWAPICONSTANTS_H 2 | #define UCSF_MSG_IWAPICONSTANTS_H 3 | 4 | /* @(#) $Id: IWApiConstants.h,v 1.9 2009/11/10 01:06:52 eric Exp $ */ 5 | /* $Name: $ */ 6 | /*----------------------------------------------------------------------------- 7 | Copyright (C) 1993 8 | Macromolecular Structure Group of Biochemistry Dept. at University of 9 | California at San Francisco. 10 | These coded instructions, statements, and computer programs comprise 11 | unpublished proprietary information of the Macromolecular Structure Group of 12 | the Biochemistry Department at University of California at San Francisco, 13 | and are protected by Federal copyright law. They may not be disclosed 14 | to third parties, copied or duplicated in any form - in whole or in part - 15 | without the prior written consent of Macromolecular Structure Group of 16 | Biochemistry Department at University of California at San Francisco. 17 | -------------------------------------------------------------------------*/ 18 | 19 | #define IW_SUCCESS 1 20 | #define IW_FAILURE 0 21 | #define IW_ERROR -1 22 | 23 | /* Constants for designating bank channels. */ 24 | #define IW_EMPTY -1 25 | #define IW_ALL_WINDOWS -1 26 | #define IW_ALL_BANKS -1 27 | #define IW_MAX_BANK 5 28 | #define IW_ALL_WAVES -1 29 | #define IW_WAVE1 0 30 | #define IW_WAVE2 1 31 | #define IW_WAVE3 2 32 | #define IW_WAVE4 3 33 | #define IW_WAVE5 4 34 | #define IW_MAX_WAVE 5 35 | 36 | /* for IMWLapply_to_wave */ 37 | #define IW_APPLY_SYNC 0 38 | #define IW_APPLY_NONE 1 39 | #define IW_APPLY_ALL 2 40 | 41 | /* Constants for specifing color */ 42 | #define IW_PSEUDO 1 43 | #define IW_TRUE_COLOR 0 44 | #define IW_COLOR_NAME_LEN 12 45 | #define IW_NUM_TRUE_COLOR 7 46 | 47 | #define IW_BLACK 0 48 | #define IW_RED 1 49 | #define IW_GREEN 2 50 | #define IW_YELLOW (IW_RED + IW_GREEN) 51 | #define IW_BLUE 4 52 | #define IW_PINK (IW_RED + IW_BLUE) 53 | #define IW_CYAN (IW_GREEN + IW_BLUE) 54 | #define IW_WHITE (IW_RED + IW_GREEN + IW_BLUE) 55 | #define IW_SANDY_BROWN 8 56 | #define IW_BROWN 9 57 | #define IW_LT_GREY 10 58 | #define IW_PURPLE 11 59 | #define IW_INVISIBLE 12 60 | #define IW_NUM_COLORS 12 61 | 62 | /* Data Types. */ 63 | #define IW_AS_IS -1 64 | #define IW_BYTE 0 65 | #define IW_SHORT 1 66 | #define IW_FLOAT 2 67 | #define IW_COMPLEX_SHORT 3 68 | #define IW_COMPLEX 4 69 | #define IW_EMTOM 5 70 | #define IW_USHORT 6 71 | #define IW_LONG 7 72 | 73 | /* 74 | * Possible values for the file type (see IMAlDat and IMRtDat). These 75 | * are new in IVE 4; previous versions referred to them directly by number. 76 | * IM_MULTIPOSITION was added in IVE 4.1.0; IM_PUPIL_FUNCTION was added in 77 | * IVE 4.1.8. 78 | */ 79 | #define IM_NORMAL_IMAGES 0 80 | #define IM_TILT_SERIES 1 81 | #define IM_STEREO_TILT_SERIES 2 82 | #define IM_AVERAGED_IMAGES 3 83 | #define IM_AVERAGED_STEREO_PAIRS 4 84 | #define IM_EM_TILT_SERIES 5 85 | #define IM_MULTIPOSITION 20 86 | #define IM_PUPIL_FUNCTION 8000 87 | 88 | /* Monitor Matrix Display Layout Format */ 89 | #define TEXT_FMT 1 90 | #define DATA_FMT 0 91 | 92 | /* 93 | Monitor window decoration style (for IWAlDisWinBdr, IWRtDisWinBdr). 94 | Full border includes the title bar and the resize handles. The resize 95 | border only has the resize handles. Windows without borders have 96 | no window manager decorations. 97 | */ 98 | #define IW_MON_FULL_BRDR 0 99 | #define IW_MON_RESIZE_BRDR 1 100 | #define IW_MON_NO_BRDR 2 101 | 102 | /* 103 | Monitor menu/toolbar display style (for IWAlDisWinTool, IWRtDisWinTool). 104 | No menus or tools are shown with IW_MON_NO_MENU_TOOLS. The other constants 105 | can be combined as a bitwise or to flag what will be shown. 106 | */ 107 | #define IW_MON_NO_MENU_TOOLS 0 108 | #define IW_MON_SHOW_MENU 1 109 | #define IW_MON_SHOW_LEFTTOOLS 2 110 | #define IW_MON_ALL_MENU_TOOLS 3 111 | 112 | #define IW_MIN_WIN_SIZE 128 113 | #define IW_MAX_WIN_SIZE 1024 114 | 115 | 116 | /* 117 | * Specify which buffers to read out for IWCaptureImage. 118 | */ 119 | #define IW_LEFT_IMAGE 1 120 | #define IW_RIGHT_IMAGE 2 121 | #define IW_NORMAL_IMAGE 3 122 | 123 | /* 124 | * Specify which format to use for each pixel in the result of IWCaptureImage. 125 | */ 126 | #define IW_RGBA_PIXEL 0 127 | #define IW_LUMINANCE_PIXEL 1 128 | 129 | 130 | typedef struct IW_MRC_Header { 131 | int nx,ny,nz; /* nz : nfocal*nwave*ntime */ 132 | int mode; 133 | int nxst, nyst, nzst; 134 | int mx, my, mz; 135 | float xlen, ylen, zlen; 136 | float alpha, beta, gamma; 137 | int mapc, mapr, maps; 138 | float amin, amax, amean; 139 | int ispg, inbsym; 140 | 141 | short nDVID,nblank; /* CB: nDVID value. nblank preserves byte boundary */ 142 | int ntst; /* Hans: add ntst to record time domain offset */ 143 | char ibyte[24]; 144 | short nint,nreal; 145 | short nres,nzfact; 146 | float min2,max2,min3,max3,min4,max4; 147 | short file_type, lens, n1, n2, v1, v2; /* From daa2:[agard.image]imsubs.for*/ 148 | /*file_type = idtype*/ 149 | float min5,max5; 150 | short num_times; 151 | short interleaved; /* Zero => not interleaved. That means z changes 152 | fastest, then time, then waves; 153 | 1 => interleaved. That means wave changes fastest, 154 | then z, then time. */ 155 | float tilt_x, tilt_y, tilt_z; 156 | short num_waves, iwav1, iwav2, iwav3, iwav4, iwav5; 157 | float zorig, xorig, yorig; 158 | int nlab; 159 | char label[800]; 160 | } IW_MRC_HEADER, *IW_MRC_HEADER_PTR; 161 | 162 | typedef struct IW_complex { 163 | float real; 164 | float imaginary; 165 | } IW_COMPLEX_VALUE, *IW_COMPLEX_PTR; 166 | 167 | /* for IMWLcomplex_disp */ 168 | #define IW_COMPLEX_AMPLITUDE 0x00010000 169 | #define IW_COMPLEX_REAL 0x00020000 170 | #define IW_COMPLEX_IMAGINARY 0x00030000 171 | #define IW_COMPLEX_PHASE 0x00040000 172 | 173 | /* 174 | * Used to define accuracy for scaling done in IWScaleImage. 175 | * IW_SCALING_DONTCARE is the default - exact for byte and short 176 | * types but increasingly inaccurate for floating point data as 177 | * the exponent gets farther away from 1. IW_SCALING_EXACT is 178 | * exact for all types (but generally involves a performance penalty). 179 | */ 180 | #define IW_SCALING_DONTCARE 0x00000000 181 | #define IW_SCALING_EXACT 0x01000000 182 | 183 | typedef unsigned char *IW_BYTE_MEM_PTR; 184 | typedef short *IW_SHORT_MEM_PTR; 185 | typedef float *IW_FLOAT_MEM_PTR; 186 | 187 | #define IW_SAVE_BUF (1 << 0) 188 | #define IW_BUF_CREATED (1 << 1) 189 | #define IW_IMG_CREATED (1 << 2) 190 | 191 | #define IW_WIN_CREATED 680 /* MAGIC NUMBER */ 192 | #define IW_WIN_KILLED 681 /* MAGIC NUMBER */ 193 | #define IW_BANK_DISPLAYED 689 /* MAGIC NUMBER */ 194 | #define IW_BANK_DISPLAY_CHANGED 690 /* MAGIC NUMBER */ 195 | #define IW_BANK_KILLED 691 /* MAGIC NUMBER */ 196 | #define IW_WINDOW_GEO_CHANGED 692 /* MAGIC NUMBER */ 197 | #define IW_WIN_GR_KILLED 693 /* MAGIC NUMBER */ 198 | #define IW_WAVE_GR_KILLED 694 /* MAGIC NUMBER */ 199 | 200 | /* Macro Function Names */ 201 | #define IW_MAX(x,y) ((x > y) ? x : y) 202 | #define IW_MIN(x,y) ((x > y) ? y : x) 203 | #define IW_ABS(x) ((x > 0) ? x : -x) 204 | 205 | typedef float IW_VECTOR[3]; 206 | typedef float *IW_VECTOR_PTR; 207 | typedef IW_VECTOR IW_MATRIX[3]; 208 | typedef IW_VECTOR *IW_MATRIX_PTR; 209 | 210 | typedef int IW_INT_VECTOR[3]; 211 | typedef int *IW_INT_VECTOR_PTR; 212 | typedef IW_INT_VECTOR IW_INT_MATRIX[3]; 213 | typedef IW_INT_VECTOR *IW_INT_MATRIX_PTR; 214 | 215 | /* 216 | * Define indices into the ClientMessage data.s array for Monitor display 217 | * change events. Use 2 and 5 for backward compatibility. 218 | */ 219 | #define IW_CM_WIN_ID 2 220 | #define IW_CM_CHANGE_OR_SYN 5 /* type of change */ 221 | 222 | #define GW_ATTEND 0 223 | #define GW_ATTACH 1 224 | #define GW_DEATTACH 2 225 | #define GW_DELETEGR 3 226 | 227 | /* Extended header definitions -- new additions */ 228 | 229 | #define UNKNOWN_EXT_HEADER_TYPE 0 230 | #define UCSF_EXT_HEADER_TYPE1 1 231 | #define API_EXT_HEADER_TYPE1 2 232 | #define API_EXT_HEADER_TYPE2 3 233 | #define UCSF_EXT_HEADER_TYPE2 4 234 | 235 | #define UCSF_EXT_HDR_1_NINTS 1 236 | #define UCSF_EXT_HDR_1_NFLOATS 1 237 | #define UCSF_EXT_HDR_2_NINTS 3 238 | #define UCSF_EXT_HDR_2_NFLOATS 1 239 | #define API_EXT_HDR_1_NINTS 0 240 | #define API_EXT_HDR_1_NFLOATS 2 241 | #define API_EXT_HDR_2_NINTS 8 242 | #define API_EXT_HDR_2_NFLOATS 32 243 | 244 | /* NB: use of these values as array indices for the floating-point */ 245 | /* part of the extended header is a temporary KLUGE. */ 246 | /* WHEN APPLYING THIS KLUGE IN FORTRAN, 1 MUST BE ADDED TO VALUE IN CODE! */ 247 | #define PHOTOSENSOR_READING 0 248 | #define TIME_STAMP_SECS 1 249 | #define STAGE_X_COORD 2 250 | #define STAGE_Y_COORD 3 251 | #define STAGE_Z_COORD 4 252 | #define MIN_INTEN 5 253 | #define MAX_INTEN 6 254 | #define MEAN_INTEN 7 255 | #define EXP_TIME 8 256 | #define ND_FILTER 9 257 | #define EX_WAVELEN 10 258 | #define EM_WAVELEN 11 259 | #define INTEN_SCALING 12 260 | #define ENERGY_CONV_FACTOR 13 261 | #define PHOTOSENSOR_NCONV 14 262 | 263 | /* array indices for extended header integer values */ 264 | #define PHOTOMETRIC_INTERP_INT 0 /*0=white is zero,1=black is zero,2=RGB,3=palette,4=transparency (same as TIFF)*/ 265 | 266 | /* code values for wavelength */ 267 | #define RATIO_IMAGE_WAVELENGTH 10 268 | #define PRODUCT_IMAGE_WAVELENGTH 20 269 | #define ADDITION_IMAGE_WAVELENGTH 30 270 | #define SUBTRACTION_IMAGE_WAVELENGTH 40 271 | #define DIC_IMAGE_WAVELENGTH 50 272 | #define PHASE_IMAGE_WAVELENGTH 60 273 | #define BLEND_IMAGE_WAVELENGTH 70 274 | 275 | 276 | /* image sequence definitions */ 277 | #define ZTW_SEQUENCE 0 /* "non-interleaved", by defintion */ 278 | #define WZT_SEQUENCE 1 /* "interleaved", from R3D and others */ 279 | #define ZWT_SEQUENCE 2 /* new sequence. Unsupported as of 11/97 */ 280 | 281 | #endif /* include guard */ 282 | -------------------------------------------------------------------------------- /IVE/win32/INCLUDE/cxxstd.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_CXXSTD_H 2 | #define UCSF_MSG_CXXSTD_H 3 | 4 | // @(#) $Id: cxxstd.h,v 1.2 2008/04/15 03:09:29 eric Exp $ 5 | // $Name: $ 6 | // Defines macros so code can conditionally compile stuff that depends 7 | // on whether or not the standard C++ headers (no .h) and namespace are 8 | // available. If HAS_STDCXX is set, the compiler, at least, provides the 9 | // standard C++ headers which are not the standard C headers wrapped in the 10 | // std namespace. If HAS_STDCXX_C is set, the compiler provides the 11 | // standard C headers wrapped in the std namespace. 12 | 13 | #ifdef __sgi 14 | #ifdef _STANDARD_C_PLUS_PLUS 15 | #define HAS_STDCXX 16 | #define HAS_STDCXX_C 17 | #endif 18 | #else 19 | #define HAS_STDCXX 20 | // Version 3.2-3 of pgCC does not include the C headers wrapped in the std 21 | // namespace. Do not know whether other versions of the Portland Group 22 | // compiler do. 23 | #ifndef __PGI 24 | #define HAS_STDCXX_C 25 | #endif 26 | #endif 27 | 28 | #ifdef HAS_STDCXX 29 | #define STDNAMESPACE(x) std::x 30 | #else 31 | #define STDNAMESPACE(x) ::x 32 | #endif 33 | 34 | #ifdef HAS_STDCXX_C 35 | #define STDNAMESPACE_C(x) std::x 36 | #else 37 | #define STDNAMESPACE_C(x) ::x 38 | #endif 39 | 40 | #endif /* include guard */ 41 | -------------------------------------------------------------------------------- /IVE/win32/INCLUDE/exhdr.inc: -------------------------------------------------------------------------------- 1 | C @(#) $Id: exhdr.inc,v 1.1 2001/08/09 23:20:47 eric Exp $ 2 | C $Name: $ 3 | integer*4 I_PHOTOSENSOR_READING 4 | parameter (I_PHOTOSENSOR_READING = 0) 5 | integer*4 I_TIME_STAMP_SECS 6 | parameter (I_TIME_STAMP_SECS = 1) 7 | integer*4 I_STAGE_X_COORD 8 | parameter (I_STAGE_X_COORD = 2) 9 | integer*4 I_STAGE_Y_COORD 10 | parameter (I_STAGE_Y_COORD = 3) 11 | integer*4 I_STAGE_Z_COORD 12 | parameter (I_STAGE_Z_COORD = 4) 13 | integer*4 I_MIN_INTEN 14 | parameter (I_MIN_INTEN = 5) 15 | integer*4 I_MAX_INTEN 16 | parameter (I_MAX_INTEN = 6) 17 | integer*4 I_MEAN_INTEN 18 | parameter (I_MEAN_INTEN = 7) 19 | integer*4 I_EXP_TIME 20 | parameter (I_EXP_TIME = 8) 21 | integer*4 I_ND_FILTER 22 | parameter (I_ND_FILTER = 9) 23 | integer*4 I_EX_WAVELEN 24 | parameter (I_EX_WAVELEN = 10) 25 | integer*4 I_EM_WAVELEN 26 | parameter (I_EM_WAVELEN = 11) 27 | integer*4 I_INTEN_SCALING 28 | parameter (I_INTEN_SCALING = 12) 29 | integer*4 I_ENERGY_CONV_FACTOR 30 | parameter (I_ENERGY_CONV_FACTOR = 13) 31 | integer*4 I_PHOTOSENSOR_NCONV 32 | parameter (I_PHOTOSENSOR_NCONV = 14) 33 | -------------------------------------------------------------------------------- /IVE/win32/INCLUDE/fortran_types.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_FORTRAN_TYPES_H 2 | #define UCSF_MSG_FORTRAN_TYPES_H 3 | 4 | /* @(#) $Id: fortran_types.h,v 1.1.1.1 2001/07/12 23:12:59 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * Define types for interfaces between Fortran and C/C++ code. 8 | */ 9 | 10 | 11 | #include "ive_conf.h" 12 | 13 | #ifdef FTN_INT_TYPE 14 | typedef FTN_INT_TYPE ftn_int_t; 15 | #endif /* FTN_INT_TYPE */ 16 | 17 | #ifdef FTN_REAL_TYPE 18 | typedef FTN_REAL_TYPE ftn_real_t; 19 | typedef struct ftn_cmplx_t { ftn_real_t real, imag; } ftn_cmplx_t; 20 | #endif /* FTN_REAL_TYPE */ 21 | 22 | #ifdef FTN_DOUBLE_TYPE 23 | typedef FTN_DOUBLE_TYPE ftn_double_t; 24 | typedef struct ftn_dcmplx_t { ftn_double_t real, imag; } ftn_dcmplx_t; 25 | #endif /* FTN_DOUBLE_TYPE */ 26 | 27 | #ifdef FTN_CHAR_TYPE 28 | typedef FTN_CHAR_TYPE ftn_char_t; 29 | #endif /* FTN_CHAR_TYPE */ 30 | 31 | /* 32 | * The type used to represent the lengths of character arrays when passed 33 | * as arguments. 34 | */ 35 | #ifdef FTN_LENGTH_TYPE 36 | typedef FTN_LENGTH_TYPE ftn_length_t; 37 | #endif /* FTN_LENGTH_TYPE */ 38 | 39 | #ifdef FTN_LOGICAL_TYPE 40 | typedef FTN_LOGICAL_TYPE ftn_logical_t; 41 | #endif /* FTN_LOGICAL_TYPE */ 42 | #undef FTN_IS_FALSE 43 | #ifdef FTN_FALSE_IS_ZERO 44 | #define FTN_IS_FALSE(x) ((x) == 0) 45 | #endif /* FTN_FALSE_IS_ZERO */ 46 | #ifdef FTN_FALSE_LOW_BIT_ZERO 47 | #define FTN_IS_FALSE(x) (((x) & 1) == 0) 48 | #endif /* FTN_FALSE_LOW_BIT_ZERO */ 49 | 50 | #endif /* include guard */ 51 | -------------------------------------------------------------------------------- /IVE/win32/INCLUDE/ive_conf.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IVE_CONF_H 2 | #define UCSF_MSG_IVE_CONF_H 3 | 4 | /* @(#) Generated from $Id: ive_conf.h_m4,v 1.22 2012/06/02 03:14:19 eric Exp $ with genus = win32 and IVE_SHM64 = */ 5 | /* $Name: $ */ 6 | /* 7 | * Copyright(C) 2001 8 | * Macromolecular Structure Group of the Biochemistry Department at the 9 | * University of California, San Francisco 10 | */ 11 | /* 12 | * Set the macros controlling platform-specific behavior and conditional 13 | * compilation. Define typedefs for fixed-size types. 14 | */ 15 | 16 | 17 | /* 18 | * Clear any outside settings. 19 | */ 20 | #undef IVECONF_XOPEN 21 | #undef IVECONF_BSD 22 | #undef IVECONF_WIN32 23 | #undef IVECONF_PTHREAD 24 | #undef IVECONF_DEFINES_ETIMEDOUT 25 | #undef IVECONF_DEFINES_ELOOP 26 | #undef IVECONF_DEFINES_EOVERFLOW 27 | #undef IVECONF_DEFINES_SEMUN 28 | #undef IVECONF_DEFINES_MAP_FAILED 29 | #undef IVECONF_POSIX_NAMED_SEM_IN_FS 30 | #undef IVECONF_NO_SEM_GETVALUE 31 | #undef IVECONF_UNIMPL_SEM_GETVALUE 32 | #undef IVECONF_SHM64 33 | #undef IVECONF_SHMMUTEX_USE_PTHREAD 34 | #undef IVECONF_SHMMUTEX_USE_SYSVSEM 35 | #undef IVECONF_SHMMUTEX_USE_FCNTL 36 | #undef IVECONF_SHMHOLD_USE_SYSVSEM 37 | #undef IVECONF_SHMHOLD_USE_FCNTL 38 | #undef IVECONF_SHMRWLK_USE_PTHREAD 39 | #undef IVECONF_SHMRWLK_USE_SYSVSEM 40 | #undef IVECONF_SHMRWLK_USE_FCNTL 41 | #undef IVECONF_SHMSEM_USE_POSIXUNNAMED 42 | #undef IVECONF_SHMSEM_USE_POSIXNAMED 43 | #undef IVECONF_SHMSEM_USE_SYSVSEM 44 | #undef IVECONF_SHMSEM_USE_CYGWIN_HACK 45 | #undef IVECONF_HAS_O_SYNC 46 | #undef IVECONF_HAS_SIGINFO 47 | #undef IVECONF_HAS_VSNPRINTF 48 | #undef IVECONF_USE_ISNANF 49 | #undef IVECONF_FINITE_IN_IEEEFP_H 50 | #undef IVECONF_INTTYPES_SYSTYPES_CLASH 51 | #undef IVECONF_HAS_DLOPEN 52 | #undef IVECONF_HAS_RTLD_LOCAL 53 | #undef IVECONF_HAS_NSMODULE 54 | #undef IVECONF_NO_INTTYPES 55 | #undef IVECONF_CLOSE_BEFORE_REMOVE 56 | #undef IVECONF_HAS_IPV6 57 | #undef IVECONF_HAS_UNSIGNED_TIME_T 58 | #undef IVECONF_NPROC_SYSCONF_NPROCESSORS_ONLN 59 | #undef IVECONF_NPROC_SYSCONF_NPROC_ONLN 60 | #undef IVECONF_NPROC_SYSCTL 61 | #undef IVECONF_HAS_STATVFS 62 | #undef IVECONF_HAS_STATVFS64 63 | #undef IVECONF_HAS_STATFS 64 | #undef IVECONF_STATFS_REQUIRES_PARAM_H 65 | #undef IVECONF_STATFS_REQUIRES_MOUNT_H 66 | #undef IVECONF_STATFS_REQUIRES_VFS_H 67 | #undef IVECONF_STATFS_REQUIRES_STATFS_H 68 | #undef IVECONF_STATFS_AVAIL_FIELD 69 | #undef IVECONF_HAS_NSGETEXECUTABLEPATH 70 | #undef IVECONF_HAS_PROCSELF 71 | #undef IVECONF_HAS_PATH_DEFPATH 72 | #undef IVECONF_DEFAULT_PATH 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | /* 92 | * Win32 or Win64 93 | */ 94 | /* Supplies some Posix-like functions in the CRT library */ 95 | #define IVECONF_WIN32 96 | #ifdef _MSC_VER 97 | typedef __int8 int8_t; 98 | typedef __int16 int16_t; 99 | typedef __int32 int32_t; 100 | typedef unsigned __int8 uint8_t; 101 | typedef unsigned __int16 uint16_t; 102 | typedef unsigned __int32 uint32_t; 103 | typedef float float32_t; 104 | typedef double float64_t; 105 | #elif defined(__GNUC__) 106 | #include 107 | typedef float float32_t; 108 | typedef double float64_t; 109 | #endif 110 | 111 | 112 | #if defined(IVECONF_XOPEN) || defined(IVECONF_BSD) 113 | typedef int IVEDesc; 114 | #ifndef IVECONF_NO_INTTYPES 115 | #ifdef IVECONF_INTTYPES_SYSTYPES_CLASH 116 | /* 117 | * A kludge for IRIX 5.3 where both inttypes.h and sys/types.h define int8_t. 118 | * int16_t, and int32_t 119 | */ 120 | #include 121 | typedef unsigned char uint8_t; 122 | typedef unsigned short uint16_t; 123 | typedef unsigned int uint32_t; 124 | #else 125 | #include 126 | #endif 127 | #endif 128 | /* 129 | * If available, use pthreads as the threading package. 130 | */ 131 | #include 132 | #ifdef _POSIX_THREADS 133 | #define IVECONF_PTHREAD 134 | #endif /* _POSIX_THREADS */ 135 | #endif /* IVECONF_XOPEN || IVECONF_BSD */ 136 | 137 | #endif /* include guard */ 138 | -------------------------------------------------------------------------------- /IVE/win32/INCLUDE/ive_error.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IVE_ERROR_H 2 | #define UCSF_MSG_IVE_ERROR_H 3 | 4 | /* @(#) $Id: ive_error.h,v 1.3 2007/09/24 17:48:36 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * Copyright(C) 2001 8 | * Macromolecular Structure Group of the Biochemistry Department at the 9 | * University of California, San Francisco 10 | */ 11 | /* 12 | * Declares error constants and error handling functions. 13 | */ 14 | 15 | 16 | enum { 17 | IVE_ERR_NONE = 0 18 | 19 | /* Runtime conditions */ 20 | , IVE_ERR_NO_MEM = 1 21 | , IVE_ERR_NO_SPC = 2 22 | , IVE_ERR_NO_RESOURCES = 3 23 | , IVE_ERR_IN_USE = 10 24 | , IVE_ERR_TIMEOUT = 11 25 | , IVE_ERR_IO = 20 26 | , IVE_ERR_NO_PERMISSION = 30 27 | , IVE_ERR_EXIST = 31 28 | , IVE_ERR_OVERFLOW = 40 29 | , IVE_ERR_UNSUPPORTED = 50 30 | 31 | /* Problems with passed arguments */ 32 | , IVE_ERR_INVALID = 512 33 | , IVE_ERR_BAD_FILENAME = 513 34 | 35 | /* Miscellaneous */ 36 | , IVE_ERR_CORRUPT = 1024 37 | , IVE_ERR_INTERNAL = 1025 38 | , IVE_ERR_UNRECOGNIZED = 1280 39 | }; 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | 45 | void IVEErrorToString(int code, int max_length, char* str, int* p_full_length); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif /* __cplusplus */ 50 | 51 | #endif /* include guard */ 52 | -------------------------------------------------------------------------------- /IVE/win32/INCLUDE/ive_fortran.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IVE_FORTRAN_H 2 | #define UCSF_MSG_IVE_FORTRAN_H 3 | 4 | /* @(#) $Id: ive_fortran.h,v 1.3 2007/09/24 17:48:38 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * Copyright(C) 2001 8 | * Macromolecular Structure Group of the Biochemistry Department at the 9 | * University of California, San Francisco 10 | */ 11 | /* 12 | * Declare functions for use in writing Fortran wrappers for C. 13 | */ 14 | 15 | 16 | #include "fortran_types.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif /* __cplusplus */ 21 | 22 | /* 23 | * Result should be freed with free. 24 | */ 25 | char* IVEFtnStringToCString(const ftn_char_t* fstr, ftn_length_t flength); 26 | 27 | void IVECStringToFtnString( 28 | const char* cstr, ftn_length_t flength, ftn_char_t* fstr 29 | ); 30 | 31 | ftn_int_t IVEPtrToFtnId(void* ptr); 32 | 33 | void* IVEFtnIdToPtr(ftn_int_t id); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif /* __cplusplus */ 38 | 39 | #endif /* include guard */ 40 | -------------------------------------------------------------------------------- /IVE/win32/INCLUDE/ive_hash.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IVE_HASH_H 2 | #define UCSF_MSG_IVE_HASH_H 3 | 4 | /* @(#) $Id: ive_hash.h,v 1.2 2007/09/24 17:48:38 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * Copyright(C) 2001 8 | * Macromolecular Structure Group of the Biochemistry Department at the 9 | * University of California, San Francisco 10 | */ 11 | /* 12 | * Declare a utility function for hashing arbitrary data to an integer 13 | * value. hash_size (the possible range of values for the hash is 0 to 14 | * hash_size - 1) is restricted to be a power of 2. 15 | */ 16 | 17 | 18 | #include "ive_conf.h" 19 | 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif /* __cplusplus */ 24 | 25 | int IVEHash(const uint8_t* data, uint32_t length, int hash_size); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif /* __cplusplus */ 30 | 31 | #endif /* include guard */ 32 | -------------------------------------------------------------------------------- /IVE/win32/INCLUDE/ive_standards.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IVE_STANDARDS_H 2 | #define UCSF_MSG_IVE_STANDARDS_H 3 | 4 | /* @(#) Generated from $Id: ive_standards.h_m4,v 1.8 2012/06/02 03:10:06 eric Exp $ with genus = win32 */ 5 | /* $Name */ 6 | /* 7 | * Copyright(C) 2002 8 | * Macromolecular Structure Group of the Biochemistry Department at the 9 | * University of California, San Francisco 10 | */ 11 | /* 12 | * Sets feature-set macros to ensure that the system headers define 13 | * the needed functions and types. Doing so after including one or more 14 | * system and then including other system headers may cause inconsistent 15 | * definitions: always include this header first! As a consequence of this, 16 | * do not use constructs (i.e. typedefs of system types) which depend on the 17 | * inclusion of this header unless the user is made aware of the side effects. 18 | */ 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | /* 36 | * Nothing is done for Win32 or Win64. 37 | */ 38 | 39 | 40 | #endif /* include guard */ 41 | -------------------------------------------------------------------------------- /IVE/win32/INCLUDE/ive_thread.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IVE_THREAD_H 2 | #define UCSF_MSG_IVE_THREAD_H 3 | 4 | /* @(#) $Id: ive_thread.h,v 1.5 2008/04/07 22:29:18 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * Copyright(C) 2001 8 | * Macromolecular Structure Group of the Biochemistry Department at the 9 | * University of California, San Francisco 10 | */ 11 | /* 12 | * Declare types and functions for making the library thread-safe. 13 | * These functions do nothing unless you link against the thread-safe 14 | * library and define IVE_MTSAFE. 15 | */ 16 | 17 | 18 | #include "ive_conf.h" 19 | 20 | 21 | #ifdef IVE_MTSAFE 22 | #ifdef IVECONF_PTHREAD 23 | #include 24 | #define IVE_ONCE_INIT PTHREAD_ONCE_INIT 25 | typedef pthread_once_t IVEThreadOnceFlag; 26 | typedef pthread_key_t IVEThreadKey; 27 | typedef pthread_mutex_t IVEThreadMutex; 28 | #elif defined(IVECONF_WIN32) 29 | #define IVE_ONCE_INIT (0) 30 | typedef PVOID IVEThreadOnceFlag; 31 | typedef DWORD IVEThreadKey; 32 | typedef CRITICAL_SECTION IVEThreadMutex; 33 | #else 34 | #error "Do not know how to define IVEThread types" 35 | #endif /* else clause IVECONF_PTHREAD */ 36 | 37 | #else 38 | #define IVE_ONCE_INIT {0} 39 | typedef struct { int set; } IVEThreadOnceFlag; 40 | struct IVEThreadKeyImpl; 41 | typedef struct IVEThreadKeyImpl* IVEThreadKey; 42 | typedef struct { int dummy; } IVEThreadMutex; 43 | 44 | #endif /* else clause IVE_MTSAFE */ 45 | 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif /* __cplusplus */ 50 | 51 | int IVEThreadCountProcessors(void); 52 | void IVEThreadCallOnce(void (*init_routine)(void), IVEThreadOnceFlag* p_once); 53 | void IVEThreadInitKey(IVEThreadKey* p_key, int* p_status); 54 | void IVEThreadDestroyKey(IVEThreadKey key); 55 | void IVEThreadSetKeyValue(void* value, IVEThreadKey key, int* p_status); 56 | void* IVEThreadGetKeyValue(IVEThreadKey key); 57 | void IVEThreadInitMutex(IVEThreadMutex* p_mutex, int* p_status); 58 | void IVEThreadDestroyMutex(IVEThreadMutex* p_mutex); 59 | void IVEThreadAcquireMutex(IVEThreadMutex* p_mutex); 60 | int IVEThreadTryAcquireMutex(IVEThreadMutex* p_mutex); 61 | void IVEThreadReleaseMutex(IVEThreadMutex* p_mutex); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif /* __cplusplus */ 66 | 67 | #endif /* include guard */ 68 | -------------------------------------------------------------------------------- /IVE/win32/INCLUDE/ive_time.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IVE_TIME_H 2 | #define UCSF_MSG_IVE_TIME_H 3 | 4 | /* @(#) $Id: ive_time.h,v 1.5 2012/06/02 03:04:36 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * Copyright(C) 2001 8 | * Macromolecular Structure Group of the Biochemistry Department at the 9 | * University of California, San Francisco 10 | */ 11 | /* 12 | * Declare types and functions for timing. 13 | */ 14 | 15 | #include "ive_conf.h" 16 | 17 | 18 | #undef IVE_TIME_INTERVAL_MIN 19 | #undef IVE_TIME_INTERVAL_MAX 20 | 21 | 22 | /* 23 | * IVETimeValue is the type used to store a representation of the current time. 24 | * IVETimerInterval is the signed integral type used to store time intervals; 25 | * it must have at least 32 bits. 26 | */ 27 | #if defined(IVECONF_XOPEN) || defined(IVECONF_BSD) 28 | #include 29 | #include 30 | typedef struct timeval IVETimeValue; 31 | typedef int IVETimeInterval; 32 | #define IVE_TIME_INTERVAL_MIN INT_MIN 33 | #define IVE_TIME_INTERVAL_MAX INT_MAX 34 | #elif defined(IVECONF_WIN32) 35 | #include 36 | #include 37 | typedef FILETIME IVETimeValue; 38 | typedef int IVETimeInterval; 39 | #define IVE_TIME_INTERVAL_MIN INT_MIN 40 | #define IVE_TIME_INTERVAL_MAX INT_MAX 41 | #else 42 | #error "Do not know how to define IVETimeValue and IVETimerInterval" 43 | #endif 44 | 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif /* __cplusplus */ 49 | 50 | void IVESleep(IVETimeInterval intvl_us); 51 | void IVEGetCurrTime(IVETimeValue* p_time); 52 | IVETimeInterval IVECalcTimeDiff( 53 | const IVETimeValue* p_t2, const IVETimeValue* p_t1, int* p_status 54 | ); 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif /* __cplusplus */ 59 | 60 | #endif /* include guard */ 61 | -------------------------------------------------------------------------------- /IVE/win32/INCLUDE/kernel/IKInterleave.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IKINTERLEAVE_H 2 | #define UCSF_MSG_IKINTERLEAVE_H 3 | 4 | /* @(#) $Id: IKInterleave.h,v 1.1 2001/08/09 23:20:50 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * These are kernel / monitor helper functions to go back and forth between 8 | * zwt indices and single section index. Other applications should use 9 | * IMRtSecNum and IMRtZWTNum. 10 | */ 11 | 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif /* __cplusplus */ 16 | 17 | /* 18 | * Returns 1 if intlv (the code for how z, waves, and times are interleaved) 19 | * is invalid. Otherwise returns 0 and sets *p_isec to the 1D section index. 20 | * Assumes that nz, nw, and nt are positive integers and that iz, iw, and 21 | * it are non-negative integers less than nz, nw, and nt respectively. 22 | */ 23 | int IKZWT2Sec( 24 | int* p_isec, int iz, int iw, int it, int nz, int nw, int nt, int intlv 25 | ); 26 | 27 | 28 | /* 29 | * Returns 1, if intlv is invalid. Otherwise returns 0 and sets *p_iz, *p_iw, 30 | * *p_it to the z, wave, and time indexes corresponding to isec. Assumes that 31 | * nz, nw, and nt are positive integers and that isec is a non-negative 32 | * integer less than nz * nw * nt. 33 | */ 34 | int IKSec2ZWT( 35 | int* p_iz, 36 | int* p_iw, 37 | int* p_it, 38 | int isec, 39 | int nz, 40 | int nw, 41 | int nt, 42 | int intlv 43 | ); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif /* __cplusplus */ 48 | 49 | #endif /* include guard */ 50 | -------------------------------------------------------------------------------- /IVE/win32/INCLUDE/kernel/IMNetFuncs.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IMNETFUNCS_H 2 | #define UCSF_MSG_IMNETFUNCS_H 3 | 4 | /* @(#) $Id: IMNetFuncs.h,v 1.2 2003/04/03 22:35:09 eric Exp $ */ 5 | /* $Name: $ */ 6 | 7 | #include "ive_conf.h" 8 | #include /* ssize_t */ 9 | 10 | 11 | /* Defines the elements common to all messages */ 12 | typedef struct remote_comm_hdr { 13 | uint32_t type; 14 | uint32_t size; 15 | } remote_comm_hdr; 16 | 17 | /* Define possible values for the type field in IM messages. */ 18 | #define NET_IMOPEN 101 19 | #define NET_IMCLOSE 102 20 | #define NET_IMRDHDR 103 21 | #define NET_IMPUTHDR 104 22 | #define NET_IMWRHDR 105 23 | #define NET_IMALEXHDR 106 24 | #define NET_IMRDPAS 107 25 | #define NET_IMWRPAS 108 26 | #define NET_IMALFMT 109 27 | 28 | /* Defines the elements common to all IM message structures. */ 29 | typedef struct remote_comm_pars { 30 | uint32_t type; 31 | uint32_t size; 32 | uint32_t istream; 33 | } remote_comm_pars; 34 | 35 | typedef struct remote_open_pars { 36 | uint32_t type; 37 | uint32_t size; 38 | uint32_t istream; 39 | uint32_t attr; 40 | uint32_t name_length; 41 | } remote_open_pars; 42 | 43 | typedef struct remote_wrhdr_pars { 44 | uint32_t type; 45 | uint32_t size; 46 | uint32_t istream; 47 | float32_t mean; 48 | } remote_wrhdr_pars; 49 | 50 | typedef struct remote_alexhdr_pars { 51 | uint32_t type; 52 | uint32_t size; 53 | uint32_t istream; 54 | int32_t section; 55 | int32_t space_group; 56 | union { 57 | struct { uint32_t nbytes; } all; 58 | struct { uint16_t nint, nfloat; } part; 59 | } var; 60 | } remote_alexhdr_pars; 61 | 62 | typedef struct remote_rdwr_pars { 63 | uint32_t type; 64 | uint32_t size; 65 | uint32_t istream; 66 | uint32_t ix; 67 | uint32_t nx; 68 | uint32_t ny; 69 | uint32_t cur_y; 70 | uint32_t cur_section; 71 | uint32_t cur_resolution; 72 | uint16_t display; 73 | uint16_t mode; 74 | } remote_rdwr_pars; 75 | 76 | typedef struct remote_alfmt_pars { 77 | uint32_t type; 78 | uint32_t size; 79 | uint32_t istream; 80 | uint32_t format; 81 | } remote_alfmt_pars; 82 | 83 | /* Define possible values for the attr field in the open message structure. */ 84 | #define NET_IMOPEN_NEW 0 85 | #define NET_IMOPEN_OLD 1 86 | #define NET_IMOPEN_READONLY 2 87 | #define NET_IMOPEN_SCRATCH 3 88 | 89 | 90 | #ifdef __cplusplus 91 | extern "C" { 92 | #endif 93 | 94 | int IMget_port_file(char* filename, const char* prefix, int max_length); 95 | int IMhandle_imsubs_request(int sock, remote_comm_pars* p_pars, int swab); 96 | ssize_t IMread_socket(int sock, void* buffer, size_t sz); 97 | int IMinitiate_byte_order_determination(int sock, int* p_different_order); 98 | int IMrespond_byte_order_determination(int sock, int* p_different_order); 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | 105 | #endif /* include guard */ 106 | -------------------------------------------------------------------------------- /IVE/win32/INCLUDE/kernel/convert.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_CONVERT_H 2 | #define UCSF_MSG_CONVERT_H 3 | 4 | /* @(#) $Id: convert.h,v 1.1 2002/01/18 00:24:52 eric Exp $ */ 5 | /* $Name: $ */ 6 | 7 | #include "ive_conf.h" /* uint32_t, uint16_t */ 8 | 9 | #define IMswab2(y) (((uint16_t)(y) >> 8) | ((uint16_t)(y) << 8)) 10 | #define IMswab4(y) (((uint32_t)(y) >> 24) | ((uint32_t)(y) << 24) | (((uint32_t)(y) & 0xff00u) << 8) | (((uint32_t)(y) & 0xff0000u) >> 8)) 11 | 12 | /* 13 | * Defines a prototype for converting to image data as seen by the user 14 | * (native byte ordering and possibly converted to floating-point) to the 15 | * representation stored in an image resource. count is the number of pixels, 16 | * or if the data is complex, twice the number of pixels, to convert. 17 | */ 18 | typedef void (*IMToUserConverterInPlace)(void* inout, int count); 19 | 20 | /* 21 | * Same as IMToUserConverter but for use where the operation can not be done 22 | * in place. 23 | */ 24 | typedef void (*IMToUserConverter)(void* out, const void* in, int count); 25 | 26 | /* 27 | * Defines a prototype for converting from image data as seen by the user 28 | * to that stored in the image resource. count is the number of pixels, 29 | * or if the data is complex, twice the number of pixels, to convert. 30 | * Returns 0 if no overflow was detected; otherwise one is returned. 31 | */ 32 | typedef int (*IMFromUserConverter)(void* out, const void* in, int count); 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | void IMvswab4(uint32_t* inout, int count); 39 | void IMvswab4_copy(uint32_t* out, const uint32_t* in, int count); 40 | void IMvswab2(uint16_t* inout, int count); 41 | void IMvswab2_copy(uint16_t* out, const uint16_t* in, int count); 42 | 43 | /* 44 | * Returns a functions which is appropriate for converting data in the 45 | * resource representation (specified by mode, which describes the 46 | * representation of each pixel, and by swab which, if true, specifies, 47 | * that byte swapping should be done) to the user representation (which 48 | * is the native floating-point form if to_float is true). 49 | */ 50 | IMToUserConverterInPlace IMget_to_user_convert_ip( 51 | int mode, int to_float, int swab 52 | ); 53 | 54 | IMToUserConverter IMget_to_user_convert(int mode, int to_float, int swab); 55 | 56 | /* 57 | * Returns a function which is appropriate for converting data from the 58 | * user's representation to the resource representation. 59 | */ 60 | IMFromUserConverter IMget_from_user_convert(int mode, int to_float, int swab); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* include guard */ 67 | -------------------------------------------------------------------------------- /IVE/win32/LIB/libimlib.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/IVE/win32/LIB/libimlib.a -------------------------------------------------------------------------------- /IVE/win32/LIB/libive.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/IVE/win32/LIB/libive.a -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/IM.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IM_H 2 | #define UCSF_MSG_IM_H 3 | 4 | /* @(#) $Id: IM.h,v 1.2 2002/01/18 00:24:43 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * Provides function prototypes for IM functions. 8 | */ 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | int IMOpen(int istream, const char* name, const char* attrib); 15 | void IMClose(int istream); 16 | int IMUnit(int istream); 17 | void IMRdHdr( 18 | int istream, 19 | int ixyz[3], 20 | int mxyz[3], 21 | int* imode, 22 | float *min, 23 | float *max, 24 | float *mean 25 | ); 26 | void IMWrHdr( 27 | int istream, 28 | const char title[80], 29 | int ntflag, 30 | float dmin, 31 | float dmax, 32 | float dmean 33 | ); 34 | void IMGetExHdr(int istream, void* extended); 35 | void IMGetHdr(int istream, void* header); 36 | void IMPutHdr(int istream, const void* header); 37 | void IMTrHdr(int istream, int jstream); 38 | void IMTrCel(int istream, int jstream); 39 | void IMTrExHdr(int jstream, int istream, int jsec, int isec); 40 | int IMTrFmt(int istream, int jstream); 41 | void IMTrLab(int istream, int jstream); 42 | void IMCrHdr( 43 | int istream, 44 | const int ixyz[3], 45 | const int mxyz[3], 46 | int imode, 47 | const char* labels, 48 | int nl 49 | ); 50 | void IMAlCel(int istream, const float cell[6]); 51 | void IMAlCon(int istream, int flag); 52 | void IMAlDat( 53 | int istream, int itype, int lensnum, int n1, int n2, float v1, float v2 54 | ); 55 | void IMAlDel(int istream, const float delta[3]); 56 | void IMAlDis(int flag); 57 | void IMAlExHdr(int istream, int isec, const int ivals[], const float rvals[]); 58 | void IMAlExHdrSize(int istream, int nints, int nreals, int nsecs); 59 | void IMAlExHdrZWT( 60 | int istream, int iz, int iw, int it, const int ival[], const float rval[] 61 | ); 62 | void IMAlExt(int istream, const void* extra, int istart, int nextra); 63 | int IMAlFmt(int istream, int iformat); 64 | void IMAlLab(int istream, const char* labels, int nl); 65 | void IMAlMap(int istream, const int mcrs[3]); 66 | void IMAlMode(int istream, int imode); 67 | void IMAlOrig(int istream, float xorig, float yorig, float zorig); 68 | void IMAlPrt(int flag); 69 | void IMAlRes(int istream, int mres, int mzfact); 70 | void IMAlSam(int istream, const int mxyz[3]); 71 | void IMAlSiz(int istream, const int inxyz[3], const int nxyzst[3]); 72 | void IMAlSpg(int istream, int nspg, int mbsym); 73 | void IMAlSym(int istream, int mbsym, const void* jbsym); 74 | void IMAlTlt(int istream, const float vals[3]); 75 | void IMAlTltRot(int istream, const float vals[3]); 76 | void IMAlTSt(int istream, int itst); 77 | void IMAlWav(int istream, int nwave, const float wavelen[]); 78 | void IMAlWavMM(int istream, int nwave, float dmin, float dmax); 79 | void IMAlZWT(int istream,int nz, int nw, int nt, int wflag); 80 | void IMRtCel(int istream, float cell[6]); 81 | void IMRtDat( 82 | int istream, 83 | int* itype, 84 | int* lensnum, 85 | int* n1, 86 | int* n2, 87 | float* v1, 88 | float* v2 89 | ); 90 | void IMRtDel(int istream, float delta[3]); 91 | void IMRtExHdr(int istream, int jsec, int ivals[], float rvals[]); 92 | void IMRtExHdrSize(int istream, int* nints, int* nreals); 93 | void IMRtExHdrZWT( 94 | int istream, int iz, int iw, int it, int ival[], float rval[] 95 | ); 96 | void IMRtExt(int istream, void* extra, int istart, int nextra); 97 | void IMRtFmt(int istream, int* iformat); 98 | void IMRtLab(int istream, char labels[20][80], int* nlabels); 99 | void IMRtMap(int istream, int mcrs[3]); 100 | void IMRtMode(int istream, int* mode); 101 | void IMRtMst(int istream, int nxyzst[3]); 102 | void IMRtOrig(int istream, float* xorig, float* yorig, float* zorig); 103 | void IMRtRes(int istream, int* mres, int* mzfact); 104 | void IMRtResInfo( 105 | int istream, int* nx, int* ny, int* nz, int* mxyfact, int* mzfact 106 | ); 107 | void IMRtSam(int istream, int mxyz[3]); 108 | void IMRtSiz(int istream, int inxyz[3], int mxyz[3], int nxyzst[3]); 109 | void IMRtSpg(int istream, int* nspg, int* mbsym); 110 | int IMRtStream(int wid); 111 | void IMRtSym(int istream, int* mbsym, void* jbsym); 112 | void IMRtTlt(int istream, float tilt[3]); 113 | void IMRtTSt(int istream, int* itst); 114 | void IMRtWav(int istream, int* nwave, float wavelen[]); 115 | void IMRtWavMM(int istream, int iwave, float* dmin, float* dmax); 116 | int IMRtWID(int istream); 117 | void IMRtZWT(int istream, int* nz, int* nw, int* nt, int* wflag); 118 | int IMPosn(int istream, int iz, int iy); 119 | int IMPosnRes(int istream, int ires); 120 | int IMPosnZWT(int istream, int iz, int iw, int it); 121 | void IMRdLin(int istream, void* array); 122 | void IMRdPal(int istream, void* array, const int* nx1, const int* nx2); 123 | void IMRdPas( 124 | int istream, 125 | void* array, 126 | int mx, 127 | int my, 128 | int nx1, 129 | int nx2, 130 | int ny1, 131 | int ny2 132 | ); 133 | void IMRdSec(int istream, void* array); 134 | void IMRdSecl(int istream, void* array, const int* mlines); 135 | void IMWrLin(int istream, const void* array); 136 | void IMWrPal(int istream, const void* array, int nx1, int nx2); 137 | void IMWrPas( 138 | int istream, 139 | const void* array, 140 | int mx, 141 | int my, 142 | int nx1, 143 | int nx2, 144 | int ny1, 145 | int ny2 146 | ); 147 | void IMWrSec(int istream, const void* array); 148 | void IMWrSecl(int istream, const void* array, int mlines); 149 | void IMClLim(int istream, int xyzmin[3], int xyzmax[3], int mxyz[3]); 150 | void IMFixExHdr(int istream, int izst, int izend, int izskip, int iflag); 151 | void IMFixExHdrZWT( 152 | int istream, 153 | int izst, 154 | int izend, 155 | int nwt, 156 | const int iwtable[], 157 | int itst, 158 | int itend, 159 | int itinc, 160 | int iflag 161 | ); 162 | void IMCalcDen( 163 | const float* array, 164 | int mx, 165 | int my, 166 | int nx1, 167 | int nx2, 168 | int ny1, 169 | int ny2, 170 | float* dmin, 171 | float* dmax, 172 | float* dmean 173 | ); 174 | void IMInterp( 175 | const float* array_a, 176 | float* array_b, 177 | int nxa, 178 | int nya, 179 | int nxb, 180 | int nyb, 181 | const float* amat, 182 | float xc, 183 | float yc, 184 | float xt, 185 | float yt, 186 | float scale 187 | ); 188 | 189 | /***** new calls added by api *****/ 190 | int IMRtExHdrType( 191 | int iStreamNum, int* iExtHeaderType, int* iNumInts, int* iNumFloats 192 | ); 193 | int IMRtExHdrValueZWT( 194 | int iStreamNum, int iZ, int iW, int iT, int iField, double* dValue 195 | ); 196 | int IMAlExHdrValueZWT( 197 | int iStreamNum, int iZ, int iW, int iT, int iField, double dValue 198 | ); 199 | int IMTrExHdr2( 200 | int iOutStream, 201 | int iInStream, 202 | int iz1, 203 | int iz2, 204 | int izinc, 205 | const int iProcWaveTable[IW_MAX_WAVE], 206 | int it1, 207 | int it2, 208 | int itinc 209 | ); 210 | int IMRtZWTNum(int iStream, int* iz, int* iw, int* it, int iSecNum); 211 | int IMRtSecNum(int iStream, int iz, int iw, int it, int* iSecNum); 212 | 213 | 214 | #ifdef __cplusplus 215 | } 216 | #endif 217 | 218 | #endif /* include guard */ 219 | -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/IMInclude.h: -------------------------------------------------------------------------------- 1 | #ifndef USCF_MSG_IMINCLUDE_H 2 | #define UCSF_MSG_IMINCLUDE_H 3 | 4 | /* @(#)$Id: IMInclude.h,v 1.1 2001/08/09 23:20:42 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * This includes all definitions and functions needed by applications using 8 | * just the IM routines. 9 | */ 10 | 11 | #include "IWApiConstants.h" 12 | #include "IM.h" 13 | 14 | #endif /* include guard */ 15 | -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/IWApiConstants.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IWAPICONSTANTS_H 2 | #define UCSF_MSG_IWAPICONSTANTS_H 3 | 4 | /* @(#) $Id: IWApiConstants.h,v 1.9 2009/11/10 01:06:52 eric Exp $ */ 5 | /* $Name: $ */ 6 | /*----------------------------------------------------------------------------- 7 | Copyright (C) 1993 8 | Macromolecular Structure Group of Biochemistry Dept. at University of 9 | California at San Francisco. 10 | These coded instructions, statements, and computer programs comprise 11 | unpublished proprietary information of the Macromolecular Structure Group of 12 | the Biochemistry Department at University of California at San Francisco, 13 | and are protected by Federal copyright law. They may not be disclosed 14 | to third parties, copied or duplicated in any form - in whole or in part - 15 | without the prior written consent of Macromolecular Structure Group of 16 | Biochemistry Department at University of California at San Francisco. 17 | -------------------------------------------------------------------------*/ 18 | 19 | #define IW_SUCCESS 1 20 | #define IW_FAILURE 0 21 | #define IW_ERROR -1 22 | 23 | /* Constants for designating bank channels. */ 24 | #define IW_EMPTY -1 25 | #define IW_ALL_WINDOWS -1 26 | #define IW_ALL_BANKS -1 27 | #define IW_MAX_BANK 5 28 | #define IW_ALL_WAVES -1 29 | #define IW_WAVE1 0 30 | #define IW_WAVE2 1 31 | #define IW_WAVE3 2 32 | #define IW_WAVE4 3 33 | #define IW_WAVE5 4 34 | #define IW_MAX_WAVE 5 35 | 36 | /* for IMWLapply_to_wave */ 37 | #define IW_APPLY_SYNC 0 38 | #define IW_APPLY_NONE 1 39 | #define IW_APPLY_ALL 2 40 | 41 | /* Constants for specifing color */ 42 | #define IW_PSEUDO 1 43 | #define IW_TRUE_COLOR 0 44 | #define IW_COLOR_NAME_LEN 12 45 | #define IW_NUM_TRUE_COLOR 7 46 | 47 | #define IW_BLACK 0 48 | #define IW_RED 1 49 | #define IW_GREEN 2 50 | #define IW_YELLOW (IW_RED + IW_GREEN) 51 | #define IW_BLUE 4 52 | #define IW_PINK (IW_RED + IW_BLUE) 53 | #define IW_CYAN (IW_GREEN + IW_BLUE) 54 | #define IW_WHITE (IW_RED + IW_GREEN + IW_BLUE) 55 | #define IW_SANDY_BROWN 8 56 | #define IW_BROWN 9 57 | #define IW_LT_GREY 10 58 | #define IW_PURPLE 11 59 | #define IW_INVISIBLE 12 60 | #define IW_NUM_COLORS 12 61 | 62 | /* Data Types. */ 63 | #define IW_AS_IS -1 64 | #define IW_BYTE 0 65 | #define IW_SHORT 1 66 | #define IW_FLOAT 2 67 | #define IW_COMPLEX_SHORT 3 68 | #define IW_COMPLEX 4 69 | #define IW_EMTOM 5 70 | #define IW_USHORT 6 71 | #define IW_LONG 7 72 | 73 | /* 74 | * Possible values for the file type (see IMAlDat and IMRtDat). These 75 | * are new in IVE 4; previous versions referred to them directly by number. 76 | * IM_MULTIPOSITION was added in IVE 4.1.0; IM_PUPIL_FUNCTION was added in 77 | * IVE 4.1.8. 78 | */ 79 | #define IM_NORMAL_IMAGES 0 80 | #define IM_TILT_SERIES 1 81 | #define IM_STEREO_TILT_SERIES 2 82 | #define IM_AVERAGED_IMAGES 3 83 | #define IM_AVERAGED_STEREO_PAIRS 4 84 | #define IM_EM_TILT_SERIES 5 85 | #define IM_MULTIPOSITION 20 86 | #define IM_PUPIL_FUNCTION 8000 87 | 88 | /* Monitor Matrix Display Layout Format */ 89 | #define TEXT_FMT 1 90 | #define DATA_FMT 0 91 | 92 | /* 93 | Monitor window decoration style (for IWAlDisWinBdr, IWRtDisWinBdr). 94 | Full border includes the title bar and the resize handles. The resize 95 | border only has the resize handles. Windows without borders have 96 | no window manager decorations. 97 | */ 98 | #define IW_MON_FULL_BRDR 0 99 | #define IW_MON_RESIZE_BRDR 1 100 | #define IW_MON_NO_BRDR 2 101 | 102 | /* 103 | Monitor menu/toolbar display style (for IWAlDisWinTool, IWRtDisWinTool). 104 | No menus or tools are shown with IW_MON_NO_MENU_TOOLS. The other constants 105 | can be combined as a bitwise or to flag what will be shown. 106 | */ 107 | #define IW_MON_NO_MENU_TOOLS 0 108 | #define IW_MON_SHOW_MENU 1 109 | #define IW_MON_SHOW_LEFTTOOLS 2 110 | #define IW_MON_ALL_MENU_TOOLS 3 111 | 112 | #define IW_MIN_WIN_SIZE 128 113 | #define IW_MAX_WIN_SIZE 1024 114 | 115 | 116 | /* 117 | * Specify which buffers to read out for IWCaptureImage. 118 | */ 119 | #define IW_LEFT_IMAGE 1 120 | #define IW_RIGHT_IMAGE 2 121 | #define IW_NORMAL_IMAGE 3 122 | 123 | /* 124 | * Specify which format to use for each pixel in the result of IWCaptureImage. 125 | */ 126 | #define IW_RGBA_PIXEL 0 127 | #define IW_LUMINANCE_PIXEL 1 128 | 129 | 130 | typedef struct IW_MRC_Header { 131 | int nx,ny,nz; /* nz : nfocal*nwave*ntime */ 132 | int mode; 133 | int nxst, nyst, nzst; 134 | int mx, my, mz; 135 | float xlen, ylen, zlen; 136 | float alpha, beta, gamma; 137 | int mapc, mapr, maps; 138 | float amin, amax, amean; 139 | int ispg, inbsym; 140 | 141 | short nDVID,nblank; /* CB: nDVID value. nblank preserves byte boundary */ 142 | int ntst; /* Hans: add ntst to record time domain offset */ 143 | char ibyte[24]; 144 | short nint,nreal; 145 | short nres,nzfact; 146 | float min2,max2,min3,max3,min4,max4; 147 | short file_type, lens, n1, n2, v1, v2; /* From daa2:[agard.image]imsubs.for*/ 148 | /*file_type = idtype*/ 149 | float min5,max5; 150 | short num_times; 151 | short interleaved; /* Zero => not interleaved. That means z changes 152 | fastest, then time, then waves; 153 | 1 => interleaved. That means wave changes fastest, 154 | then z, then time. */ 155 | float tilt_x, tilt_y, tilt_z; 156 | short num_waves, iwav1, iwav2, iwav3, iwav4, iwav5; 157 | float zorig, xorig, yorig; 158 | int nlab; 159 | char label[800]; 160 | } IW_MRC_HEADER, *IW_MRC_HEADER_PTR; 161 | 162 | typedef struct IW_complex { 163 | float real; 164 | float imaginary; 165 | } IW_COMPLEX_VALUE, *IW_COMPLEX_PTR; 166 | 167 | /* for IMWLcomplex_disp */ 168 | #define IW_COMPLEX_AMPLITUDE 0x00010000 169 | #define IW_COMPLEX_REAL 0x00020000 170 | #define IW_COMPLEX_IMAGINARY 0x00030000 171 | #define IW_COMPLEX_PHASE 0x00040000 172 | 173 | /* 174 | * Used to define accuracy for scaling done in IWScaleImage. 175 | * IW_SCALING_DONTCARE is the default - exact for byte and short 176 | * types but increasingly inaccurate for floating point data as 177 | * the exponent gets farther away from 1. IW_SCALING_EXACT is 178 | * exact for all types (but generally involves a performance penalty). 179 | */ 180 | #define IW_SCALING_DONTCARE 0x00000000 181 | #define IW_SCALING_EXACT 0x01000000 182 | 183 | typedef unsigned char *IW_BYTE_MEM_PTR; 184 | typedef short *IW_SHORT_MEM_PTR; 185 | typedef float *IW_FLOAT_MEM_PTR; 186 | 187 | #define IW_SAVE_BUF (1 << 0) 188 | #define IW_BUF_CREATED (1 << 1) 189 | #define IW_IMG_CREATED (1 << 2) 190 | 191 | #define IW_WIN_CREATED 680 /* MAGIC NUMBER */ 192 | #define IW_WIN_KILLED 681 /* MAGIC NUMBER */ 193 | #define IW_BANK_DISPLAYED 689 /* MAGIC NUMBER */ 194 | #define IW_BANK_DISPLAY_CHANGED 690 /* MAGIC NUMBER */ 195 | #define IW_BANK_KILLED 691 /* MAGIC NUMBER */ 196 | #define IW_WINDOW_GEO_CHANGED 692 /* MAGIC NUMBER */ 197 | #define IW_WIN_GR_KILLED 693 /* MAGIC NUMBER */ 198 | #define IW_WAVE_GR_KILLED 694 /* MAGIC NUMBER */ 199 | 200 | /* Macro Function Names */ 201 | #define IW_MAX(x,y) ((x > y) ? x : y) 202 | #define IW_MIN(x,y) ((x > y) ? y : x) 203 | #define IW_ABS(x) ((x > 0) ? x : -x) 204 | 205 | typedef float IW_VECTOR[3]; 206 | typedef float *IW_VECTOR_PTR; 207 | typedef IW_VECTOR IW_MATRIX[3]; 208 | typedef IW_VECTOR *IW_MATRIX_PTR; 209 | 210 | typedef int IW_INT_VECTOR[3]; 211 | typedef int *IW_INT_VECTOR_PTR; 212 | typedef IW_INT_VECTOR IW_INT_MATRIX[3]; 213 | typedef IW_INT_VECTOR *IW_INT_MATRIX_PTR; 214 | 215 | /* 216 | * Define indices into the ClientMessage data.s array for Monitor display 217 | * change events. Use 2 and 5 for backward compatibility. 218 | */ 219 | #define IW_CM_WIN_ID 2 220 | #define IW_CM_CHANGE_OR_SYN 5 /* type of change */ 221 | 222 | #define GW_ATTEND 0 223 | #define GW_ATTACH 1 224 | #define GW_DEATTACH 2 225 | #define GW_DELETEGR 3 226 | 227 | /* Extended header definitions -- new additions */ 228 | 229 | #define UNKNOWN_EXT_HEADER_TYPE 0 230 | #define UCSF_EXT_HEADER_TYPE1 1 231 | #define API_EXT_HEADER_TYPE1 2 232 | #define API_EXT_HEADER_TYPE2 3 233 | #define UCSF_EXT_HEADER_TYPE2 4 234 | 235 | #define UCSF_EXT_HDR_1_NINTS 1 236 | #define UCSF_EXT_HDR_1_NFLOATS 1 237 | #define UCSF_EXT_HDR_2_NINTS 3 238 | #define UCSF_EXT_HDR_2_NFLOATS 1 239 | #define API_EXT_HDR_1_NINTS 0 240 | #define API_EXT_HDR_1_NFLOATS 2 241 | #define API_EXT_HDR_2_NINTS 8 242 | #define API_EXT_HDR_2_NFLOATS 32 243 | 244 | /* NB: use of these values as array indices for the floating-point */ 245 | /* part of the extended header is a temporary KLUGE. */ 246 | /* WHEN APPLYING THIS KLUGE IN FORTRAN, 1 MUST BE ADDED TO VALUE IN CODE! */ 247 | #define PHOTOSENSOR_READING 0 248 | #define TIME_STAMP_SECS 1 249 | #define STAGE_X_COORD 2 250 | #define STAGE_Y_COORD 3 251 | #define STAGE_Z_COORD 4 252 | #define MIN_INTEN 5 253 | #define MAX_INTEN 6 254 | #define MEAN_INTEN 7 255 | #define EXP_TIME 8 256 | #define ND_FILTER 9 257 | #define EX_WAVELEN 10 258 | #define EM_WAVELEN 11 259 | #define INTEN_SCALING 12 260 | #define ENERGY_CONV_FACTOR 13 261 | #define PHOTOSENSOR_NCONV 14 262 | 263 | /* array indices for extended header integer values */ 264 | #define PHOTOMETRIC_INTERP_INT 0 /*0=white is zero,1=black is zero,2=RGB,3=palette,4=transparency (same as TIFF)*/ 265 | 266 | /* code values for wavelength */ 267 | #define RATIO_IMAGE_WAVELENGTH 10 268 | #define PRODUCT_IMAGE_WAVELENGTH 20 269 | #define ADDITION_IMAGE_WAVELENGTH 30 270 | #define SUBTRACTION_IMAGE_WAVELENGTH 40 271 | #define DIC_IMAGE_WAVELENGTH 50 272 | #define PHASE_IMAGE_WAVELENGTH 60 273 | #define BLEND_IMAGE_WAVELENGTH 70 274 | 275 | 276 | /* image sequence definitions */ 277 | #define ZTW_SEQUENCE 0 /* "non-interleaved", by defintion */ 278 | #define WZT_SEQUENCE 1 /* "interleaved", from R3D and others */ 279 | #define ZWT_SEQUENCE 2 /* new sequence. Unsupported as of 11/97 */ 280 | 281 | #endif /* include guard */ 282 | -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/cxxstd.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_CXXSTD_H 2 | #define UCSF_MSG_CXXSTD_H 3 | 4 | // @(#) $Id: cxxstd.h,v 1.2 2008/04/15 03:09:29 eric Exp $ 5 | // $Name: $ 6 | // Defines macros so code can conditionally compile stuff that depends 7 | // on whether or not the standard C++ headers (no .h) and namespace are 8 | // available. If HAS_STDCXX is set, the compiler, at least, provides the 9 | // standard C++ headers which are not the standard C headers wrapped in the 10 | // std namespace. If HAS_STDCXX_C is set, the compiler provides the 11 | // standard C headers wrapped in the std namespace. 12 | 13 | #ifdef __sgi 14 | #ifdef _STANDARD_C_PLUS_PLUS 15 | #define HAS_STDCXX 16 | #define HAS_STDCXX_C 17 | #endif 18 | #else 19 | #define HAS_STDCXX 20 | // Version 3.2-3 of pgCC does not include the C headers wrapped in the std 21 | // namespace. Do not know whether other versions of the Portland Group 22 | // compiler do. 23 | #ifndef __PGI 24 | #define HAS_STDCXX_C 25 | #endif 26 | #endif 27 | 28 | #ifdef HAS_STDCXX 29 | #define STDNAMESPACE(x) std::x 30 | #else 31 | #define STDNAMESPACE(x) ::x 32 | #endif 33 | 34 | #ifdef HAS_STDCXX_C 35 | #define STDNAMESPACE_C(x) std::x 36 | #else 37 | #define STDNAMESPACE_C(x) ::x 38 | #endif 39 | 40 | #endif /* include guard */ 41 | -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/exhdr.inc: -------------------------------------------------------------------------------- 1 | C @(#) $Id: exhdr.inc,v 1.1 2001/08/09 23:20:47 eric Exp $ 2 | C $Name: $ 3 | integer*4 I_PHOTOSENSOR_READING 4 | parameter (I_PHOTOSENSOR_READING = 0) 5 | integer*4 I_TIME_STAMP_SECS 6 | parameter (I_TIME_STAMP_SECS = 1) 7 | integer*4 I_STAGE_X_COORD 8 | parameter (I_STAGE_X_COORD = 2) 9 | integer*4 I_STAGE_Y_COORD 10 | parameter (I_STAGE_Y_COORD = 3) 11 | integer*4 I_STAGE_Z_COORD 12 | parameter (I_STAGE_Z_COORD = 4) 13 | integer*4 I_MIN_INTEN 14 | parameter (I_MIN_INTEN = 5) 15 | integer*4 I_MAX_INTEN 16 | parameter (I_MAX_INTEN = 6) 17 | integer*4 I_MEAN_INTEN 18 | parameter (I_MEAN_INTEN = 7) 19 | integer*4 I_EXP_TIME 20 | parameter (I_EXP_TIME = 8) 21 | integer*4 I_ND_FILTER 22 | parameter (I_ND_FILTER = 9) 23 | integer*4 I_EX_WAVELEN 24 | parameter (I_EX_WAVELEN = 10) 25 | integer*4 I_EM_WAVELEN 26 | parameter (I_EM_WAVELEN = 11) 27 | integer*4 I_INTEN_SCALING 28 | parameter (I_INTEN_SCALING = 12) 29 | integer*4 I_ENERGY_CONV_FACTOR 30 | parameter (I_ENERGY_CONV_FACTOR = 13) 31 | integer*4 I_PHOTOSENSOR_NCONV 32 | parameter (I_PHOTOSENSOR_NCONV = 14) 33 | -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/fortran_types.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_FORTRAN_TYPES_H 2 | #define UCSF_MSG_FORTRAN_TYPES_H 3 | 4 | /* @(#) $Id: fortran_types.h,v 1.1.1.1 2001/07/12 23:12:59 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * Define types for interfaces between Fortran and C/C++ code. 8 | */ 9 | 10 | 11 | #include "ive_conf.h" 12 | 13 | #ifdef FTN_INT_TYPE 14 | typedef FTN_INT_TYPE ftn_int_t; 15 | #endif /* FTN_INT_TYPE */ 16 | 17 | #ifdef FTN_REAL_TYPE 18 | typedef FTN_REAL_TYPE ftn_real_t; 19 | typedef struct ftn_cmplx_t { ftn_real_t real, imag; } ftn_cmplx_t; 20 | #endif /* FTN_REAL_TYPE */ 21 | 22 | #ifdef FTN_DOUBLE_TYPE 23 | typedef FTN_DOUBLE_TYPE ftn_double_t; 24 | typedef struct ftn_dcmplx_t { ftn_double_t real, imag; } ftn_dcmplx_t; 25 | #endif /* FTN_DOUBLE_TYPE */ 26 | 27 | #ifdef FTN_CHAR_TYPE 28 | typedef FTN_CHAR_TYPE ftn_char_t; 29 | #endif /* FTN_CHAR_TYPE */ 30 | 31 | /* 32 | * The type used to represent the lengths of character arrays when passed 33 | * as arguments. 34 | */ 35 | #ifdef FTN_LENGTH_TYPE 36 | typedef FTN_LENGTH_TYPE ftn_length_t; 37 | #endif /* FTN_LENGTH_TYPE */ 38 | 39 | #ifdef FTN_LOGICAL_TYPE 40 | typedef FTN_LOGICAL_TYPE ftn_logical_t; 41 | #endif /* FTN_LOGICAL_TYPE */ 42 | #undef FTN_IS_FALSE 43 | #ifdef FTN_FALSE_IS_ZERO 44 | #define FTN_IS_FALSE(x) ((x) == 0) 45 | #endif /* FTN_FALSE_IS_ZERO */ 46 | #ifdef FTN_FALSE_LOW_BIT_ZERO 47 | #define FTN_IS_FALSE(x) (((x) & 1) == 0) 48 | #endif /* FTN_FALSE_LOW_BIT_ZERO */ 49 | 50 | #endif /* include guard */ 51 | -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/ive_conf.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IVE_CONF_H 2 | #define UCSF_MSG_IVE_CONF_H 3 | 4 | /* @(#) Generated from $Id: ive_conf.h_m4,v 1.22 2012/06/02 03:14:19 eric Exp $ with genus = win64 and IVE_SHM64 = */ 5 | /* $Name: $ */ 6 | /* 7 | * Copyright(C) 2001 8 | * Macromolecular Structure Group of the Biochemistry Department at the 9 | * University of California, San Francisco 10 | */ 11 | /* 12 | * Set the macros controlling platform-specific behavior and conditional 13 | * compilation. Define typedefs for fixed-size types. 14 | */ 15 | 16 | 17 | /* 18 | * Clear any outside settings. 19 | */ 20 | #undef IVECONF_XOPEN 21 | #undef IVECONF_BSD 22 | #undef IVECONF_WIN32 23 | #undef IVECONF_PTHREAD 24 | #undef IVECONF_DEFINES_ETIMEDOUT 25 | #undef IVECONF_DEFINES_ELOOP 26 | #undef IVECONF_DEFINES_EOVERFLOW 27 | #undef IVECONF_DEFINES_SEMUN 28 | #undef IVECONF_DEFINES_MAP_FAILED 29 | #undef IVECONF_POSIX_NAMED_SEM_IN_FS 30 | #undef IVECONF_NO_SEM_GETVALUE 31 | #undef IVECONF_UNIMPL_SEM_GETVALUE 32 | #undef IVECONF_SHM64 33 | #undef IVECONF_SHMMUTEX_USE_PTHREAD 34 | #undef IVECONF_SHMMUTEX_USE_SYSVSEM 35 | #undef IVECONF_SHMMUTEX_USE_FCNTL 36 | #undef IVECONF_SHMHOLD_USE_SYSVSEM 37 | #undef IVECONF_SHMHOLD_USE_FCNTL 38 | #undef IVECONF_SHMRWLK_USE_PTHREAD 39 | #undef IVECONF_SHMRWLK_USE_SYSVSEM 40 | #undef IVECONF_SHMRWLK_USE_FCNTL 41 | #undef IVECONF_SHMSEM_USE_POSIXUNNAMED 42 | #undef IVECONF_SHMSEM_USE_POSIXNAMED 43 | #undef IVECONF_SHMSEM_USE_SYSVSEM 44 | #undef IVECONF_SHMSEM_USE_CYGWIN_HACK 45 | #undef IVECONF_HAS_O_SYNC 46 | #undef IVECONF_HAS_SIGINFO 47 | #undef IVECONF_HAS_VSNPRINTF 48 | #undef IVECONF_USE_ISNANF 49 | #undef IVECONF_FINITE_IN_IEEEFP_H 50 | #undef IVECONF_INTTYPES_SYSTYPES_CLASH 51 | #undef IVECONF_HAS_DLOPEN 52 | #undef IVECONF_HAS_RTLD_LOCAL 53 | #undef IVECONF_HAS_NSMODULE 54 | #undef IVECONF_NO_INTTYPES 55 | #undef IVECONF_CLOSE_BEFORE_REMOVE 56 | #undef IVECONF_HAS_IPV6 57 | #undef IVECONF_HAS_UNSIGNED_TIME_T 58 | #undef IVECONF_NPROC_SYSCONF_NPROCESSORS_ONLN 59 | #undef IVECONF_NPROC_SYSCONF_NPROC_ONLN 60 | #undef IVECONF_NPROC_SYSCTL 61 | #undef IVECONF_HAS_STATVFS 62 | #undef IVECONF_HAS_STATVFS64 63 | #undef IVECONF_HAS_STATFS 64 | #undef IVECONF_STATFS_REQUIRES_PARAM_H 65 | #undef IVECONF_STATFS_REQUIRES_MOUNT_H 66 | #undef IVECONF_STATFS_REQUIRES_VFS_H 67 | #undef IVECONF_STATFS_REQUIRES_STATFS_H 68 | #undef IVECONF_STATFS_AVAIL_FIELD 69 | #undef IVECONF_HAS_NSGETEXECUTABLEPATH 70 | #undef IVECONF_HAS_PROCSELF 71 | #undef IVECONF_HAS_PATH_DEFPATH 72 | #undef IVECONF_DEFAULT_PATH 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | /* 92 | * Win32 or Win64 93 | */ 94 | /* Supplies some Posix-like functions in the CRT library */ 95 | #define IVECONF_WIN32 96 | #ifdef _MSC_VER 97 | typedef __int8 int8_t; 98 | typedef __int16 int16_t; 99 | typedef __int32 int32_t; 100 | typedef unsigned __int8 uint8_t; 101 | typedef unsigned __int16 uint16_t; 102 | typedef unsigned __int32 uint32_t; 103 | typedef float float32_t; 104 | typedef double float64_t; 105 | #elif defined(__GNUC__) 106 | #include 107 | typedef float float32_t; 108 | typedef double float64_t; 109 | #endif 110 | 111 | 112 | #if defined(IVECONF_XOPEN) || defined(IVECONF_BSD) 113 | typedef int IVEDesc; 114 | #ifndef IVECONF_NO_INTTYPES 115 | #ifdef IVECONF_INTTYPES_SYSTYPES_CLASH 116 | /* 117 | * A kludge for IRIX 5.3 where both inttypes.h and sys/types.h define int8_t. 118 | * int16_t, and int32_t 119 | */ 120 | #include 121 | typedef unsigned char uint8_t; 122 | typedef unsigned short uint16_t; 123 | typedef unsigned int uint32_t; 124 | #else 125 | #include 126 | #endif 127 | #endif 128 | /* 129 | * If available, use pthreads as the threading package. 130 | */ 131 | #include 132 | #ifdef _POSIX_THREADS 133 | #define IVECONF_PTHREAD 134 | #endif /* _POSIX_THREADS */ 135 | #endif /* IVECONF_XOPEN || IVECONF_BSD */ 136 | 137 | #endif /* include guard */ 138 | -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/ive_error.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IVE_ERROR_H 2 | #define UCSF_MSG_IVE_ERROR_H 3 | 4 | /* @(#) $Id: ive_error.h,v 1.3 2007/09/24 17:48:36 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * Copyright(C) 2001 8 | * Macromolecular Structure Group of the Biochemistry Department at the 9 | * University of California, San Francisco 10 | */ 11 | /* 12 | * Declares error constants and error handling functions. 13 | */ 14 | 15 | 16 | enum { 17 | IVE_ERR_NONE = 0 18 | 19 | /* Runtime conditions */ 20 | , IVE_ERR_NO_MEM = 1 21 | , IVE_ERR_NO_SPC = 2 22 | , IVE_ERR_NO_RESOURCES = 3 23 | , IVE_ERR_IN_USE = 10 24 | , IVE_ERR_TIMEOUT = 11 25 | , IVE_ERR_IO = 20 26 | , IVE_ERR_NO_PERMISSION = 30 27 | , IVE_ERR_EXIST = 31 28 | , IVE_ERR_OVERFLOW = 40 29 | , IVE_ERR_UNSUPPORTED = 50 30 | 31 | /* Problems with passed arguments */ 32 | , IVE_ERR_INVALID = 512 33 | , IVE_ERR_BAD_FILENAME = 513 34 | 35 | /* Miscellaneous */ 36 | , IVE_ERR_CORRUPT = 1024 37 | , IVE_ERR_INTERNAL = 1025 38 | , IVE_ERR_UNRECOGNIZED = 1280 39 | }; 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | 45 | void IVEErrorToString(int code, int max_length, char* str, int* p_full_length); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif /* __cplusplus */ 50 | 51 | #endif /* include guard */ 52 | -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/ive_fortran.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IVE_FORTRAN_H 2 | #define UCSF_MSG_IVE_FORTRAN_H 3 | 4 | /* @(#) $Id: ive_fortran.h,v 1.3 2007/09/24 17:48:38 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * Copyright(C) 2001 8 | * Macromolecular Structure Group of the Biochemistry Department at the 9 | * University of California, San Francisco 10 | */ 11 | /* 12 | * Declare functions for use in writing Fortran wrappers for C. 13 | */ 14 | 15 | 16 | #include "fortran_types.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif /* __cplusplus */ 21 | 22 | /* 23 | * Result should be freed with free. 24 | */ 25 | char* IVEFtnStringToCString(const ftn_char_t* fstr, ftn_length_t flength); 26 | 27 | void IVECStringToFtnString( 28 | const char* cstr, ftn_length_t flength, ftn_char_t* fstr 29 | ); 30 | 31 | ftn_int_t IVEPtrToFtnId(void* ptr); 32 | 33 | void* IVEFtnIdToPtr(ftn_int_t id); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif /* __cplusplus */ 38 | 39 | #endif /* include guard */ 40 | -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/ive_hash.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IVE_HASH_H 2 | #define UCSF_MSG_IVE_HASH_H 3 | 4 | /* @(#) $Id: ive_hash.h,v 1.2 2007/09/24 17:48:38 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * Copyright(C) 2001 8 | * Macromolecular Structure Group of the Biochemistry Department at the 9 | * University of California, San Francisco 10 | */ 11 | /* 12 | * Declare a utility function for hashing arbitrary data to an integer 13 | * value. hash_size (the possible range of values for the hash is 0 to 14 | * hash_size - 1) is restricted to be a power of 2. 15 | */ 16 | 17 | 18 | #include "ive_conf.h" 19 | 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif /* __cplusplus */ 24 | 25 | int IVEHash(const uint8_t* data, uint32_t length, int hash_size); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif /* __cplusplus */ 30 | 31 | #endif /* include guard */ 32 | -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/ive_standards.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IVE_STANDARDS_H 2 | #define UCSF_MSG_IVE_STANDARDS_H 3 | 4 | /* @(#) Generated from $Id: ive_standards.h_m4,v 1.8 2012/06/02 03:10:06 eric Exp $ with genus = win64 */ 5 | /* $Name */ 6 | /* 7 | * Copyright(C) 2002 8 | * Macromolecular Structure Group of the Biochemistry Department at the 9 | * University of California, San Francisco 10 | */ 11 | /* 12 | * Sets feature-set macros to ensure that the system headers define 13 | * the needed functions and types. Doing so after including one or more 14 | * system and then including other system headers may cause inconsistent 15 | * definitions: always include this header first! As a consequence of this, 16 | * do not use constructs (i.e. typedefs of system types) which depend on the 17 | * inclusion of this header unless the user is made aware of the side effects. 18 | */ 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | /* 36 | * Nothing is done for Win32 or Win64. 37 | */ 38 | 39 | 40 | #endif /* include guard */ 41 | -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/ive_thread.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IVE_THREAD_H 2 | #define UCSF_MSG_IVE_THREAD_H 3 | 4 | /* @(#) $Id: ive_thread.h,v 1.5 2008/04/07 22:29:18 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * Copyright(C) 2001 8 | * Macromolecular Structure Group of the Biochemistry Department at the 9 | * University of California, San Francisco 10 | */ 11 | /* 12 | * Declare types and functions for making the library thread-safe. 13 | * These functions do nothing unless you link against the thread-safe 14 | * library and define IVE_MTSAFE. 15 | */ 16 | 17 | 18 | #include "ive_conf.h" 19 | 20 | 21 | #ifdef IVE_MTSAFE 22 | #ifdef IVECONF_PTHREAD 23 | #include 24 | #define IVE_ONCE_INIT PTHREAD_ONCE_INIT 25 | typedef pthread_once_t IVEThreadOnceFlag; 26 | typedef pthread_key_t IVEThreadKey; 27 | typedef pthread_mutex_t IVEThreadMutex; 28 | #elif defined(IVECONF_WIN32) 29 | #define IVE_ONCE_INIT (0) 30 | typedef PVOID IVEThreadOnceFlag; 31 | typedef DWORD IVEThreadKey; 32 | typedef CRITICAL_SECTION IVEThreadMutex; 33 | #else 34 | #error "Do not know how to define IVEThread types" 35 | #endif /* else clause IVECONF_PTHREAD */ 36 | 37 | #else 38 | #define IVE_ONCE_INIT {0} 39 | typedef struct { int set; } IVEThreadOnceFlag; 40 | struct IVEThreadKeyImpl; 41 | typedef struct IVEThreadKeyImpl* IVEThreadKey; 42 | typedef struct { int dummy; } IVEThreadMutex; 43 | 44 | #endif /* else clause IVE_MTSAFE */ 45 | 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif /* __cplusplus */ 50 | 51 | int IVEThreadCountProcessors(void); 52 | void IVEThreadCallOnce(void (*init_routine)(void), IVEThreadOnceFlag* p_once); 53 | void IVEThreadInitKey(IVEThreadKey* p_key, int* p_status); 54 | void IVEThreadDestroyKey(IVEThreadKey key); 55 | void IVEThreadSetKeyValue(void* value, IVEThreadKey key, int* p_status); 56 | void* IVEThreadGetKeyValue(IVEThreadKey key); 57 | void IVEThreadInitMutex(IVEThreadMutex* p_mutex, int* p_status); 58 | void IVEThreadDestroyMutex(IVEThreadMutex* p_mutex); 59 | void IVEThreadAcquireMutex(IVEThreadMutex* p_mutex); 60 | int IVEThreadTryAcquireMutex(IVEThreadMutex* p_mutex); 61 | void IVEThreadReleaseMutex(IVEThreadMutex* p_mutex); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif /* __cplusplus */ 66 | 67 | #endif /* include guard */ 68 | -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/ive_time.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IVE_TIME_H 2 | #define UCSF_MSG_IVE_TIME_H 3 | 4 | /* @(#) $Id: ive_time.h,v 1.5 2012/06/02 03:04:36 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * Copyright(C) 2001 8 | * Macromolecular Structure Group of the Biochemistry Department at the 9 | * University of California, San Francisco 10 | */ 11 | /* 12 | * Declare types and functions for timing. 13 | */ 14 | 15 | #include "ive_conf.h" 16 | 17 | 18 | #undef IVE_TIME_INTERVAL_MIN 19 | #undef IVE_TIME_INTERVAL_MAX 20 | 21 | 22 | /* 23 | * IVETimeValue is the type used to store a representation of the current time. 24 | * IVETimerInterval is the signed integral type used to store time intervals; 25 | * it must have at least 32 bits. 26 | */ 27 | #if defined(IVECONF_XOPEN) || defined(IVECONF_BSD) 28 | #include 29 | #include 30 | typedef struct timeval IVETimeValue; 31 | typedef int IVETimeInterval; 32 | #define IVE_TIME_INTERVAL_MIN INT_MIN 33 | #define IVE_TIME_INTERVAL_MAX INT_MAX 34 | #elif defined(IVECONF_WIN32) 35 | #include 36 | #include 37 | typedef FILETIME IVETimeValue; 38 | typedef int IVETimeInterval; 39 | #define IVE_TIME_INTERVAL_MIN INT_MIN 40 | #define IVE_TIME_INTERVAL_MAX INT_MAX 41 | #else 42 | #error "Do not know how to define IVETimeValue and IVETimerInterval" 43 | #endif 44 | 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif /* __cplusplus */ 49 | 50 | void IVESleep(IVETimeInterval intvl_us); 51 | void IVEGetCurrTime(IVETimeValue* p_time); 52 | IVETimeInterval IVECalcTimeDiff( 53 | const IVETimeValue* p_t2, const IVETimeValue* p_t1, int* p_status 54 | ); 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif /* __cplusplus */ 59 | 60 | #endif /* include guard */ 61 | -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/kernel/IKInterleave.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IKINTERLEAVE_H 2 | #define UCSF_MSG_IKINTERLEAVE_H 3 | 4 | /* @(#) $Id: IKInterleave.h,v 1.1 2001/08/09 23:20:50 eric Exp $ */ 5 | /* $Name: $ */ 6 | /* 7 | * These are kernel / monitor helper functions to go back and forth between 8 | * zwt indices and single section index. Other applications should use 9 | * IMRtSecNum and IMRtZWTNum. 10 | */ 11 | 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif /* __cplusplus */ 16 | 17 | /* 18 | * Returns 1 if intlv (the code for how z, waves, and times are interleaved) 19 | * is invalid. Otherwise returns 0 and sets *p_isec to the 1D section index. 20 | * Assumes that nz, nw, and nt are positive integers and that iz, iw, and 21 | * it are non-negative integers less than nz, nw, and nt respectively. 22 | */ 23 | int IKZWT2Sec( 24 | int* p_isec, int iz, int iw, int it, int nz, int nw, int nt, int intlv 25 | ); 26 | 27 | 28 | /* 29 | * Returns 1, if intlv is invalid. Otherwise returns 0 and sets *p_iz, *p_iw, 30 | * *p_it to the z, wave, and time indexes corresponding to isec. Assumes that 31 | * nz, nw, and nt are positive integers and that isec is a non-negative 32 | * integer less than nz * nw * nt. 33 | */ 34 | int IKSec2ZWT( 35 | int* p_iz, 36 | int* p_iw, 37 | int* p_it, 38 | int isec, 39 | int nz, 40 | int nw, 41 | int nt, 42 | int intlv 43 | ); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif /* __cplusplus */ 48 | 49 | #endif /* include guard */ 50 | -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/kernel/IMNetFuncs.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_IMNETFUNCS_H 2 | #define UCSF_MSG_IMNETFUNCS_H 3 | 4 | /* @(#) $Id: IMNetFuncs.h,v 1.2 2003/04/03 22:35:09 eric Exp $ */ 5 | /* $Name: $ */ 6 | 7 | #include "ive_conf.h" 8 | #include /* ssize_t */ 9 | 10 | 11 | /* Defines the elements common to all messages */ 12 | typedef struct remote_comm_hdr { 13 | uint32_t type; 14 | uint32_t size; 15 | } remote_comm_hdr; 16 | 17 | /* Define possible values for the type field in IM messages. */ 18 | #define NET_IMOPEN 101 19 | #define NET_IMCLOSE 102 20 | #define NET_IMRDHDR 103 21 | #define NET_IMPUTHDR 104 22 | #define NET_IMWRHDR 105 23 | #define NET_IMALEXHDR 106 24 | #define NET_IMRDPAS 107 25 | #define NET_IMWRPAS 108 26 | #define NET_IMALFMT 109 27 | 28 | /* Defines the elements common to all IM message structures. */ 29 | typedef struct remote_comm_pars { 30 | uint32_t type; 31 | uint32_t size; 32 | uint32_t istream; 33 | } remote_comm_pars; 34 | 35 | typedef struct remote_open_pars { 36 | uint32_t type; 37 | uint32_t size; 38 | uint32_t istream; 39 | uint32_t attr; 40 | uint32_t name_length; 41 | } remote_open_pars; 42 | 43 | typedef struct remote_wrhdr_pars { 44 | uint32_t type; 45 | uint32_t size; 46 | uint32_t istream; 47 | float32_t mean; 48 | } remote_wrhdr_pars; 49 | 50 | typedef struct remote_alexhdr_pars { 51 | uint32_t type; 52 | uint32_t size; 53 | uint32_t istream; 54 | int32_t section; 55 | int32_t space_group; 56 | union { 57 | struct { uint32_t nbytes; } all; 58 | struct { uint16_t nint, nfloat; } part; 59 | } var; 60 | } remote_alexhdr_pars; 61 | 62 | typedef struct remote_rdwr_pars { 63 | uint32_t type; 64 | uint32_t size; 65 | uint32_t istream; 66 | uint32_t ix; 67 | uint32_t nx; 68 | uint32_t ny; 69 | uint32_t cur_y; 70 | uint32_t cur_section; 71 | uint32_t cur_resolution; 72 | uint16_t display; 73 | uint16_t mode; 74 | } remote_rdwr_pars; 75 | 76 | typedef struct remote_alfmt_pars { 77 | uint32_t type; 78 | uint32_t size; 79 | uint32_t istream; 80 | uint32_t format; 81 | } remote_alfmt_pars; 82 | 83 | /* Define possible values for the attr field in the open message structure. */ 84 | #define NET_IMOPEN_NEW 0 85 | #define NET_IMOPEN_OLD 1 86 | #define NET_IMOPEN_READONLY 2 87 | #define NET_IMOPEN_SCRATCH 3 88 | 89 | 90 | #ifdef __cplusplus 91 | extern "C" { 92 | #endif 93 | 94 | int IMget_port_file(char* filename, const char* prefix, int max_length); 95 | int IMhandle_imsubs_request(int sock, remote_comm_pars* p_pars, int swab); 96 | ssize_t IMread_socket(int sock, void* buffer, size_t sz); 97 | int IMinitiate_byte_order_determination(int sock, int* p_different_order); 98 | int IMrespond_byte_order_determination(int sock, int* p_different_order); 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | 105 | #endif /* include guard */ 106 | -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/kernel/convert.h: -------------------------------------------------------------------------------- 1 | #ifndef UCSF_MSG_CONVERT_H 2 | #define UCSF_MSG_CONVERT_H 3 | 4 | /* @(#) $Id: convert.h,v 1.1 2002/01/18 00:24:52 eric Exp $ */ 5 | /* $Name: $ */ 6 | 7 | #include "ive_conf.h" /* uint32_t, uint16_t */ 8 | 9 | #define IMswab2(y) (((uint16_t)(y) >> 8) | ((uint16_t)(y) << 8)) 10 | #define IMswab4(y) (((uint32_t)(y) >> 24) | ((uint32_t)(y) << 24) | (((uint32_t)(y) & 0xff00u) << 8) | (((uint32_t)(y) & 0xff0000u) >> 8)) 11 | 12 | /* 13 | * Defines a prototype for converting to image data as seen by the user 14 | * (native byte ordering and possibly converted to floating-point) to the 15 | * representation stored in an image resource. count is the number of pixels, 16 | * or if the data is complex, twice the number of pixels, to convert. 17 | */ 18 | typedef void (*IMToUserConverterInPlace)(void* inout, int count); 19 | 20 | /* 21 | * Same as IMToUserConverter but for use where the operation can not be done 22 | * in place. 23 | */ 24 | typedef void (*IMToUserConverter)(void* out, const void* in, int count); 25 | 26 | /* 27 | * Defines a prototype for converting from image data as seen by the user 28 | * to that stored in the image resource. count is the number of pixels, 29 | * or if the data is complex, twice the number of pixels, to convert. 30 | * Returns 0 if no overflow was detected; otherwise one is returned. 31 | */ 32 | typedef int (*IMFromUserConverter)(void* out, const void* in, int count); 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | void IMvswab4(uint32_t* inout, int count); 39 | void IMvswab4_copy(uint32_t* out, const uint32_t* in, int count); 40 | void IMvswab2(uint16_t* inout, int count); 41 | void IMvswab2_copy(uint16_t* out, const uint16_t* in, int count); 42 | 43 | /* 44 | * Returns a functions which is appropriate for converting data in the 45 | * resource representation (specified by mode, which describes the 46 | * representation of each pixel, and by swab which, if true, specifies, 47 | * that byte swapping should be done) to the user representation (which 48 | * is the native floating-point form if to_float is true). 49 | */ 50 | IMToUserConverterInPlace IMget_to_user_convert_ip( 51 | int mode, int to_float, int swab 52 | ); 53 | 54 | IMToUserConverter IMget_to_user_convert(int mode, int to_float, int swab); 55 | 56 | /* 57 | * Returns a function which is appropriate for converting data from the 58 | * user's representation to the resource representation. 59 | */ 60 | IMFromUserConverter IMget_from_user_convert(int mode, int to_float, int swab); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* include guard */ 67 | -------------------------------------------------------------------------------- /IVE/win64/INCLUDE/malloc.inc: -------------------------------------------------------------------------------- 1 | c @(#) $Id: malloc.inc_m4,v 1.1 2001/11/20 20:02:11 eric Exp $ 2 | c $Name: $ 3 | c 4 | c Define appropriate return type for malloc and size of pointer in 5 | c bytes. 6 | 7 | integer iptrsz 8 | parameter (iptrsz = 8) 9 | 10 | integer*8 malloc 11 | -------------------------------------------------------------------------------- /IVE/win64/LIB/libimlib.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/IVE/win64/LIB/libimlib.a -------------------------------------------------------------------------------- /IVE/win64/LIB/libimlib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/IVE/win64/LIB/libimlib.lib -------------------------------------------------------------------------------- /IVE/win64/LIB/libive - Copy.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/IVE/win64/LIB/libive - Copy.a -------------------------------------------------------------------------------- /IVE/win64/LIB/libive.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/IVE/win64/LIB/libive.lib -------------------------------------------------------------------------------- /VStutio_project/Buffers/Buffers.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {AAE0AF2B-D932-44C7-8ADE-A249535D0DFF} 23 | Win32Proj 24 | Buffers 25 | 26 | 27 | 28 | StaticLibrary 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | StaticLibrary 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | StaticLibrary 41 | false 42 | v120 43 | true 44 | Unicode 45 | 46 | 47 | StaticLibrary 48 | false 49 | v120 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | $(SolutionDir) 71 | 72 | 73 | $(SolutionDir) 74 | 75 | 76 | 77 | Use 78 | Level3 79 | Disabled 80 | WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) 81 | 82 | 83 | Windows 84 | true 85 | 86 | 87 | 88 | 89 | Use 90 | Level3 91 | Disabled 92 | WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) 93 | 94 | 95 | Windows 96 | true 97 | 98 | 99 | 100 | 101 | Level3 102 | Use 103 | MaxSpeed 104 | true 105 | true 106 | WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) 107 | $(CUDA_PATH)/include 108 | None 109 | 110 | 111 | Windows 112 | true 113 | true 114 | true 115 | 116 | 117 | 118 | 119 | Level3 120 | NotUsing 121 | MaxSpeed 122 | true 123 | true 124 | WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) 125 | $(CUDA_PATH)/include 126 | None 127 | 128 | 129 | Windows 130 | true 131 | true 132 | true 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /VStutio_project/Buffers/Buffers.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | -------------------------------------------------------------------------------- /VStutio_project/VStutio_project.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2013 for Windows Desktop 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cudaRecon", "VStutio_project.vcxproj", "{363C1217-D4E3-4ABE-BAE9-567D3B9A730C}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {AAE0AF2B-D932-44C7-8ADE-A249535D0DFF} = {AAE0AF2B-D932-44C7-8ADE-A249535D0DFF} 9 | EndProjectSection 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Buffers", "Buffers\Buffers.vcxproj", "{AAE0AF2B-D932-44C7-8ADE-A249535D0DFF}" 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Mixed Platforms = Debug|Mixed Platforms 16 | Debug|Win32 = Debug|Win32 17 | Debug|x64 = Debug|x64 18 | Release|Mixed Platforms = Release|Mixed Platforms 19 | Release|Win32 = Release|Win32 20 | Release|x64 = Release|x64 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {363C1217-D4E3-4ABE-BAE9-567D3B9A730C}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 24 | {363C1217-D4E3-4ABE-BAE9-567D3B9A730C}.Debug|Mixed Platforms.Build.0 = Debug|Win32 25 | {363C1217-D4E3-4ABE-BAE9-567D3B9A730C}.Debug|Win32.ActiveCfg = Debug|Win32 26 | {363C1217-D4E3-4ABE-BAE9-567D3B9A730C}.Debug|Win32.Build.0 = Debug|Win32 27 | {363C1217-D4E3-4ABE-BAE9-567D3B9A730C}.Debug|x64.ActiveCfg = Debug|x64 28 | {363C1217-D4E3-4ABE-BAE9-567D3B9A730C}.Debug|x64.Build.0 = Debug|x64 29 | {363C1217-D4E3-4ABE-BAE9-567D3B9A730C}.Release|Mixed Platforms.ActiveCfg = Release|Win32 30 | {363C1217-D4E3-4ABE-BAE9-567D3B9A730C}.Release|Mixed Platforms.Build.0 = Release|Win32 31 | {363C1217-D4E3-4ABE-BAE9-567D3B9A730C}.Release|Win32.ActiveCfg = Release|Win32 32 | {363C1217-D4E3-4ABE-BAE9-567D3B9A730C}.Release|Win32.Build.0 = Release|Win32 33 | {363C1217-D4E3-4ABE-BAE9-567D3B9A730C}.Release|x64.ActiveCfg = Release|x64 34 | {363C1217-D4E3-4ABE-BAE9-567D3B9A730C}.Release|x64.Build.0 = Release|x64 35 | {AAE0AF2B-D932-44C7-8ADE-A249535D0DFF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 36 | {AAE0AF2B-D932-44C7-8ADE-A249535D0DFF}.Debug|Mixed Platforms.Build.0 = Debug|Win32 37 | {AAE0AF2B-D932-44C7-8ADE-A249535D0DFF}.Debug|Win32.ActiveCfg = Debug|Win32 38 | {AAE0AF2B-D932-44C7-8ADE-A249535D0DFF}.Debug|Win32.Build.0 = Debug|Win32 39 | {AAE0AF2B-D932-44C7-8ADE-A249535D0DFF}.Debug|x64.ActiveCfg = Debug|Win32 40 | {AAE0AF2B-D932-44C7-8ADE-A249535D0DFF}.Release|Mixed Platforms.ActiveCfg = Release|Win32 41 | {AAE0AF2B-D932-44C7-8ADE-A249535D0DFF}.Release|Mixed Platforms.Build.0 = Release|Win32 42 | {AAE0AF2B-D932-44C7-8ADE-A249535D0DFF}.Release|Win32.ActiveCfg = Release|Win32 43 | {AAE0AF2B-D932-44C7-8ADE-A249535D0DFF}.Release|Win32.Build.0 = Release|Win32 44 | {AAE0AF2B-D932-44C7-8ADE-A249535D0DFF}.Release|x64.ActiveCfg = Release|x64 45 | {AAE0AF2B-D932-44C7-8ADE-A249535D0DFF}.Release|x64.Build.0 = Release|x64 46 | EndGlobalSection 47 | GlobalSection(SolutionProperties) = preSolution 48 | HideSolutionNode = FALSE 49 | EndGlobalSection 50 | EndGlobal 51 | -------------------------------------------------------------------------------- /VStutio_project/VStutio_project.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | {363C1217-D4E3-4ABE-BAE9-567D3B9A730C} 32 | Win32Proj 33 | VStutio_project 34 | $(CUDA_PATH) 35 | cudaRecon 36 | 37 | 38 | 39 | Application 40 | true 41 | v120 42 | Unicode 43 | 44 | 45 | Application 46 | true 47 | v120 48 | Unicode 49 | 50 | 51 | Application 52 | false 53 | v120 54 | true 55 | Unicode 56 | 57 | 58 | Application 59 | false 60 | v120 61 | true 62 | Unicode 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | true 83 | 84 | 85 | true 86 | 87 | 88 | false 89 | 90 | 91 | false 92 | $(SolutionDir) 93 | cudaSireconDriver 94 | 95 | 96 | 97 | 98 | 99 | Level3 100 | Disabled 101 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 102 | 103 | 104 | Console 105 | true 106 | 107 | 108 | 109 | 110 | 111 | 112 | Level3 113 | Disabled 114 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 115 | 116 | 117 | Console 118 | true 119 | 120 | 121 | 122 | 123 | Level3 124 | 125 | 126 | MaxSpeed 127 | true 128 | true 129 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 130 | 131 | 132 | Console 133 | true 134 | true 135 | true 136 | 137 | 138 | 139 | 140 | Level3 141 | 142 | 143 | MaxSpeed 144 | true 145 | true 146 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 147 | $(CUDA_PATH)/include;../Buffers;C:/libtiff;../IVE/win64/INCLUDE;C:/Boost/boost_1_55_0 148 | None 149 | 150 | 151 | Console 152 | true 153 | true 154 | true 155 | C:\Boost\boost_1_55_0\lib;$(CUDA_PATH)\lib\x64;C:\libtiff;..\lapack\win64;..\IVE\win64\lib;$(SolutionDir) 156 | cuda.lib;cudart.lib;cufft.lib;libtiff.lib;liblapack.lib;libblas.lib;libimlib.lib;libive.lib;Buffers.lib;%(AdditionalDependencies) 157 | 158 | 159 | 64 160 | compute_20,sm_20;compute_30,sm_30 161 | 162 | 163 | 164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /VStutio_project/VStutio_project.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /cudaSirecon/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories( 2 | "${CMAKE_CURRENT_SOURCE_DIR}" 3 | ${CUDA_INCLUDE_DIRS} 4 | "${CMAKE_CURRENT_SOURCE_DIR}/../Buffers" 5 | ) 6 | 7 | 8 | if(WIN32)# OR APPLE) 9 | link_directories ( ${Boost_LIBRARY_DIRS} ) 10 | include_directories( ${Boost_INCLUDE_DIRS} ) 11 | endif() 12 | 13 | if(WIN32) 14 | set(PRIISM_LIB_PATH "${CMAKE_SOURCE_DIR}/IVE/win64/LIB") 15 | include_directories("${CMAKE_SOURCE_DIR}/IVE/win64/INCLUDE/") 16 | link_directories ( ${PRIISM_LIB_PATH} ) 17 | if(WITH_TIFF) 18 | include_directories( ${TIFF_INCLUDE_DIR} ) 19 | link_directories ( ${TIFF_LIBRARY} ) 20 | endif(WITH_TIFF) 21 | elseif(APPLE) 22 | ## Not assuming the builder's shell environment is already set up to use 64-bit Priism 23 | ## But rather the priism/ was put in the locate described 24 | ## in the instructions in the top CMakeLists.txt section 1.5 25 | set(PRIISM_LIB_PATH "${CMAKE_SOURCE_DIR}/priism-4.4.0/Darwin/x86_64/LIB") 26 | include_directories("${CMAKE_SOURCE_DIR}/priism-4.4.0/Darwin/x86_64/INCLUDE") 27 | else() 28 | ## same as for apple - priism install location - works for chalkie666 29 | set(PRIISM_LIB_PATH "${CMAKE_SOURCE_DIR}/priism-4.4.0/Linux/x86_64/LIB") 30 | include_directories("${CMAKE_SOURCE_DIR}/priism-4.4.0/Linux/x86_64/INCLUDE") 31 | endif(WIN32) 32 | 33 | 34 | if(WIN32) 35 | message(STATUS "PRIISM_LIB_PATH: " ${PRIISM_LIB_PATH}) 36 | # find_library(IMLIB libimlib.a 37 | # PATHS ${PRIISM_LIB_PATH} 38 | # REQUIRED) 39 | # find_library(IVELIB ive 40 | # PATHS ${PRIISM_LIB_PATH} 41 | # REQUIRED) 42 | else(WIN32) 43 | find_library(IMLIB imlib 44 | PATHS ${PRIISM_LIB_PATH} 45 | REQUIRED) 46 | find_library(IVELIB ive 47 | PATHS ${PRIISM_LIB_PATH} 48 | REQUIRED) 49 | endif(WIN32) 50 | 51 | # if (APPLE) 52 | ############################################### 53 | #### Lin: The path to the cuda libraries is hardcoded here. Let me know 54 | #### if this works for you. 55 | ############################################### 56 | # set(CUDA_LIBRARIES "/Developer/NVIDIA/CUDA-5.0/lib/libtlshook.dylib" ${CUDA_LIBRARIES} ) 57 | # endif () 58 | 59 | 60 | 61 | CUDA_ADD_LIBRARY( 62 | gpuFunctions 63 | # SHARED 64 | gpuFunctionsImpl.cu 65 | ) 66 | 67 | if (NOT APPLE) 68 | set (SHARED_OR_NOT SHARED) 69 | endif() 70 | 71 | if (WITH_TIFF AND WIN32) 72 | CUDA_ADD_LIBRARY( 73 | cudaSirecon 74 | ${SHARED_OR_NOT} 75 | cudaSirecon.cpp 76 | boostfs.cpp 77 | tiffhandle.cpp 78 | ) 79 | elseif(APPLE) 80 | CUDA_ADD_LIBRARY( 81 | cudaSirecon 82 | SHARED 83 | cudaSirecon.cpp 84 | ) 85 | else () 86 | CUDA_ADD_LIBRARY( 87 | cudaSirecon 88 | # ${SHARED_OR_NOT} 89 | cudaSirecon.cpp 90 | ) 91 | endif() 92 | 93 | CUDA_ADD_EXECUTABLE( 94 | cudaSireconDriver 95 | cudaSireconDriver.cpp 96 | ) 97 | 98 | add_dependencies(cudaSireconDriver 99 | cudaSirecon 100 | gpuFunctions 101 | Buffer 102 | ) 103 | if(WIN32) 104 | find_library(BLAS LIBBLAS PATHS "${CMAKE_SOURCE_DIR}/lapack/win64" REQUIRED) 105 | find_library(LAPACK LIBLAPACK PATHS "${CMAKE_SOURCE_DIR}/lapack/win64" REQUIRED) 106 | if(WITH_TIFF) 107 | target_link_libraries( 108 | cudaSirecon 109 | gpuFunctions 110 | Buffer 111 | ${LAPACK} 112 | ${BLAS} 113 | libtiff 114 | ) 115 | else(WITH_TIFF) 116 | target_link_libraries( 117 | cudaSirecon 118 | gpuFunctions 119 | Buffer 120 | # ${IMLIB} 121 | # ${IVELIB} 122 | libimlib 123 | libive 124 | ${LAPACK} 125 | ${BLAS} 126 | ) 127 | endif(WITH_TIFF) 128 | 129 | target_link_libraries( 130 | cudaSireconDriver 131 | cudaSirecon 132 | gpuFunctions 133 | Buffer 134 | ${IMLIB} 135 | ${IVELIB} 136 | ${LAPACK} 137 | ${BLAS} 138 | ) 139 | else(WIN32) 140 | target_link_libraries( 141 | cudaSirecon 142 | gpuFunctions 143 | Buffer 144 | ${IMLIB} 145 | ${Boost_PROGRAM_OPTIONS_LIBRARY} 146 | ${Boost_FILESYSTEM_LIBRARY} 147 | ${Boost_REGEX_LIBRARY} 148 | ${Boost_SYSTEM_LIBRARY} 149 | blas 150 | lapack 151 | ${TIFF_LIBRARIES} 152 | X11 153 | # nvidia-ml 154 | ) 155 | target_link_libraries( 156 | cudaSireconDriver 157 | cudaSirecon 158 | ) 159 | endif(WIN32) 160 | CUDA_ADD_CUFFT_TO_TARGET(cudaSirecon) 161 | CUDA_ADD_CUFFT_TO_TARGET(cudaSireconDriver) 162 | -------------------------------------------------------------------------------- /cudaSirecon/SIM_reconstructor.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SIM_RECONSTRUCTOR_HPP 2 | #define SIM_RECONSTRUCTOR_HPP 3 | 4 | #include 5 | namespace po = boost::program_options; 6 | #include 7 | 8 | //! All calculation starts with a SIM_Reconstructor object 9 | /*! 10 | As seen in cudaSireconDriver.cpp, SIM reconstruction is done in the following steps: 11 | 1. Instantiate a SIM_Reconstructor object by passing along the command line; 12 | 2. For all the time points, do: 13 | 2a. Load raw data and preprocess 14 | 2b. call member processOneVolume() to reconstruct the current time point 15 | 2c. write reconstruction result of current time point 16 | 3. Close file(s) and exit 17 | */ 18 | class SIM_Reconstructor { 19 | 20 | public: 21 | /*! The constructor does the following: 22 | * Command line is parsed by this ctor using Boost program_options library; 23 | * Set all parameters' values; 24 | * Open raw data and OTF files for reading and output file for writing (except for in 25 | * TIFF mode output file is not created until the result of current time is getting saved); 26 | * Allocate all memory buffers. 27 | */ 28 | SIM_Reconstructor(int argc, char **argv); 29 | 30 | ~SIM_Reconstructor(); 31 | 32 | //! Load raw data from a file and do bleach correction (what "rescale" refers to) 33 | /*! 34 | * Calls private method loadImageData() 35 | * As is in other occasions, 'waveIdx' is to indicate color channel but mostly unused. 36 | * In the future, may add multi-color capability 37 | */ 38 | void loadAndRescaleImage(int timeIdx, int waveIdx); 39 | 40 | //! The main processing occurs inside this function: 41 | /*! 42 | 1. Re-initialize all key device buffers under m_reconData; 43 | 2. Fine-tune k0 vectors, modulation amplitudes and phases for all directions and orders 44 | 3. For all directions, pre-filter separated bands, inverse FFT, and assemble the bands 45 | */ 46 | void processOneVolume(); 47 | 48 | //! Off-load processed result to host and save it to disk 49 | void writeResult(int timeIdx, int waveIdx); 50 | 51 | int getNTimes() { return m_imgParams.ntimes; }; 52 | void setCurTimeIdx(int it) { m_imgParams.curTimeIdx = it; }; 53 | 54 | ReconParams & getReconParams() {return m_myParams;}; 55 | ImageParams & getImageParams() {return m_imgParams;}; 56 | 57 | void closeFiles(); //! only needed for closing MRC output file 58 | 59 | #ifdef __SIRECON_USE_TIFF__ 60 | //! Names of input TIFF files (usually a time series whose file names all match a pattern) 61 | std::vector< std::string > m_all_matching_files; 62 | // CImg<> m_otf_tiff; 63 | #endif 64 | 65 | private: 66 | std::string m_config_file; 67 | ReconParams m_myParams; 68 | ImageParams m_imgParams; 69 | ReconData m_reconData; 70 | DriftParams m_driftParams; 71 | int m_zoffset; 72 | po::options_description m_progopts; 73 | po::variables_map m_varsmap; 74 | IW_MRC_HEADER m_in_out_header; 75 | 76 | int m_argc; 77 | char ** m_argv; 78 | 79 | int setupProgramOptions(); //! setup command line options using Boost library 80 | int setParams(); //! assign parameters after parsing command line 81 | #ifdef __SIRECON_USE_TIFF__ 82 | void setup(CImg<> &inTIFF); 83 | #else 84 | //! Read header, set up OTF and separation matrix, allocate device buffers, initialize parameters like k0guess etc. 85 | /*! 86 | Calls setup_part2() to: 87 | 1. OTF is loaded and transferred to CUDA device by calling getOTFs(); 88 | 2. Separation (or un-mixing) matrix is allocated on CUDA device and populated; 89 | 3. Raw image and other buffers, including overlap0/1, bigbuffer, outbuffer, are allocated on CUDA device 90 | by calling allocateImageBuffers(); 91 | 4. Allocate/initialize a bunch of reconstruction related parameters , including: 92 | a. inscale 93 | b. k0 94 | c. k0_time0 95 | d. k0guess 96 | e. sum_dir0_phase0 97 | f. amp 98 | */ 99 | void setup(); 100 | #endif 101 | void openFiles(); 102 | 103 | //! Load raw data from disk, do flat-fielding, and transfer data to GPU 104 | /*! 105 | This is called by loadAndRescaleImage(); 106 | 'zoffset' is used if z-padding is used (almost never) 107 | 'iw' is color channel indicator; rarely used 108 | */ 109 | void loadImageData(int it, int iw, int zoffset); 110 | }; 111 | 112 | #endif 113 | -------------------------------------------------------------------------------- /cudaSirecon/boostfs.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include // sort 6 | 7 | static boost::filesystem::path outputDir; 8 | 9 | std::vector gatherMatchingFiles(std::string target_path, std::string pattern) 10 | { 11 | pattern.insert(0, ".*"); // '.' is the wildcard in Perl regexp; '*' just means "repeat". 12 | pattern.append(".*\\.tif"); 13 | 14 | const boost::regex my_filter(pattern); 15 | 16 | std::vector< std::string > all_matching_files; 17 | 18 | boost::filesystem::directory_iterator end_itr; // Constructs the end iterator. 19 | for( boost::filesystem::directory_iterator i( target_path ); i != end_itr; ++i ) { 20 | 21 | // Skip if not a file 22 | if( !boost::filesystem::is_regular_file( i->status() ) ) continue; 23 | 24 | boost::smatch what; 25 | 26 | // Skip if no match 27 | if( !boost::regex_match( i->path().string(), what, my_filter ) ) continue; 28 | 29 | // File matches, store it 30 | all_matching_files.push_back( i->path().string() ); 31 | } 32 | 33 | // sort file names so that earlier time points will be processed first: 34 | sort(all_matching_files.begin(), all_matching_files.end()); 35 | 36 | 37 | // Create output subfolder "decon/" just under the data folder: 38 | outputDir = target_path; 39 | outputDir /= "GPUsirecon"; 40 | 41 | if (! boost::filesystem::exists(outputDir) ) 42 | boost::filesystem::create_directory(outputDir); 43 | 44 | return all_matching_files; 45 | } 46 | 47 | 48 | std::string makeOutputFilePath(std::string inputFileName, std::string insert) 49 | { 50 | boost::filesystem::path inputpath(inputFileName); 51 | boost::filesystem::path outputpath(outputDir); 52 | 53 | std::string basename = inputpath.filename().string(); 54 | int pos = basename.find_last_of(".tif"); 55 | basename.insert(pos - 3, insert); 56 | 57 | outputpath /= basename; 58 | 59 | std::cout << "Output: " << outputpath.string() << '\n'; 60 | return outputpath.string(); 61 | } 62 | -------------------------------------------------------------------------------- /cudaSirecon/cudaSirecon.h: -------------------------------------------------------------------------------- 1 | #ifndef CUDA_SIRECON_H 2 | #define CUDA_SIRECON_H 3 | 4 | 5 | #include "cudaSireconImpl.h" // Or only a subset of it is needed? 6 | /* 7 | The following definitions are needed from cudaSirecon.h: 8 | 9 | ReconParams, ImageParams, DriftParams, ReconData 10 | */ 11 | #endif 12 | -------------------------------------------------------------------------------- /cudaSirecon/cudaSireconDriver.cpp: -------------------------------------------------------------------------------- 1 | #include "cudaSireconImpl.h" 2 | #include "SIM_reconstructor.hpp" 3 | 4 | int main(int argc, char **argv) 5 | { 6 | try { 7 | SIM_Reconstructor myreconstructor(argc, argv); 8 | 9 | for (int it = 0; it < myreconstructor.getNTimes(); ++it) { 10 | for (int iw = 0; iw < 1; ++iw) { 11 | myreconstructor.loadAndRescaleImage(it, iw); 12 | myreconstructor.setCurTimeIdx(it); 13 | myreconstructor.processOneVolume(); 14 | myreconstructor.writeResult(it, iw); 15 | } 16 | } 17 | 18 | #ifndef __SIRECON_USE_TIFF__ 19 | myreconstructor.closeFiles(); 20 | #endif 21 | } 22 | catch (std::exception &e) { 23 | std::cerr << "\n!!Error occurred: " << e.what() << std::endl; 24 | return 0; 25 | } 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /cudaSirecon/cudaSireconImpl.h: -------------------------------------------------------------------------------- 1 | #ifndef __CUDA_SIRECON_H 2 | #define __CUDA_SIRECON_H 3 | #ifdef _WIN32 4 | #define _USE_MATH_DEFINES 5 | #endif 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #ifndef __clang__ 21 | #include 22 | #endif 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #ifndef NDEBUG 31 | #ifndef _WIN32 32 | #include //for memory query 33 | static nvmlDevice_t nvmldevice; 34 | static nvmlMemory_t memoryStruct; 35 | #endif 36 | #endif 37 | 38 | #include "Buffer.h" 39 | #include "GPUBuffer.h" 40 | #include "CPUBuffer.h" 41 | #include "PinnedCPUBuffer.h" 42 | #include "gpuFunctions.h" 43 | 44 | #ifdef __SIRECON_USE_TIFF__ 45 | #include 46 | #define cimg_use_tiff 47 | #include 48 | using namespace cimg_library; 49 | #else 50 | #include // MRC file I/O routines 51 | #endif 52 | 53 | // Block sizes for reduction kernels 54 | #define RED_BLOCK_SIZE_X 64 55 | #define RED_BLOCK_SIZE_Y 4 56 | 57 | // Some simulation parameters 58 | /**ratio of beam size in pupil to pupil size */ 59 | #define SPOTRATIO 0.1 60 | #define MAXPHASES 25 61 | /** If k0 initial estimate is off from the guess by over this many pixels, a warning will be displayed */ 62 | #define K0_WARNING_THRESH 2 63 | 64 | 65 | #define CHECKED_DELETE(PTR) \ 66 | if (PTR) {\ 67 | delete PTR;\ 68 | PTR = 0;\ 69 | } 70 | #define CHECKED_DELETE_ARR(PTR) \ 71 | if (PTR) {\ 72 | delete [] PTR;\ 73 | PTR = 0;\ 74 | } 75 | 76 | #ifdef __SIRECON_USE_TIFF__ 77 | static TIFF *otf_tiff; // TODO: get rid of this; use "CImg<> m_otf_tiff" member in SIM_reconstructor instead. 78 | #else 79 | static const int istream_no = 1; 80 | static const int ostream_no = 2; 81 | static const int otfstream_no = 3; 82 | static const int aligned_stream_no = 10; 83 | static const int separated_stream_no = 11; 84 | static const int overlaps_stream_no = 12; 85 | 86 | // static IW_MRC_HEADER header; 87 | static IW_MRC_HEADER aligned_header; 88 | static IW_MRC_HEADER sep_header; 89 | static IW_MRC_HEADER overlaps_header; 90 | 91 | struct myExtHeader { 92 | float timestamp; 93 | float phaseAbsDeg; 94 | float expDose; 95 | float xdrift; 96 | float ydrift; 97 | }; 98 | #endif 99 | 100 | static float maxval = -FLT_MAX; 101 | static float minval = FLT_MAX; 102 | 103 | 104 | struct vector { 105 | float x; 106 | float y; 107 | }; 108 | struct vector3d { 109 | float x; 110 | float y; 111 | float z; 112 | }; 113 | 114 | /** Overall image reconstruction parameters. */ 115 | struct ReconParams { 116 | float k0startangle, linespacing; 117 | float na, nimm; 118 | int ndirs, nphases, norders_output; 119 | int norders; 120 | float *phaseSteps; /** user-specified non-ideal phase steps, one for each orientation */ 121 | int bTwolens; /** whether to process I{^5}S dataset */ 122 | int bFastSIM; /** fast SIM data is organized differently */ 123 | 124 | /* algorithm related parameters */ 125 | float zoomfact; 126 | int z_zoom; 127 | int nzPadTo; /** pad zero sections to this number of z sections */ 128 | float explodefact; 129 | int bFilteroverlaps; 130 | int recalcarrays; /** whether to calculate the overlaping regions between bands just once or always; used in fitk0andmodamps() */ 131 | int napodize; 132 | std::vector forceamp; 133 | // float *k0angles; 134 | std::vector k0angles; 135 | int bSearchforvector; 136 | int bUseTime0k0; /** whether to use time 0's k0 fit for the rest of a time series */ 137 | int apodizeoutput; /** 0-no apodize; 1-cosine apodize; 2-triangle apodize; used in filterbands() */ 138 | float apoGamma; 139 | int bSuppress_singularities; /** whether to dampen the OTF values near band centers; used in filterbands() */ 140 | int suppression_radius; /** if suppress_singularities is 1, the range within which suppresion is applied; used in filterbands() */ 141 | int bDampenOrder0; /** whether to dampen the OTF values near band centers; used in filterbands() */ 142 | int bFitallphases; /** In NL SIM, whether to use fitted phase for all orders or to infer higher order phase from order 1 phase fil */ 143 | int do_rescale; /** fading correction method: 0-no correction; 1-with correction */ 144 | int equalizez; 145 | int equalizet; 146 | int bNoKz0; /** if true, no kz=0 plane is used in modamp fit and assemblerealspace() */ 147 | float wiener, wienerInr; 148 | int bUseEstimatedWiener; 149 | 150 | /* OTF specific parameters */ 151 | int nxotf, nyotf, nzotf; 152 | float dkzotf, dkrotf; /** OTF's pixel size in inverse mirons */ 153 | int bRadAvgOTF; /** is radially-averaged OTF used? */ 154 | 155 | /* drift correction and phase step correction related flags */ 156 | int bFixdrift; /** whether nor not to correct drift between pattern directions */ 157 | float drift_filter_fact; /** fraction of the NA; used as the cutoff frequency in high-pass filtering in drift estimation */ 158 | 159 | /* Camera related parameters */ 160 | float constbkgd; 161 | int bBgInExtHdr; /** In Andor EMCCD, background varies with each exposure, esp. in EM mode. Hidden-behind-aluminum-foil pixels can be used to estimate background of each exposure and stored in the extended header. When this option is true, the 3rd float of the extended header stores such estimated background values. */ 162 | int bUsecorr; /** whether to use a camera flat-fielding (or correction) file */ 163 | char corrfiles[400]; /** name of the camera correction file if bUsecorr is 1 */ 164 | float readoutNoiseVar; 165 | float electrons_per_bit; 166 | 167 | /* Debugging flags */ 168 | int bMakemodel; /** whether to fake an ideal point source and obtain a recontruction of it (i.e., an effective PSF in some sense) */ 169 | int bSaveSeparated; /** whether to save separated bands and then quit before filterbands */ 170 | char fileSeparated[400]; 171 | int bSaveAlignedRaw; /** whether to save dirft-corrected raw images (within each direction) and then quit before filterbands */ 172 | char fileRawAligned[400]; 173 | int bSaveOverlaps; /** whether to save makeoverlaps() output into a file */ 174 | char fileOverlaps[400]; 175 | 176 | char ifiles[400]; 177 | char ofiles[400]; 178 | char otffiles[400]; 179 | int ifilein; 180 | int ofilein; 181 | int otffilein; 182 | }; 183 | struct ImageParams { 184 | int nx; 185 | int ny; 186 | int nz; 187 | int nz0; 188 | short nwaves; 189 | short wave[5]; 190 | short ntimes; 191 | unsigned short curTimeIdx; 192 | float dx; 193 | float dy; 194 | float dz; 195 | float inscale; 196 | }; 197 | struct DriftParams { 198 | vector3d* driftlist; 199 | float* phaseList; 200 | vector* driftAcq; 201 | vector3d* drifts; 202 | float* phaseAbs; 203 | float* timestamps; 204 | float* timestamps_for_fitting; 205 | float* expDose; 206 | vector3d* drift_bt_dirs; 207 | DriftParams() : driftlist(0), phaseList(0), driftAcq(0), drifts(0), 208 | phaseAbs(0), timestamps(0), timestamps_for_fitting(0), expDose(0) { 209 | }; 210 | ~DriftParams() { 211 | CHECKED_DELETE_ARR(driftlist); 212 | CHECKED_DELETE_ARR(phaseList); 213 | CHECKED_DELETE_ARR(driftAcq); 214 | CHECKED_DELETE_ARR(drifts); 215 | CHECKED_DELETE_ARR(phaseAbs); 216 | CHECKED_DELETE_ARR(timestamps); 217 | CHECKED_DELETE_ARR(timestamps_for_fitting); 218 | CHECKED_DELETE_ARR(expDose); 219 | }; 220 | }; 221 | struct ReconData { 222 | int sizeOTF; 223 | std::vector otf; 224 | CPUBuffer background; 225 | CPUBuffer slope; 226 | float backgroundExtra; 227 | std::vector > savedBands; 228 | std::vector sepMatrix; 229 | std::vector noiseVarFactors; 230 | GPUBuffer overlap0; 231 | GPUBuffer overlap1; 232 | std::vector k0; 233 | std::vector k0_time0; 234 | std::vector k0guess; 235 | std::vector > amp; 236 | std::vector sum_dir0_phase0; 237 | GPUBuffer bigbuffer; 238 | GPUBuffer outbuffer; 239 | }; 240 | 241 | 242 | void SetDefaultParams(ReconParams *pParams); 243 | 244 | 245 | // Functions for dealing with input images 246 | 247 | /** General setup applicable to all times and waves 248 | * Sets up image parameters and sets up OTFs. 249 | * Allocates memory for images on GPU, and for sepmatrix and noisevars on CPU. 250 | * */ 251 | // void setup(ReconParams* params, ImageParams* 252 | // imgParams, DriftParams* driftParams, ReconData* data); 253 | void setup_part2(ReconParams* params, ImageParams* imgParams, ReconData* reconData); 254 | // #ifdef __SIRECON_USE_TIFF__ 255 | // void setup(CImg<> &inTIFF, ReconParams* params, ImageParams* imgParams, ReconData* reconData); 256 | // #endif 257 | void loadHeader(const ReconParams& params, ImageParams* imgParams, IW_MRC_HEADER &header); 258 | // void readDriftData(const ReconParams& params, DriftParams* driftParams); 259 | void getOTFs(ReconParams* params, const ImageParams& imgParams, 260 | ReconData* data); 261 | void determine_otf_dimensions(int norders, int nz, ReconParams *params, 262 | int *sizeOTF); 263 | void allocateOTFs(int norders, int sizeOTF, 264 | std::vector* otfs); 265 | int loadOTFs(int norders, const ReconParams& params, 266 | const ImageParams& imgParams, ReconData* data); 267 | void allocateImageBuffers(const ReconParams& params, 268 | const ImageParams& imgParams, ReconData* reconData); 269 | 270 | void setOutputHeader(const ReconParams& myParams, const ImageParams& imgParams, 271 | IW_MRC_HEADER &header); 272 | 273 | void bgAndSlope(const ReconParams& myParams, 274 | const ImageParams& imgParams, ReconData* reconData); 275 | 276 | void getbg_and_slope(const char *corrfiles, float *background, 277 | float *slope, int nx, int ny); 278 | 279 | void makematrix(int nphases, int norders, int dir, float *arrPhases, 280 | float *sepMatrix, float * noiseVarFactors); 281 | 282 | void allocSepMatrixAndNoiseVarFactors(const ReconParams& params, 283 | ReconData* reconData); 284 | 285 | #ifdef __SIRECON_USE_TIFF__ 286 | void load_and_flatfield(CImg<> &cimg, int section_no, float *bufDestiny, 287 | float background, float inscale); 288 | #endif 289 | 290 | void load_and_flatfield(int section_no, int wave_no, 291 | int time_no, float *bufDestiny, float *buffer, int nx, int ny, 292 | float *background, float backgroundExtra, float *slope, float inscale, 293 | int bUsecorr); 294 | 295 | void saveIntermediateDataForDebugging(const ReconParams& params); 296 | 297 | void matrix_transpose(float* mat, int nRows, int nCols); 298 | 299 | /*! 300 | 301 | */ 302 | void findModulationVectorsAndPhasesForAllDirections( 303 | int zoffset, ReconParams* params, const ImageParams& imgParams, 304 | DriftParams* driftParams, ReconData* data); 305 | 306 | void apodizationDriver(int zoffset, ReconParams* params, 307 | const ImageParams& imgParams, DriftParams* driftParams, ReconData* data); 308 | void rescaleDriver(int it, int iw, int zoffset, ReconParams* params, 309 | const ImageParams& imgParams, DriftParams* driftParams, ReconData* data); 310 | void transformXYSlice(int zoffset, ReconParams* params, 311 | const ImageParams& imgParams, DriftParams* driftParams, ReconData* data); 312 | 313 | int fitXYdrift(vector3d *drifts, float * timestamps, int nPoints, 314 | vector3d *fitted_drift, float *eval_timestamps, int nEvalPoints); 315 | void calcPhaseList(float * phaseList, vector3d *driftlist, 316 | float *phaseAbs, float k0angle, float linespacing, 317 | float dr, int nphases, int nz, int direction, int z); 318 | 319 | void writeResult(int it, int iw, const ReconParams& params, 320 | const ImageParams& imgParams, const ReconData& reconData); 321 | #ifndef __SIRECON_USE_TIFF__ 322 | void saveCommandLineToHeader(int argc, char **argv, IW_MRC_HEADER &header); 323 | #endif 324 | 325 | void dumpBands(std::vector* bands, int nx, int ny, int nz0); 326 | 327 | void deviceMemoryUsage(); 328 | 329 | double meanAboveBackground_GPU(GPUBuffer &img, int nx, int ny, int nz); 330 | void rescale_GPU(GPUBuffer &img, int nx, int ny, int nz, float scale); 331 | 332 | // Compute rdistcutoff 333 | int rdistcutoff(int iw, const ReconParams& params, const ImageParams& imgParams); 334 | float get_phase(cuFloatComplex b); 335 | float cmag(cuFloatComplex a); 336 | cuFloatComplex cmul(cuFloatComplex a, cuFloatComplex b); 337 | 338 | // Extern Blas and Lapack declarations 339 | extern "C" void sgemm_(const char*, const char*, int*, int*, int*, 340 | float*, float*, int*, float*, int*, float*, float*, int*); 341 | extern "C" void sgetrf_(int*, int*, float*, int*, int*, int*); 342 | extern "C" void sgetri_(int*, float*, int*, int*, float*, int*, int*); 343 | extern "C" void sgels_(const char*, int*, int*, int*, float*, int*, float*, 344 | int*, float*, int*, int*); 345 | 346 | #ifdef __SIRECON_USE_TIFF__ 347 | extern "C" int load_tiff(TIFF *const tif, const unsigned int directory, const unsigned colind, float *const buffer); 348 | extern "C" int save_tiff(TIFF *tif, const unsigned int directory, int colind, const int nwaves, int width, int height, float * buffer , int bIsComplex); 349 | 350 | std::vector gatherMatchingFiles(std::string target_path, std::string pattern); 351 | std::string makeOutputFilePath(std::string inputFileName, std::string insert); 352 | #endif 353 | 354 | #endif 355 | -------------------------------------------------------------------------------- /cudaSirecon/gpuFunctions.h: -------------------------------------------------------------------------------- 1 | #ifndef GPU_FUNCTIONS_H 2 | #define GPU_FUNCTIONS_H 3 | 4 | #include "GPUBuffer.h" 5 | #include "cudaSireconImpl.h" 6 | 7 | #include 8 | 9 | struct vector; 10 | struct vector3d; 11 | struct ReconParams; 12 | 13 | /* 14 | returns alpha*a + beta*b in a 15 | offset is an offset into a 16 | len is the number of elements in the vectors a and b 17 | imSrc can be a NULL pointer, in which case only fDest*imDest will be returned 18 | */ 19 | void image_arithmetic(GPUBuffer* a, const GPUBuffer& b, int offset, 20 | int len, float alpha, float beta); 21 | void image_arithmetic(GPUBuffer* a, const GPUBuffer& b, 22 | int offsetA, int offsetB, 23 | int len, float alpha, float beta); 24 | 25 | void apodize(int napodize, int nx,int ny, GPUBuffer* image, int offset); 26 | void cosapodize(int nx,int ny, GPUBuffer* image, int offset); 27 | void rescale(int nx, int ny, int nz, int z, int zoffset, int direction, 28 | int wave, int t, int phases, std::vector* images, int equalizez, 29 | int equalizet, double* sum_dir0_phase0); 30 | 31 | float estimate_Wiener(const std::vector& rawImages, int nx, 32 | int ny, int z, int nphases, int rdistcutoff); 33 | 34 | int calcRefImage(const std::vector& rawImages, 35 | GPUBuffer* refImage, const std::vector& offImages, 36 | int nOffImages, int nx, int ny, int nphases, int type_of_refImage); 37 | 38 | void determinedrift_2D(const std::vector& rawImages, 39 | const std::vector& offImages, int nOffImages, 40 | const GPUBuffer& CrefImage, 41 | vector3d *drifts, int nphases, int nx, int ny, int dir, 42 | float rdistcutoff, float drift_filter_fact); 43 | 44 | void fixdrift_2D(std::vector* CrawImages, 45 | vector3d *driftlist, int nphases, int nx, int ny, int nz, int dir, 46 | int z); 47 | 48 | void separate(int nx, int ny, int z, int direction, int nphases, int 49 | norders, std::vector*rawImages, float *sepMatrix); 50 | 51 | void makemodeldata(int nx, int ny, int nz, std::vector* bands, 52 | int norders, vector k0, float dy, float dz, 53 | std::vector* OTF, short wave, ReconParams *pParams); 54 | 55 | void fixdrift_bt_dirs(std::vector* bands, int norders, 56 | vector3d drift, int nx,int ny, int nz); 57 | 58 | void findk0(std::vector* bands, GPUBuffer* overlap0, 59 | GPUBuffer* overlap1, int nx, int ny, int nz, int norders, vector *k0, 60 | float dy, float dz, std::vector* OTF, short wave, 61 | ReconParams * pParams); 62 | 63 | void fitk0andmodamps(std::vector* bands, GPUBuffer* overlap0, 64 | GPUBuffer* overlap1, int nx, int ny, int nz, int norders, 65 | vector *k0, float dy, float dz, std::vector* otf, short wave, 66 | cuFloatComplex* amps, ReconParams * pParams); 67 | 68 | float findrealspacemodamp(std::vector* bands, 69 | GPUBuffer* overlap0, GPUBuffer* overlap1, int nx, int ny, int nz, 70 | int order1, int order2, vector k0, float dy, float dz, 71 | std::vector* OTF, short wave, cuFloatComplex* modamp1, 72 | cuFloatComplex* modamp2, cuFloatComplex* modamp3, int redoarrays, 73 | ReconParams *pParams); 74 | 75 | void filterbands(int dir, std::vector* bands, 76 | const std::vector& k0, int ndirs, int norders, 77 | std::vector& otf, float dy, float dz, 78 | const std::vector >& amp, 79 | const std::vector& noiseVarFactors, int nx, int ny, int nz, 80 | short wave, ReconParams* params); 81 | 82 | void assemblerealspacebands(int dir, GPUBuffer* outbuffer, GPUBuffer* bigbuffer, 83 | std::vector* bands, int ndirs, int norders, 84 | const std::vector& k0, int nx, int ny, int nz, float zoomfact, 85 | int z_zoom, float expfact); 86 | 87 | void computeAminAmax(const GPUBuffer* data, int nx, int ny, int nz, 88 | float* min, float* max); 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /cudaSirecon/gpuFunctionsImpl_hh.cu: -------------------------------------------------------------------------------- 1 | #ifndef GPU_FUNCTIONS_IMPL_H 2 | #define GPU_FUNCTIONS_IMPL_H 3 | 4 | #include "gpuFunctions.h" 5 | #include 6 | #include 7 | #include 8 | #include "../cutilSafeCall.h" 9 | 10 | #ifndef RED_BLOCK_SIZE_X 11 | #define RED_BLOCK_SIZE_X 32 12 | #endif 13 | #ifndef RED_BLOCK_SIZE_Y 14 | #define RED_BLOCK_SIZE_Y 32 15 | #endif 16 | 17 | 18 | /** Data from pParams going into constant memory */ 19 | __constant__ int const_pParams_bSuppress_singularities; 20 | __constant__ int const_pParams_suppression_radius; 21 | __constant__ int const_pParams_bDampenOrder0; 22 | __constant__ int const_pParams_bNoKz0; 23 | __constant__ int const_pParams_bFilteroverlaps; 24 | __constant__ int const_pParams_apodizeoutput; 25 | __constant__ float const_pParams_apoGamma; 26 | __constant__ int const_pParams_bRadAvgOTF; 27 | __constant__ int const_pParams_nzotf; 28 | __constant__ float const_wiener; 29 | 30 | /** These data are not modified in the kernels and can go in constant 31 | * memory */ 32 | __constant__ int const_zdistcutoff[3]; 33 | __constant__ float const_ampmag2[3]; 34 | __constant__ float const_ampmag2_alldirs[9]; 35 | __constant__ cuFloatComplex const_conjamp[3]; 36 | __constant__ float const_noiseVarFactors[9]; 37 | __constant__ float2 const_k0[3]; 38 | __constant__ cuFloatComplex * const_otfPtrs[3]; 39 | 40 | #define MAX_ORDERS 32 41 | #define MAX_PHASES 32 42 | __constant__ float* const_outputPtrs[MAX_ORDERS * 2 -1]; 43 | __constant__ float* const_imgPtrs[MAX_PHASES]; 44 | __constant__ float const_sepMatrix[(MAX_ORDERS * 2 - 1) * MAX_PHASES]; 45 | 46 | __global__ void image_arithmetic_kernel(float* a, const float* b, 47 | int len, float alpha, float beta); 48 | __global__ void apodize_x_kernel(int napodize, int nx, int ny, 49 | float* image); 50 | __global__ void apodize_y_kernel(int napodize, int nx, int ny, 51 | float* image); 52 | __global__ void cosapodize_kernel(int nx, int ny, float* image); 53 | __global__ void rescale_kernel(float* img, int nx, int ny, 54 | float scaleFactor); 55 | __global__ void sum_reduction_kernel(float* img, int nx, int ny, 56 | float* partialReduction); 57 | 58 | __host__ void makeoverlaps(std::vector* bands, 59 | GPUBuffer* overlap0, GPUBuffer* overlap1, int nx, int ny, int nz, 60 | int order1, int order2, 61 | float k0x, float k0y, float dy, float dz, 62 | std::vector* OTF, short wave, ReconParams* pParams); 63 | 64 | __global__ void makeOverlaps0Kernel(int nx, int ny, int nz, 65 | int order1, int order2, float kx, float ky, 66 | float rdistcutoff, float otfcutoff, float zdistcutoff, 67 | float order0_2_factor, float krscale, float kzscale, 68 | cuFloatComplex *band1im, cuFloatComplex *band1re, 69 | cuFloatComplex *overlap0); 70 | __global__ void makeOverlaps1Kernel(int nx, int ny, int nz, 71 | int order1, int order2, float kx, float ky, 72 | float rdistcutoff, float otfcutoff, float zdistcutoff, 73 | float order0_2_factor, float krscale, float kzscale, 74 | cuFloatComplex *band2im, cuFloatComplex *band2re, 75 | cuFloatComplex *overlap1); 76 | __device__ cuFloatComplex dev_otfinterpolateMkOvrLps( 77 | cuFloatComplex * otf, float kx, float ky, float krscale, int kz, 78 | float kzscale, int mask); 79 | 80 | __host__ void aTimesConjB(GPUBuffer* overlap0, GPUBuffer* overlap1, 81 | int nx, int ny, int nz, GPUBuffer* crosscorr_c); 82 | __global__ void aTimesConjBKernel(cuFloatComplex* overlap0, 83 | cuFloatComplex* overlap1, int nx, int ny, int nz, 84 | cuFloatComplex* crosscorr_c); 85 | 86 | __host__ void computeIntensities(GPUBuffer* amplitudes, int nx, int ny, 87 | GPUBuffer* intensities); 88 | __global__ void computeIntensitiesKernel(cuFloatComplex* amplitudes, 89 | int nx, int ny, float* intensities); 90 | 91 | __host__ void findpeak(float array[], int sizex, int sizey, vector *peak); 92 | __host__ float fitparabola( float a1, float a2, float a3); 93 | 94 | __host__ void computeIntensities(GPUBuffer* amplitudes, int nx, int ny, 95 | GPUBuffer* intensities); 96 | 97 | __host__ float getmodamp(float kangle, float klength, 98 | std::vector* bands, GPUBuffer* overlap0, GPUBuffer* overlap1, 99 | int nx, int ny,int nz, int order1, int order2, float dy, float dz, 100 | std::vector* otf, short wave, cuFloatComplex* modamp, 101 | int redoarrays, ReconParams *pParams, int bShowDetail); 102 | 103 | __host__ float findrealspacemodamp(std::vector* bands, 104 | GPUBuffer* overlap0, GPUBuffer* overlap1, int nx, int ny, int nz, 105 | int order1, int order2, vector k0, float dy, float dz, 106 | std::vector* OTF, short wave, cuFloatComplex* modamp1, 107 | cuFloatComplex* modamp2, cuFloatComplex* modamp3, int redoarrays, 108 | ReconParams *pParams); 109 | 110 | __global__ void reductionKernel( 111 | int nx, int ny, int nz, 112 | float kx, float ky, 113 | const cuFloatComplex *overlap0, const cuFloatComplex *overlap1, 114 | cuFloatComplex *XStarY, float *sumXMag, float *sumYMag); 115 | 116 | __host__ float fitxyparabola( float x1, float y1, float x2, float y2, 117 | float x3, float y3); 118 | 119 | __device__ cuFloatComplex dev_otfinterpolate(cuFloatComplex * otf, float 120 | kx, float ky, float krscale, int kz, float kzscale); 121 | 122 | __device__ float dev_suppress(float x); 123 | __device__ float dev_mag2(cuFloatComplex x); 124 | __device__ float dev_order0damping(float radius, float zindex, int 125 | rlimit, int zlimit); 126 | __global__ void move_kernel(cuFloatComplex *inarray1, cuFloatComplex *inarray2, int order, 127 | cuFloatComplex *outarray, int nx, int ny, int nz, float 128 | zoomfact, int z_zoom); 129 | __global__ void write_outbuffer_kernel1(cuFloatComplex * bigbuffer, 130 | float * outbuffer, int); 131 | __global__ void write_outbuffer_kernel2(float * coslookup, float * sinlookup, 132 | cuFloatComplex * bigbuffer, float * outbuffer, int); 133 | 134 | __global__ void cos_sin_kernel(float k0x, float k0y, float fact, float * 135 | coslookup, float * sinlookup, int); 136 | 137 | __global__ void filterbands_kernel1(int dir, int ndirs, int order, int norders, int nx, 138 | int ny, int nz, float rdistcutoff, float zapocutoff, float apocutoff, 139 | float krscale, float kzscale, 140 | cuFloatComplex * dev_bandptr, cuFloatComplex * dev_bandptr2, bool bSecondEntry); 141 | 142 | // __global__ void filterbands_kernel2(int dir, int ndirs, int order, int norders, int nx, 143 | // int ny, int nz, float rdistcutoff, float zapocutoff, float apocutoff, 144 | // float krscale, float kzscale, /*cuFloatComplex *dev_scale,*/ cuFloatComplex * dev_tempbandplus, 145 | // cuFloatComplex * dev_bandptr, cuFloatComplex * dev_bandptr2); 146 | 147 | __global__ void filterbands_kernel3(int order, int nx, int ny, int nz, 148 | cuFloatComplex * dev_bandptr, cuFloatComplex * 149 | dev_bandptr2); 150 | 151 | __global__ void filterbands_kernel4(int order, int nx, int ny, int nz, 152 | cuFloatComplex * dev_tempbandplus, cuFloatComplex * dev_bandptr, 153 | cuFloatComplex * dev_bandptr2); 154 | 155 | __global__ void separate_kernel(int norders, int nphases, int nx, int ny, int nz); 156 | __global__ void computeAminAmax_kernel(const float* data, int numElems, 157 | float* maxPartialResult, float* minPartialResult); 158 | 159 | __global__ void summation_kernel(float * img, double * intRes, int n); 160 | __global__ void sumAboveThresh_kernel(float * img, double * intRes, unsigned * counter, float thresh, int n); 161 | __global__ void scale_kernel(float * img, double factor, int n); 162 | 163 | 164 | template 165 | T cpuReduce(const T* vec, int n) { 166 | T red = 0; 167 | for (int i = 0; i < n; ++i) { 168 | red += vec[i]; 169 | } 170 | return red; 171 | } 172 | 173 | cuFloatComplex cpuReduce(const cuFloatComplex* vec, int n) { 174 | cuFloatComplex red; 175 | red.x = 0; 176 | red.y = 0; 177 | for (int i = 0; i < n; ++i) { 178 | red.x += vec[i].x; 179 | red.y += vec[i].y; 180 | } 181 | return red; 182 | } 183 | #endif 184 | -------------------------------------------------------------------------------- /cudaSirecon/tiffhandle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define cimg_for1(bound,i) for (int i = 0; i<(int)(bound); ++i) 4 | #define cimg_forX(width,x) cimg_for1(width,x) 5 | #define cimg_forY(height,y) cimg_for1(height,y) 6 | #define cimg_forZ(depth,z) cimg_for1(depth,z) 7 | #define cimg_forXY(width,height,x,y) cimg_forY(height,y) cimg_forX(width,x) 8 | 9 | 10 | // "t" is the datatype of the TIFF file, while "T" is datatype of memory storage 11 | template 12 | void _load_tiff_tiled_contig(TIFF *const tif, const uint16 samplesperpixel, const uint32 nx, const uint32 ny, const uint32 tw, const uint32 th, const int colind, T *const buffer) { 13 | t *const buf = (t*)_TIFFmalloc(TIFFTileSize(tif)); 14 | if (buf) { 15 | for (unsigned int row = 0; row 35 | void _load_tiff_tiled_separate(TIFF *const tif, const uint16 samplesperpixel, const uint32 nx, const uint32 ny, const uint32 tw, const uint32 th, const int colind, T *const buffer) { 36 | t *const buf = (t*)_TIFFmalloc(TIFFTileSize(tif)); 37 | if (buf) { 38 | // for (unsigned int vv = 0; vv 58 | void _load_tiff_contig(TIFF *const tif, const uint16 samplesperpixel, const uint32 nx, const uint32 ny, const int colind, T *const buffer) { 59 | t *const buf = (t*)_TIFFmalloc(TIFFStripSize(tif)); 60 | if (buf) { 61 | uint32 row, rowsperstrip = (uint32)-1; 62 | TIFFGetField(tif,TIFFTAG_ROWSPERSTRIP,&rowsperstrip); 63 | for (row = 0; rowny?ny-row:rowsperstrip); 65 | tstrip_t strip = TIFFComputeStrip(tif, row, 0); 66 | if ((TIFFReadEncodedStrip(tif,strip,buf,-1))<0) { 67 | _TIFFfree(buf); TIFFClose(tif); 68 | // throw CImgException(_cimg_instance 69 | // "load_tiff() : Invalid strip in file '%s'.", 70 | // cimg_instance, 71 | // TIFFFileName(tif)); 72 | } 73 | const t *ptr = buf; 74 | for (unsigned int rr = 0; rr 87 | void _load_tiff_separate(TIFF *const tif, const uint16 samplesperpixel, const uint32 nx, const uint32 ny, const int colind, T *const buffer) { 88 | t *buf = (t*)_TIFFmalloc(TIFFStripSize(tif)); 89 | if (buf) { 90 | uint32 row, rowsperstrip = (uint32)-1; 91 | TIFFGetField(tif,TIFFTAG_ROWSPERSTRIP,&rowsperstrip); 92 | // for (unsigned int vv = 0; vvny?ny-row:rowsperstrip); 95 | tstrip_t strip = TIFFComputeStrip(tif, row, colind); 96 | if ((TIFFReadEncodedStrip(tif,strip,buf,-1))<0) { 97 | _TIFFfree(buf); TIFFClose(tif); 98 | // throw CImgException(_cimg_instance 99 | // "load_tiff() : Invalid strip in file '%s'.", 100 | // cimg_instance, 101 | // TIFFFileName(tif)); 102 | } 103 | const t *ptr = buf; 104 | for (unsigned int rr = 0;rr 120 | int load_tiff(TIFF *const tif, const unsigned int directory, const unsigned colind, float *const buffer) { 121 | //Read the current directory of channel colind into buffer 122 | if (!TIFFSetDirectory(tif,directory)) return 0; 123 | uint16 samplesperpixel, bitspersample; 124 | uint16 sampleformat = SAMPLEFORMAT_UINT; 125 | uint32 nx,ny; 126 | // const char *const filename = TIFFFileName(tif); 127 | TIFFGetField(tif,TIFFTAG_IMAGEWIDTH,&nx); 128 | TIFFGetField(tif,TIFFTAG_IMAGELENGTH,&ny); 129 | TIFFGetField(tif,TIFFTAG_SAMPLESPERPIXEL,&samplesperpixel); 130 | TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &sampleformat); 131 | TIFFGetFieldDefaulted(tif,TIFFTAG_BITSPERSAMPLE,&bitspersample); 132 | // assign(nx,ny,1,samplesperpixel); 133 | if (bitspersample!=8 || !(samplesperpixel==3 || samplesperpixel==4)) { 134 | uint16 photo, config; 135 | TIFFGetField(tif,TIFFTAG_PLANARCONFIG,&config); 136 | TIFFGetField(tif,TIFFTAG_PHOTOMETRIC,&photo); 137 | if (TIFFIsTiled(tif)) { 138 | uint32 tw, th; 139 | TIFFGetField(tif,TIFFTAG_TILEWIDTH,&tw); 140 | TIFFGetField(tif,TIFFTAG_TILELENGTH,&th); 141 | if (config==PLANARCONFIG_CONTIG) switch (bitspersample) { 142 | case 8 : { 143 | if (sampleformat==SAMPLEFORMAT_UINT) _load_tiff_tiled_contig(tif,samplesperpixel,nx,ny,tw,th, colind, buffer); 144 | else _load_tiff_tiled_contig(tif,samplesperpixel,nx,ny,tw,th, colind, buffer); 145 | } break; 146 | case 16 : 147 | if (sampleformat==SAMPLEFORMAT_UINT) _load_tiff_tiled_contig(tif,samplesperpixel,nx,ny,tw,th, colind, buffer); 148 | else _load_tiff_tiled_contig(tif,samplesperpixel,nx,ny,tw,th, colind, buffer); 149 | break; 150 | case 32 : 151 | if (sampleformat==SAMPLEFORMAT_UINT) _load_tiff_tiled_contig(tif,samplesperpixel,nx,ny,tw,th, colind, buffer); 152 | else if (sampleformat==SAMPLEFORMAT_INT) _load_tiff_tiled_contig(tif,samplesperpixel,nx,ny,tw,th, colind, buffer); 153 | else _load_tiff_tiled_contig(tif,samplesperpixel,nx,ny,tw,th, colind, buffer); 154 | break; 155 | } else switch (bitspersample) { 156 | case 8 : 157 | if (sampleformat==SAMPLEFORMAT_UINT) _load_tiff_tiled_separate(tif,samplesperpixel,nx,ny,tw,th, colind, buffer); 158 | else _load_tiff_tiled_separate(tif,samplesperpixel,nx,ny,tw,th, colind, buffer); 159 | break; 160 | case 16 : 161 | if (sampleformat==SAMPLEFORMAT_UINT) _load_tiff_tiled_separate(tif,samplesperpixel,nx,ny,tw,th, colind, buffer); 162 | else _load_tiff_tiled_separate(tif,samplesperpixel,nx,ny,tw,th, colind, buffer); 163 | break; 164 | case 32 : 165 | if (sampleformat==SAMPLEFORMAT_UINT) _load_tiff_tiled_separate(tif,samplesperpixel,nx,ny,tw,th, colind, buffer); 166 | else if (sampleformat==SAMPLEFORMAT_INT) _load_tiff_tiled_separate(tif,samplesperpixel,nx,ny,tw,th, colind, buffer); 167 | else _load_tiff_tiled_separate(tif,samplesperpixel,nx,ny,tw,th, colind, buffer); 168 | break; 169 | } 170 | } else { 171 | if (config==PLANARCONFIG_CONTIG) switch (bitspersample) { 172 | case 8 : 173 | if (sampleformat==SAMPLEFORMAT_UINT) _load_tiff_contig(tif,samplesperpixel,nx,ny, colind, buffer); 174 | else _load_tiff_contig(tif,samplesperpixel,nx,ny, colind, buffer); 175 | break; 176 | case 16 : 177 | if (sampleformat==SAMPLEFORMAT_UINT) _load_tiff_contig(tif,samplesperpixel,nx,ny, colind, buffer); 178 | else _load_tiff_contig(tif,samplesperpixel,nx,ny, colind, buffer); 179 | break; 180 | case 32 : 181 | if (sampleformat==SAMPLEFORMAT_UINT) _load_tiff_contig(tif,samplesperpixel,nx,ny, colind, buffer); 182 | else if (sampleformat==SAMPLEFORMAT_INT) _load_tiff_contig(tif,samplesperpixel,nx,ny, colind, buffer); 183 | else _load_tiff_contig(tif,samplesperpixel,nx,ny, colind, buffer); 184 | break; 185 | } else switch (bitspersample){ 186 | case 8 : 187 | if (sampleformat==SAMPLEFORMAT_UINT) _load_tiff_separate(tif,samplesperpixel,nx,ny, colind, buffer); 188 | else _load_tiff_separate(tif,samplesperpixel,nx,ny, colind, buffer); 189 | break; 190 | case 16 : 191 | if (sampleformat==SAMPLEFORMAT_UINT) _load_tiff_separate(tif,samplesperpixel,nx,ny, colind, buffer); 192 | else _load_tiff_separate(tif,samplesperpixel,nx,ny, colind, buffer); 193 | break; 194 | case 32 : 195 | if (sampleformat==SAMPLEFORMAT_UINT) _load_tiff_separate(tif,samplesperpixel,nx,ny, colind, buffer); 196 | else if (sampleformat==SAMPLEFORMAT_INT) _load_tiff_separate(tif,samplesperpixel,nx,ny, colind, buffer); 197 | else _load_tiff_separate(tif,samplesperpixel,nx,ny, colind, buffer); 198 | break; 199 | } 200 | } 201 | } else { 202 | uint32 *const raster = (uint32*)_TIFFmalloc(nx*ny*sizeof(uint32)); 203 | if (!raster) { 204 | _TIFFfree(raster); TIFFClose(tif); 205 | // throw CImgException(_cimg_instance 206 | // "load_tiff() : Failed to allocate memory (%s) for file '%s'.", 207 | // cimg_instance, 208 | // cimg::strbuffersize(nx*ny*sizeof(uint32)),filename); 209 | } 210 | TIFFReadRGBAImage(tif,nx,ny,raster,0); 211 | switch (samplesperpixel) { 212 | case 1 : { 213 | cimg_forXY(nx,ny,x,y) buffer[nx*y+x] = (float)((raster[nx*(ny-1-y)+x] + 128)/257); 214 | } break; 215 | case 3 : { 216 | cimg_forXY(nx,ny,x,y) { 217 | int ind=y*nx+x, nxy=nx*ny; 218 | buffer[ind] = (float)TIFFGetR(raster[nx*(ny-1-y)+x]); 219 | buffer[nxy+ind] = (float)TIFFGetG(raster[nx*(ny-1-y)+x]); 220 | buffer[2*nxy+ind] = (float)TIFFGetB(raster[nx*(ny-1-y)+x]); 221 | } 222 | } break; 223 | case 4 : { 224 | cimg_forXY(nx,ny,x,y) { 225 | int ind=y*nx+x, nxy=nx*ny; 226 | buffer[ind] = (float)TIFFGetR(raster[nx*(ny-1-y)+x]); 227 | buffer[nxy+ind] = (float)TIFFGetG(raster[nx*(ny-1-y)+x]); 228 | buffer[2*nxy+ind] = (float)TIFFGetB(raster[nx*(ny-1-y)+x]); 229 | buffer[3*nxy+ind] = (float)TIFFGetA(raster[nx*(ny-1-y)+x]); 230 | } 231 | } break; 232 | } 233 | _TIFFfree(raster); 234 | } 235 | return 1; 236 | } 237 | 238 | 239 | int save_tiff(TIFF *tif, const unsigned int directory, int colind, const int nwaves, 240 | int width, int height, float * buffer, int bIsComplex=0) { 241 | // In case of saving complex-number file (bIsComplex==1), colind indicates saving real or imag part 242 | 243 | if (!tif) return 0; 244 | // const char *const filename = TIFFFileName(tif); 245 | uint32 rowsperstrip = (uint32)-1; 246 | uint16 spp = nwaves, bpp = 32, photometric; 247 | // if (spp==3 || spp==4) photometric = PHOTOMETRIC_RGB; 248 | /*else */photometric = PHOTOMETRIC_MINISBLACK; 249 | TIFFSetDirectory(tif,directory); 250 | TIFFSetField(tif,TIFFTAG_IMAGEWIDTH,width); 251 | TIFFSetField(tif,TIFFTAG_IMAGELENGTH,height); 252 | TIFFSetField(tif,TIFFTAG_ORIENTATION,ORIENTATION_TOPLEFT); 253 | TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,spp); 254 | // if (cimg::type::is_float()) 255 | TIFFSetField(tif,TIFFTAG_SAMPLEFORMAT,3); 256 | // else if (cimg::type::min()==0) TIFFSetField(tif,TIFFTAG_SAMPLEFORMAT,1); 257 | // else TIFFSetField(tif,TIFFTAG_SAMPLEFORMAT,2); 258 | TIFFSetField(tif,TIFFTAG_BITSPERSAMPLE,bpp); 259 | TIFFSetField(tif,TIFFTAG_PLANARCONFIG,PLANARCONFIG_SEPARATE); 260 | TIFFSetField(tif,TIFFTAG_PHOTOMETRIC,photometric); 261 | // TIFFSetField(tif,TIFFTAG_COMPRESSION,compression?(compression-1):COMPRESSION_NONE); 262 | rowsperstrip = TIFFDefaultStripSize(tif,rowsperstrip); 263 | TIFFSetField(tif,TIFFTAG_ROWSPERSTRIP,rowsperstrip); 264 | TIFFSetField(tif,TIFFTAG_FILLORDER,FILLORDER_MSB2LSB); 265 | // t *const buf = (t*)_TIFFmalloc(TIFFStripSize(tif)); 266 | float *const buf = (float*)_TIFFmalloc(TIFFStripSize(tif)); 267 | if (buf) { 268 | for (unsigned int row = 0; rowheight?height-row:rowsperstrip); 270 | tstrip_t strip = TIFFComputeStrip(tif,row,colind); 271 | tsize_t i = 0; 272 | for (unsigned int rr = 0; rr 5 | 6 | // utilities for safe cuda api calls copied from cuda sdk. 7 | // (currently these aren't exported -- file local) 8 | #define cutilSafeCallNoSync(err) __cudaSafeCallNoSync(err, __FILE__, __LINE__) 9 | #define cutilSafeCall(err) __cudaSafeCall (err, __FILE__, __LINE__) 10 | inline static void __cudaSafeCall(cudaError_t err, const char *file, const int line) 11 | { 12 | if (cudaSuccess != err) { 13 | fprintf(stderr, "%s(%i) : cudaSafeCall() Runtime API error %d: %s.\n", 14 | file, line, (int)err, cudaGetErrorString(err)); 15 | exit(-1); 16 | } 17 | } 18 | inline static void __cudaSafeCallNoSync(cudaError_t err, const char *file, const int line) 19 | { 20 | if (cudaSuccess != err) { 21 | fprintf(stderr, "%s(%i) : cudaSafeCallNoSync() Runtime API error %d : %s.\n", 22 | file, line, (int)err, cudaGetErrorString(err)); 23 | exit(-1); 24 | } 25 | } 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /lapack/win32/BLAS.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/lapack/win32/BLAS.lib -------------------------------------------------------------------------------- /lapack/win32/LAPACK.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/lapack/win32/LAPACK.lib -------------------------------------------------------------------------------- /lapack/win32/cblas.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/lapack/win32/cblas.lib -------------------------------------------------------------------------------- /lapack/win32/clapack.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/lapack/win32/clapack.lib -------------------------------------------------------------------------------- /lapack/win32/libf2c.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/lapack/win32/libf2c.lib -------------------------------------------------------------------------------- /lapack/win32/liblapacke.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/lapack/win32/liblapacke.lib -------------------------------------------------------------------------------- /lapack/win64/libblas.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/lapack/win64/libblas.dll -------------------------------------------------------------------------------- /lapack/win64/libblas.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/lapack/win64/libblas.lib -------------------------------------------------------------------------------- /lapack/win64/liblapack.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/lapack/win64/liblapack.dll -------------------------------------------------------------------------------- /lapack/win64/liblapack.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/lapack/win64/liblapack.lib -------------------------------------------------------------------------------- /lapack/win64/liblapacke.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/lapack/win64/liblapacke.dll -------------------------------------------------------------------------------- /lapack/win64/libtmglib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/lapack/win64/libtmglib.dll -------------------------------------------------------------------------------- /lapack/win64/libtmglib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandobbie/CUDA_SIMrecon/545a3d0c58c03992b58f3c254acc67205c5c4ed0/lapack/win64/libtmglib.lib --------------------------------------------------------------------------------