From 4d7e369e994b0eb47ea2e71864d24bcede536b55 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Sat, 29 Aug 2015 12:38:48 -0400 Subject: [PATCH 01/16] Increment version to 3.1.1 --- CMakeModules/Version.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeModules/Version.cmake b/CMakeModules/Version.cmake index 26d1e8c9f4..534735f930 100644 --- a/CMakeModules/Version.cmake +++ b/CMakeModules/Version.cmake @@ -3,7 +3,7 @@ # SET(AF_VERSION_MAJOR "3") SET(AF_VERSION_MINOR "1") -SET(AF_VERSION_PATCH "0") +SET(AF_VERSION_PATCH "1") SET(AF_VERSION "${AF_VERSION_MAJOR}.${AF_VERSION_MINOR}.${AF_VERSION_PATCH}") SET(AF_API_VERSION_CURRENT ${AF_VERSION_MAJOR}${AF_VERSION_MINOR}) From e0b8b5b22df4a8c4641ec948db24c5dc45082d67 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Sat, 29 Aug 2015 12:39:11 -0400 Subject: [PATCH 02/16] Fixes for snprintf on windows * Non-graphics build fails with snprintf errors in opencl magma --- src/backend/opencl/magma/magma_cpu_blas.h | 1 + src/backend/opencl/magma/magma_cpu_lapack.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/backend/opencl/magma/magma_cpu_blas.h b/src/backend/opencl/magma/magma_cpu_blas.h index 9375c67a33..6ae4f8f39f 100644 --- a/src/backend/opencl/magma/magma_cpu_blas.h +++ b/src/backend/opencl/magma/magma_cpu_blas.h @@ -10,6 +10,7 @@ #ifndef MAGMA_CPU_BLAS #define MAGMA_CPU_BLAS #include +#include #include "magma_types.h" #ifdef __APPLE__ diff --git a/src/backend/opencl/magma/magma_cpu_lapack.h b/src/backend/opencl/magma/magma_cpu_lapack.h index f737acb987..5974dab8a9 100644 --- a/src/backend/opencl/magma/magma_cpu_lapack.h +++ b/src/backend/opencl/magma/magma_cpu_lapack.h @@ -11,6 +11,7 @@ #define MAGMA_CPU_LAPACK #include +#include #include "magma_types.h" #define LAPACKE_sunmqr_work(...) LAPACKE_sormqr_work(__VA_ARGS__) From 095f29e9ebdb47c917197d914039730d3f8a80b7 Mon Sep 17 00:00:00 2001 From: Pavan Yalamanchili Date: Wed, 2 Sep 2015 14:03:05 -0400 Subject: [PATCH 03/16] BUGFIX: For calculating number of elements for a buffer in CUDA backend --- src/backend/cuda/kernel/fftconvolve.hpp | 18 ++++++++++++++---- src/backend/cuda/kernel/ireduce.hpp | 2 +- src/backend/cuda/kernel/reduce.hpp | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/backend/cuda/kernel/fftconvolve.hpp b/src/backend/cuda/kernel/fftconvolve.hpp index 2acf2db621..186fb117de 100644 --- a/src/backend/cuda/kernel/fftconvolve.hpp +++ b/src/backend/cuda/kernel/fftconvolve.hpp @@ -262,8 +262,13 @@ void packDataHelper(Param sig_packed, { dim_t *sd = sig.dims; - int sig_packed_elem = sig_packed.strides[3] * sig_packed.dims[3]; - int filter_packed_elem = filter_packed.strides[3] * filter_packed.dims[3]; + int sig_packed_elem = 1; + int filter_packed_elem = 1; + + for (int i = 0; i < 4; i++) { + sig_packed_elem *= sig_packed.dims[i]; + filter_packed_elem *= filter_packed.dims[i]; + } // Number of packed complex elements in dimension 0 int sig_half_d0 = divup(sd[0], 2); @@ -292,8 +297,13 @@ void complexMultiplyHelper(Param out, CParam filter, ConvolveBatchKind kind) { - int sig_packed_elem = sig_packed.strides[3] * sig_packed.dims[3]; - int filter_packed_elem = filter_packed.strides[3] * filter_packed.dims[3]; + int sig_packed_elem = 1; + int filter_packed_elem = 1; + + for (int i = 0; i < 4; i++) { + sig_packed_elem *= sig_packed.dims[i]; + filter_packed_elem *= filter_packed.dims[i]; + } dim3 threads(THREADS); dim3 blocks(divup(sig_packed_elem / 2, threads.x)); diff --git a/src/backend/cuda/kernel/ireduce.hpp b/src/backend/cuda/kernel/ireduce.hpp index 4f9cac5baf..4a2ab14777 100644 --- a/src/backend/cuda/kernel/ireduce.hpp +++ b/src/backend/cuda/kernel/ireduce.hpp @@ -444,7 +444,7 @@ namespace kernel template T ireduce_all(uint *idx, CParam in) { - int in_elements = in.strides[3] * in.dims[3]; + int in_elements = in.dims[0] * in.dims[1] * in.dims[2] * in.dims[3]; // FIXME: Use better heuristics to get to the optimum number if (in_elements > 4096) { diff --git a/src/backend/cuda/kernel/reduce.hpp b/src/backend/cuda/kernel/reduce.hpp index be52375525..8cc720fb69 100644 --- a/src/backend/cuda/kernel/reduce.hpp +++ b/src/backend/cuda/kernel/reduce.hpp @@ -371,7 +371,7 @@ namespace kernel template To reduce_all(CParam in, bool change_nan, double nanval) { - int in_elements = in.strides[3] * in.dims[3]; + int in_elements = in.dims[0] * in.dims[1] * in.dims[2] * in.dims[3]; // FIXME: Use better heuristics to get to the optimum number if (in_elements > 4096) { From 619ecf70230c3322573140df2b06b08dd7102b5c Mon Sep 17 00:00:00 2001 From: Pavan Yalamanchili Date: Wed, 2 Sep 2015 14:04:01 -0400 Subject: [PATCH 04/16] BUGFIX: For calculating number of elements for a buffer in OpenCL backend --- src/backend/opencl/kernel/ireduce.hpp | 6 ++++-- src/backend/opencl/kernel/reduce.hpp | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/backend/opencl/kernel/ireduce.hpp b/src/backend/opencl/kernel/ireduce.hpp index 5fa0fa6952..8bc06f2f5f 100644 --- a/src/backend/opencl/kernel/ireduce.hpp +++ b/src/backend/opencl/kernel/ireduce.hpp @@ -332,7 +332,7 @@ namespace kernel T ireduce_all(uint *loc, Param in) { try { - int in_elements = in.info.dims[3] * in.info.strides[3]; + int in_elements = in.info.dims[0] * in.info.dims[1] * in.info.dims[2] * in.info.dims[3]; // FIXME: Use better heuristics to get to the optimum number if (in_elements > 4096) { @@ -397,7 +397,9 @@ namespace kernel unique_ptr h_ptr(new T[in_elements]); T* h_ptr_raw = h_ptr.get(); - getQueue().enqueueReadBuffer(*in.data, CL_TRUE, 0, sizeof(T) * in_elements, h_ptr_raw); + + getQueue().enqueueReadBuffer(*in.data, CL_TRUE, sizeof(T) * in.info.offset, + sizeof(T) * in_elements, h_ptr_raw); MinMaxOp Op(h_ptr_raw[0], 0); diff --git a/src/backend/opencl/kernel/reduce.hpp b/src/backend/opencl/kernel/reduce.hpp index 5ac55b58da..e46d5e41ab 100644 --- a/src/backend/opencl/kernel/reduce.hpp +++ b/src/backend/opencl/kernel/reduce.hpp @@ -287,7 +287,7 @@ namespace kernel To reduce_all(Param in, int change_nan, double nanval) { try { - int in_elements = in.info.dims[3] * in.info.strides[3]; + int in_elements = in.info.dims[0] * in.info.dims[1] * in.info.dims[2] * in.info.dims[3]; // FIXME: Use better heuristics to get to the optimum number if (in_elements > 4096) { @@ -342,7 +342,8 @@ namespace kernel } else { unique_ptr h_ptr(new Ti[in_elements]); - getQueue().enqueueReadBuffer(*in.data, CL_TRUE, 0, sizeof(Ti) * in_elements, h_ptr.get()); + getQueue().enqueueReadBuffer(*in.data, CL_TRUE, sizeof(Ti) * in.info.offset, + sizeof(Ti) * in_elements, h_ptr.get()); Transform transform; Binary reduce; From bce6967930002512997c82ac5398a0d93ea9b474 Mon Sep 17 00:00:00 2001 From: Pavan Yalamanchili Date: Wed, 2 Sep 2015 14:29:04 -0400 Subject: [PATCH 05/16] TEST: Adding tests for indexed reductions --- test/ireduce.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ test/reduce.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/test/ireduce.cpp b/test/ireduce.cpp index 18461c5ee5..17abfcf8e4 100644 --- a/test/ireduce.cpp +++ b/test/ireduce.cpp @@ -12,6 +12,7 @@ #include #include #include +#include using namespace std; using namespace af; @@ -98,3 +99,47 @@ MINMAXOP(max, int) MINMAXOP(max, uint) MINMAXOP(max, char) MINMAXOP(max, uchar) + +TEST(ImaxAll, IndexedSmall) +{ + const int num = 1000; + const int st = 10; + const int en = num - 100; + af::array a = af::randu(num); + + float b; + unsigned idx; + af::max(&b, &idx, a(af::seq(st, en))); + + std::vector ha(num); + a.host(&ha[0]); + + float res = ha[st]; + for (int i = st; i <= en; i++) { + res = std::max(res, ha[i]); + } + + ASSERT_EQ(b, res); +} + +TEST(ImaxAll, IndexedBig) +{ + const int num = 100000; + const int st = 1000; + const int en = num - 1000; + af::array a = af::randu(num); + + float b; + unsigned idx; + af::max(&b, &idx, a(af::seq(st, en))); + + std::vector ha(num); + a.host(&ha[0]); + + float res = ha[st]; + for (int i = st; i <= en; i++) { + res = std::max(res, ha[i]); + } + + ASSERT_EQ(b, res); +} diff --git a/test/reduce.cpp b/test/reduce.cpp index ad99430e17..000f1ea961 100644 --- a/test/reduce.cpp +++ b/test/reduce.cpp @@ -15,6 +15,7 @@ #include #include #include +#include using std::vector; using std::string; @@ -522,3 +523,41 @@ TEST(AnyAll, NaN) ASSERT_EQ(af::anyTrue(A), true); ASSERT_EQ(af::allTrue(A), false); } + +TEST(MaxAll, IndexedSmall) +{ + const int num = 1000; + const int st = 10; + const int en = num - 100; + af::array a = af::randu(num); + float b = af::max(a(af::seq(st, en))); + + std::vector ha(num); + a.host(&ha[0]); + + float res = ha[st]; + for (int i = st; i <= en; i++) { + res = std::max(res, ha[i]); + } + + ASSERT_EQ(b, res); +} + +TEST(MaxAll, IndexedBig) +{ + const int num = 100000; + const int st = 1000; + const int en = num - 1000; + af::array a = af::randu(num); + float b = af::max(a(af::seq(st, en))); + + std::vector ha(num); + a.host(&ha[0]); + + float res = ha[st]; + for (int i = st; i <= en; i++) { + res = std::max(res, ha[i]); + } + + ASSERT_EQ(b, res); +} From 64a0dbff82c32dae51b2574850a26c4a78d90af6 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Mon, 31 Aug 2015 15:39:01 -0400 Subject: [PATCH 06/16] DOC fix for AF_PATH rendering missing % --- docs/pages/using_on_windows.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/pages/using_on_windows.md b/docs/pages/using_on_windows.md index 04bb8917e6..aa4aeff2d0 100644 --- a/docs/pages/using_on_windows.md +++ b/docs/pages/using_on_windows.md @@ -24,7 +24,7 @@ to the location of the executables. ## Step 1: Adding ArrayFire to PATH for all users The ArrayFire installer for Windows creates a user `PATH` variable containing -`%AF_PATH%/lib`. This is required so that Windows knows where to find the +`%%AF_PATH%/lib`. This is required so that Windows knows where to find the ArrayFire DLLs. This variable fixes the DLL finding only for the user that installs ArrayFire. @@ -42,9 +42,9 @@ To allow DLL detection for all users, it needs to be added to the system 3. Click on _Environment Variables_, then under **System Variables**, find `PATH`, and click on it. -4. In edit mode, append `%AF_PATH%/lib`. NOTE: Ensure that there is a semi-colon - separating `%AF_PATH%/lib` from any existing content (e.g. - `EXISTING_PATHS;%AF_PATH%/lib;`) otherwise other software may not function +4. In edit mode, append `%%AF_PATH%/lib`. NOTE: Ensure that there is a semi-colon + separating `%%AF_PATH%/lib` from any existing content (e.g. + `EXISTING_PATHS;%%AF_PATH%/lib;`) otherwise other software may not function correctly. ## Step 2: Verify the path addition functions correctly From e87a0034db4377b9c15c88e36d769b59f12e6c7b Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Fri, 4 Sep 2015 14:37:39 -0400 Subject: [PATCH 07/16] Read me fixes --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fbfc94dd69..b5aa3b0eef 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ A few lines of code in ArrayFire can replace dozens of lines of parallel computi To build ArrayFire from source, please follow the instructions on our [wiki](https://github.com/arrayfire/arrayfire/wiki). ### Download ArrayFire Installers -We currently have binary tar balls and installers available for the beta version of ArrayFire 3.0. These can be downloaded at the [ArrayFire Downloads](http://go.arrayfire.com/l/37882/2015-03-31/mmhqy) page. +ArrayFire binary installers can be downloaded at the [ArrayFire Downloads](http://go.arrayfire.com/l/37882/2015-03-31/mmhqy) page. ### Support and Contact Info [![Join the chat at https://gitter.im/arrayfire/arrayfire](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/arrayfire/arrayfire?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) @@ -118,7 +118,7 @@ following reference: Formatted: ``` Yalamanchili, P., Arshad, U., Mohammed, Z., Garigipati, P., Entschev, P., -Kloppenborg, B., Malcolm, James and Melonakos, J. (2015). +Kloppenborg, B., Malcolm, J. and Melonakos, J. (2015). ArrayFire - A high performance software library for parallel computing with an easy-to-use API. Atlanta: AccelerEyes. Retrieved from https://github.com/arrayfire/arrayfire ``` From 644d074867ff35821a87b3b6794efe6e7cd4006a Mon Sep 17 00:00:00 2001 From: Marius Brehler Date: Tue, 8 Sep 2015 15:20:57 +0200 Subject: [PATCH 08/16] Try PkgConf first to find CBLAS --- CMakeModules/FindCBLAS.cmake | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CMakeModules/FindCBLAS.cmake b/CMakeModules/FindCBLAS.cmake index ee47b3af5a..d08b3c25aa 100644 --- a/CMakeModules/FindCBLAS.cmake +++ b/CMakeModules/FindCBLAS.cmake @@ -21,6 +21,29 @@ SET(CBLAS_INCLUDE_DIR CACHE STRING SET(CBLAS_INCLUDE_FILE CACHE STRING "CBLAS header name") + +# If a valid PkgConfig configuration for cblas is found, this overrides and cancels +# all further checks. +FIND_PACKAGE(PkgConfig) +IF(PKG_CONFIG_FOUND) + PKG_CHECK_MODULES(PC_CBLAS cblas) +ENDIF(PKG_CONFIG_FOUND) + +IF(PC_CBLAS_FOUND) + + FOREACH(PC_LIB ${PC_CBLAS_LIBRARIES}) + FIND_LIBRARY(${PC_LIB}_LIBRARY NAMES ${PC_LIB} HINTS ${PC_CBLAS_LIBRARY_DIRS} ) + IF (NOT ${PC_LIB}_LIBRARY) + message(FATAL_ERROR "Something is wrong in your pkg-config file - lib ${PC_LIB} not found in ${PC_CBLAS_LIBRARY_DIRS}") + ENDIF (NOT ${PC_LIB}_LIBRARY) + LIST(APPEND CBLAS_LIBRARIES ${${PC_LIB}_LIBRARY}) + ENDFOREACH(PC_LIB) + + FIND_PACKAGE_HANDLE_STANDARD_ARGS(CBLAS DEFAULT_MSG CBLAS_LIBRARIES) + MARK_AS_ADVANCED(CBLAS_LIBRARIES) + +ELSE(PC_CBLAS_FOUND) + SET(INTEL_MKL_ROOT_DIR CACHE STRING "Root directory of the Intel MKL") @@ -277,3 +300,5 @@ IF(NOT CBLAS_FIND_QUIETLY) MESSAGE(STATUS "CBLAS library not found.") ENDIF() ENDIF(NOT CBLAS_FIND_QUIETLY) + +ENDIF(PC_CBLAS_FOUND) From fc0ed4182e7a0d1f940c73397c77202baff2b7ce Mon Sep 17 00:00:00 2001 From: Marius Brehler Date: Tue, 8 Sep 2015 15:21:49 +0200 Subject: [PATCH 09/16] Try PkgConf first to find LAPACKE --- CMakeModules/FindLAPACKE.cmake | 144 ++++++++++++++++++++------------- 1 file changed, 86 insertions(+), 58 deletions(-) diff --git a/CMakeModules/FindLAPACKE.cmake b/CMakeModules/FindLAPACKE.cmake index 05d218aa86..945ba0cb58 100644 --- a/CMakeModules/FindLAPACKE.cmake +++ b/CMakeModules/FindLAPACKE.cmake @@ -18,70 +18,23 @@ FIND_PACKAGE(PkgConfig) #Determine from PKG IF(PKG_CONFIG_FOUND AND NOT LAPACKE_ROOT) - PKG_CHECK_MODULES( PKG_LAPACKE QUIET "lapacke") + PKG_CHECK_MODULES( PC_LAPACKE QUIET "lapacke") ENDIF() -IF(LAPACKE_ROOT) - #find libs - FIND_LIBRARY( - LAPACKE_LIB - NAMES "lapacke" "LAPACKE" "liblapacke" - PATHS ${LAPACKE_ROOT} - PATH_SUFFIXES "lib" "lib64" - DOC "LAPACKE Library" - NO_DEFAULT_PATH - ) - FIND_LIBRARY( - LAPACK_LIB - NAMES "lapack" "LAPACK" "liblapack" - PATHS ${LAPACKE_ROOT} - PATH_SUFFIXES "lib" "lib64" - DOC "LAPACK Library" - NO_DEFAULT_PATH - ) - FIND_PATH( - LAPACKE_INCLUDES - NAMES "lapacke.h" - PATHS ${LAPACKE_ROOT} - PATH_SUFFIXES "include" - DOC "LAPACKE Include Directory" - NO_DEFAULT_PATH - ) +IF(PC_LAPACKE_FOUND) + FOREACH(PC_LIB ${PC_LAPACKE_LIBRARIES}) + FIND_LIBRARY(${PC_LIB}_LIBRARY NAMES ${PC_LIB} HINTS ${PC_LAPACKE_LIBRARY_DIRS} ) + IF (NOT ${PC_LIB}_LIBRARY) + MESSAGE(FATAL_ERROR "Something is wrong in your pkg-config file - lib ${PC_LIB} not found in ${PC_LAPACKE_LIBRARY_DIRS}") + ENDIF (NOT ${PC_LIB}_LIBRARY) + LIST(APPEND LAPACKE_LIB ${${PC_LIB}_LIBRARY}) + ENDFOREACH(PC_LIB) -ELSE() - FIND_LIBRARY( - LAPACKE_LIB - NAMES "lapacke" "liblapacke" - PATHS - ${PKG_LAPACKE_LIBRARY_DIRS} - ${LIB_INSTALL_DIR} - /usr/lib64 - /usr/lib - /usr/local/lib64 - /usr/local/lib - /sw/lib - /opt/local/lib - DOC "LAPACKE Library" - ) - FIND_LIBRARY( - LAPACK_LIB - NAMES "lapack" "liblapack" - PATHS - ${PKG_LAPACKE_LIBRARY_DIRS} - ${LIB_INSTALL_DIR} - /usr/lib64 - /usr/lib - /usr/local/lib64 - /usr/local/lib - /sw/lib - /opt/local/lib - DOC "LAPACK Library" - ) FIND_PATH( LAPACKE_INCLUDES NAMES "lapacke.h" PATHS - ${PKG_LAPACKE_INCLUDE_DIRS} + ${PC_LAPACKE_INCLUDE_DIRS} ${INCLUDE_INSTALL_DIR} /usr/include /usr/local/include @@ -89,7 +42,82 @@ ELSE() /opt/local/include DOC "LAPACKE Include Directory" ) -ENDIF(LAPACKE_ROOT) + + FIND_PACKAGE_HANDLE_STANDARD_ARGS(LAPACKE DEFAULT_MSG LAPACKE_LIB) + MARK_AS_ADVANCED(LAPACKE_INCLUDES LAPACKE_LIB) + +ELSE(PC_LAPACKE_FOUND) + + IF(LAPACKE_ROOT) + #find libs + FIND_LIBRARY( + LAPACKE_LIB + NAMES "lapacke" "LAPACKE" "liblapacke" + PATHS ${LAPACKE_ROOT} + PATH_SUFFIXES "lib" "lib64" + DOC "LAPACKE Library" + NO_DEFAULT_PATH + ) + FIND_LIBRARY( + LAPACK_LIB + NAMES "lapack" "LAPACK" "liblapack" + PATHS ${LAPACKE_ROOT} + PATH_SUFFIXES "lib" "lib64" + DOC "LAPACK Library" + NO_DEFAULT_PATH + ) + FIND_PATH( + LAPACKE_INCLUDES + NAMES "lapacke.h" + PATHS ${LAPACKE_ROOT} + PATH_SUFFIXES "include" + DOC "LAPACKE Include Directory" + NO_DEFAULT_PATH + ) + + ELSE() + FIND_LIBRARY( + LAPACKE_LIB + NAMES "lapacke" "liblapacke" + PATHS + ${PC_LAPACKE_LIBRARY_DIRS} + ${LIB_INSTALL_DIR} + /usr/lib64 + /usr/lib + /usr/local/lib64 + /usr/local/lib + /sw/lib + /opt/local/lib + DOC "LAPACKE Library" + ) + FIND_LIBRARY( + LAPACK_LIB + NAMES "lapack" "liblapack" + PATHS + ${PC_LAPACKE_LIBRARY_DIRS} + ${LIB_INSTALL_DIR} + /usr/lib64 + /usr/lib + /usr/local/lib64 + /usr/local/lib + /sw/lib + /opt/local/lib + DOC "LAPACK Library" + ) + FIND_PATH( + LAPACKE_INCLUDES + NAMES "lapacke.h" + PATHS + ${PC_LAPACKE_INCLUDE_DIRS} + ${INCLUDE_INSTALL_DIR} + /usr/include + /usr/local/include + /sw/include + /opt/local/include + DOC "LAPACKE Include Directory" + ) + ENDIF(LAPACKE_ROOT) +ENDIF(PC_LAPACKE_FOUND) SET(LAPACK_LIBRARIES ${LAPACKE_LIB} ${LAPACK_LIB}) SET(LAPACK_INCLUDE_DIR ${LAPACKE_INCLUDES}) From 887ae72395593f55317b27a03409a0089e182032 Mon Sep 17 00:00:00 2001 From: Pavan Yalamanchili Date: Fri, 11 Sep 2015 11:29:43 -0400 Subject: [PATCH 10/16] Changes to Heston model to remove c++11 dependencies --- examples/financial/heston_model.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/financial/heston_model.cpp b/examples/financial/heston_model.cpp index 617e04be05..581f89994e 100644 --- a/examples/financial/heston_model.cpp +++ b/examples/financial/heston_model.cpp @@ -29,22 +29,21 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************************************/ +#include #include #include -#include -#include using namespace std; using namespace af; -tuple -simulateHestonModel(float T, unsigned int N, unsigned int R, float mu, float kappa, - float vBar, float sigmaV, float rho, float x0, float v0) +void simulateHestonModel(af::array &xres, af::array &vres, + float T, unsigned int N, unsigned int R, float mu, float kappa, + float vBar, float sigmaV, float rho, float x0, float v0) { float deltaT = T / (float)(N - 1); - std::vector x = {af::constant(x0, R), af::constant(0, R)}; - std::vector v = {af::constant(v0, R), af::constant(0, R)}; + af::array x[] = {af::constant(x0, R), af::constant(0, R)}; + af::array v[] = {af::constant(v0, R), af::constant(0, R)}; float sqrtDeltaT = sqrt(deltaT); @@ -68,7 +67,8 @@ simulateHestonModel(float T, unsigned int N, unsigned int R, float mu, float kap v[tCurrent] = max(vTmp, zeroConstant); } - return std::make_tuple(x[tCurrent], v[tCurrent]); + xres = x[tCurrent]; + vres = v[tCurrent]; } int main() @@ -94,11 +94,11 @@ int main() af::array v; // first run - std::tie(x, v) = simulateHestonModel(T, nT, R_first_run, r, kappa, vBar, sigmaV, rho, x0, v0); + simulateHestonModel(x, v, T, nT, R_first_run, r, kappa, vBar, sigmaV, rho, x0, v0); af::sync(); // Ensure the first run is finished timer::start(); - std::tie(x, v) = simulateHestonModel(T, nT, R, r, kappa, vBar, sigmaV, rho, x0, v0); + simulateHestonModel(x, v, T, nT, R, r, kappa, vBar, sigmaV, rho, x0, v0); af::sync(); cout << "Time in simulation: " << timer::stop() << endl; From 714cdc0f5becef4f3e91006f78dec4a96c8cc9e1 Mon Sep 17 00:00:00 2001 From: Pavan Yalamanchili Date: Fri, 11 Sep 2015 14:32:02 -0400 Subject: [PATCH 11/16] BUGFIX: seq.begin can now use negative offsets just like seq.end --- src/api/cpp/array.cpp | 9 +++------ src/api/cpp/index.cpp | 2 +- src/api/cpp/seq.cpp | 2 +- src/backend/dim4.cpp | 22 ++++++++-------------- 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/api/cpp/array.cpp b/src/api/cpp/array.cpp index 7615c39b5a..3280457e19 100644 --- a/src/api/cpp/array.cpp +++ b/src/api/cpp/array.cpp @@ -374,8 +374,7 @@ namespace af const array::array_proxy array::row(int index) const { - seq idx(index, index, 1); - return this->operator()(idx, span, span, span); + return this->operator()(index, span, span, span); } array::array_proxy array::row(int index) @@ -385,8 +384,7 @@ namespace af const array::array_proxy array::col(int index) const { - seq idx(index, index, 1); - return this->operator()(span, idx, span, span); + return this->operator()(span, index, span, span); } array::array_proxy array::col(int index) @@ -396,8 +394,7 @@ namespace af const array::array_proxy array::slice(int index) const { - seq idx(index, index, 1); - return this->operator()(span, span, idx, span); + return this->operator()(span, span, index, span); } array::array_proxy array::slice(int index) diff --git a/src/api/cpp/index.cpp b/src/api/cpp/index.cpp index ccc698bc3c..d7a0cd1c76 100644 --- a/src/api/cpp/index.cpp +++ b/src/api/cpp/index.cpp @@ -75,7 +75,7 @@ index::index(const af::array& idx0) { impl.isBatch = false; } -index::index(const af::index& idx0) { +index::index(const af::index& idx0) { *this = idx0; } diff --git a/src/api/cpp/seq.cpp b/src/api/cpp/seq.cpp index d1433563ba..388fa4103b 100644 --- a/src/api/cpp/seq.cpp +++ b/src/api/cpp/seq.cpp @@ -46,7 +46,7 @@ seq::~seq() seq::seq(double n): m_gfor(false) { if (n < 0) { - init(n + 1, 0, 1); // seq(-4) = -3, -2, -1, 0 + init(0, n, 1); } else { init(0, n - 1, 1); } diff --git a/src/backend/dim4.cpp b/src/backend/dim4.cpp index 41ea56a336..d1f69d2044 100644 --- a/src/backend/dim4.cpp +++ b/src/backend/dim4.cpp @@ -176,7 +176,7 @@ dim4 operator*(const dim4& first, const dim4& second) bool -isEnd(const af_seq &seq) { return (seq.end <= -1); } +hasEnd(const af_seq &seq) { return (seq.begin <= -1 || seq.end <= -1); } bool isSpan(const af_seq &seq) { return (seq.step == 0 && seq.begin == 1 && seq.end == 1); } @@ -196,18 +196,11 @@ dim_t calcDim(const af_seq &seq, const dim_t &parentDim) dim_t outDim = 1; if (isSpan(seq)) { outDim = parentDim; - } else if (isEnd(seq)) { - if(seq.begin == -1) { // only end is passed as seq - outDim = 1; - } else if (seq.begin < 0) { - af_seq temp = {parentDim + seq.begin, - parentDim + seq.end, - seq.step}; - outDim = seqElements(temp); - } else { // end is passed as a part of seq - af_seq temp = {seq.begin, parentDim + seq.end, seq.step}; - outDim = seqElements(temp); - } + } else if (hasEnd(seq)) { + af_seq temp = {seq.begin, seq.end, seq.step}; + if (seq.begin < 0) temp.begin += parentDim; + if (seq.end < 0) temp.end += parentDim; + outDim = seqElements(temp); } else { DIM_ASSERT(1, seq.begin >= -DBL_MIN && seq.begin < parentDim); DIM_ASSERT(1, seq.end < parentDim); @@ -216,7 +209,8 @@ dim_t calcDim(const af_seq &seq, const dim_t &parentDim) return outDim; } -} + +} // end namespace af using af::dim4; using std::vector; From 01af9623a96b7ca5b136c7ab05bd82e51b6c1c3d Mon Sep 17 00:00:00 2001 From: Pavan Yalamanchili Date: Fri, 11 Sep 2015 14:33:59 -0400 Subject: [PATCH 12/16] Updating Release notes for 3.1.1 --- docs/pages/release_notes.md | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 0ba0ae0049..fd52334e62 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -1,6 +1,27 @@ Release Notes {#releasenotes} ============== +v3.1.1 +============== + +Installers +----------- + +* CUDA backend now depends on CUDA 7.5 toolkit +* OpenCL backend now require OpenCL 1.2 or greater + +Bug Fixes +-------------- + +* Fixed [bug](https://github.com/arrayfire/arrayfire/issues/981) in reductions after indexing +* Fixed [bug](https://github.com/arrayfire/arrayfire/issues/976) in indexing when using reverse indices + +Build +------ + +* `cmake` now includes `PKG_CONFIG` in the search path for CBLAS and LAPACKE libraries +* `heston_model` example now builds with the default ArrayFire cmake files after installation + v3.1.0 ============== @@ -105,7 +126,7 @@ Bug Fixes * Fix compatibility of c32/c64 arrays when operating with scalars * Fix median for all values of an array * Fix double free issue when indexing (30cbbc7) - * Fix bug in rank + * Fix [bug](https://github.com/arrayfire/arrayfire/issues/901) in rank * Fix default values for scale throwing exception * Fix conjg raising exception on real input * Fix bug when using conjugate transpose for vector input @@ -115,7 +136,7 @@ Bug Fixes * Fix setSeed for randu * Fix casting to and from complex * Check NULL values when allocating memory - * Fix offset issue for CPU element-wise operations + * Fix [offset issue](https://github.com/arrayfire/arrayfire/issues/923) for CPU element-wise operations New Examples ------------ @@ -123,12 +144,10 @@ New Examples * Susan * Heston Model (contributed by Michael Nowotny) -Distribution Changes --------------------- -* Fixed automatic detection of ArrayFire when using with CMake in the Windows - Installer -* Compiling ArrayFire with FreeImage as a static library for Linux x86 - installers +Installer +---------- +* Fixed bug in automatic detection of ArrayFire when using with CMake in Windows +* The Linux libraries are now compiled with static version of FreeImage Known Issues ------------ From eb9fde9179306e031cbbe82e9d9a1d663b3de99c Mon Sep 17 00:00:00 2001 From: Pavan Yalamanchili Date: Fri, 11 Sep 2015 16:03:28 -0400 Subject: [PATCH 13/16] BUG: Fixing seq when passing af::end to af::seq --- src/api/cpp/seq.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/api/cpp/seq.cpp b/src/api/cpp/seq.cpp index 388fa4103b..a9d5df637e 100644 --- a/src/api/cpp/seq.cpp +++ b/src/api/cpp/seq.cpp @@ -65,10 +65,6 @@ seq& seq::operator=(const af_seq& s_) seq::seq(double begin, double end, double step): m_gfor(false) { - if(begin == -1 && end <= -1) { - step = 0; // end - } - if (step == 0) { if (begin != end) // Span AF_THROW_MSG("Invalid step size", AF_ERR_ARG); From 3d7f26b2d25064c2b29fdafd6fe86de5aec66742 Mon Sep 17 00:00:00 2001 From: pradeep Date: Fri, 11 Sep 2015 19:06:50 -0400 Subject: [PATCH 14/16] bug fix in image_editing example --- examples/image_processing/image_editing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/image_processing/image_editing.cpp b/examples/image_processing/image_editing.cpp index 85b2f73cc8..d765734559 100644 --- a/examples/image_processing/image_editing.cpp +++ b/examples/image_processing/image_editing.cpp @@ -101,7 +101,7 @@ int main(int argc, char **argv) array man = loadImage(ASSETS_DIR "/examples/images/man.jpg", true); array fight = loadImage(ASSETS_DIR "/examples/images/fight.jpg", true); - array nature = loadImage(ASSETS_DIR "/examples/images/nature.jpg", true); + array nature = resize(loadImage(ASSETS_DIR "/examples/images/nature.jpg", true), fight.dims(0), fight.dims(1)); array intensity = colorSpace(fight, AF_GRAY, AF_RGB); array mask = clamp(intensity, 10.0f, 255.0f)>0.0f; From f2474cfc96826e3084f00a6272fc776379961880 Mon Sep 17 00:00:00 2001 From: pradeep Date: Fri, 11 Sep 2015 20:11:33 -0400 Subject: [PATCH 15/16] Updated forge tag for 3.1 release --- CMakeModules/build_forge.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeModules/build_forge.cmake b/CMakeModules/build_forge.cmake index b376895942..a0757bfe26 100644 --- a/CMakeModules/build_forge.cmake +++ b/CMakeModules/build_forge.cmake @@ -22,7 +22,7 @@ ENDIF() ExternalProject_Add( forge-ext GIT_REPOSITORY https://github.com/arrayfire/forge.git - GIT_TAG 79fac0b7ed35c96f25c8006075ec934729cf9dc4 + GIT_TAG af3.1 PREFIX "${prefix}" INSTALL_DIR "${prefix}" UPDATE_COMMAND "" From 169af41b818b9fa5dba3ee90cbc1f2189459bef7 Mon Sep 17 00:00:00 2001 From: Pavan Yalamanchili Date: Sun, 13 Sep 2015 08:40:05 -0400 Subject: [PATCH 16/16] Updating release notes --- docs/pages/release_notes.md | 7 ++++++- include/arrayfire.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index fd52334e62..bfff852193 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -20,7 +20,12 @@ Build ------ * `cmake` now includes `PKG_CONFIG` in the search path for CBLAS and LAPACKE libraries -* `heston_model` example now builds with the default ArrayFire cmake files after installation +* [heston_model.cpp](\ref heston_model.cpp) example now builds with the default ArrayFire cmake files after installation + +Other +------ + +* Fixed bug in [image_editing.cpp](\ref image_editing.cpp) v3.1.0 ============== diff --git a/include/arrayfire.h b/include/arrayfire.h index 2208bf5011..ff6a3e5245 100644 --- a/include/arrayfire.h +++ b/include/arrayfire.h @@ -241,6 +241,7 @@ \example vectorize.cpp \example black_scholes_options.cpp \example monte_carlo_options.cpp +\example heston_model.cpp \example harris.cpp \example kmeans.cpp \example knn.cpp @@ -258,6 +259,7 @@ \example plot2d.cpp \example brain_segmentation.cpp \example image_demo.cpp +\example image_editing.cpp \example morphing.cpp \example optical_flow.cpp \example pyramids.cpp