Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: intel/Financial-Services-Workload-Samples
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: dslarm/Financial-Services-Workload-Samples
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Able to merge. These branches can be automatically merged.

Commits on Dec 7, 2022

  1. Copy the full SHA
    b254129 View commit details

Commits on Dec 9, 2022

  1. adding BlackScholes Makefile

    dslarm committed Dec 9, 2022
    Copy the full SHA
    3a5867e View commit details
  2. Add top-level makefile

    dslarm committed Dec 9, 2022
    Copy the full SHA
    d02c17e View commit details
  3. make a top level makefile

    dslarm committed Dec 9, 2022
    Copy the full SHA
    aca106b View commit details

Commits on Dec 14, 2022

  1. Copy the full SHA
    325cb57 View commit details
  2. add openmp flag

    dslarm committed Dec 14, 2022
    Copy the full SHA
    56267bf View commit details

Commits on Jan 28, 2023

  1. Fix compilation failure

    dslarm committed Jan 28, 2023
    Copy the full SHA
    45eb579 View commit details

Commits on Apr 23, 2024

  1. Copy the full SHA
    cea7351 View commit details
  2. Enable compilation on MacOS

    dslarm committed Apr 23, 2024
    Copy the full SHA
    8621a8c View commit details
  3. Add MacOS build

    dslarm committed Apr 23, 2024
    Copy the full SHA
    e20d509 View commit details
  4. Making it compile on MacOS

    dslarm committed Apr 23, 2024
    Copy the full SHA
    73bbb58 View commit details

Commits on Apr 24, 2024

  1. Fix erroneous header guard

    dslarm committed Apr 24, 2024
    Copy the full SHA
    a7b1eba View commit details
  2. Copy the full SHA
    476ea0f View commit details
  3. Tidying / DRY Makefiles

    dslarm committed Apr 24, 2024
    Copy the full SHA
    38ced6c View commit details

Commits on Jun 11, 2024

  1. fix compile error - x86 icx

    dslarm committed Jun 11, 2024
    Copy the full SHA
    273cf99 View commit details
  2. fixing link errors, x86 icx

    dslarm committed Jun 11, 2024
    Copy the full SHA
    4ae776a View commit details
  3. fix type error

    dslarm committed Jun 11, 2024
    Copy the full SHA
    3ec9fb9 View commit details
  4. Copy the full SHA
    e5a7c23 View commit details
  5. Copy the full SHA
    74b891c View commit details
  6. Copy the full SHA
    bd78cf1 View commit details
  7. and use the extra_libs etc..

    dslarm committed Jun 11, 2024
    Copy the full SHA
    ea1ff04 View commit details
  8. Copy the full SHA
    d2ea994 View commit details
  9. oops typo

    dslarm committed Jun 11, 2024
    Copy the full SHA
    305b7b9 View commit details
12 changes: 8 additions & 4 deletions AsianOptionsPricing/MCAsianOptions.cpp
Original file line number Diff line number Diff line change
@@ -44,7 +44,11 @@ static const tfloat F_RAND_N = static_cast<tfloat>(RAND_N);
static const tfloat STDDEV_DENOM = 1.0 / (F_RAND_N * (F_RAND_N - 1.0));
static const tfloat CONFIDENCE_DENOM = 1.0 / std::sqrt(F_RAND_N);

#ifdef __x86_64__
void* (*my_aligned_malloc)(size_t, int) = &MKL_malloc;
#else
void* (*my_aligned_malloc)(size_t, unsigned long) = &MKL_malloc;
#endif
void (*my_aligned_free)(void*) = &MKL_free;

//Simulate Spot Path
@@ -100,10 +104,10 @@ void MonteCarloTimeStep(
double time_init = 0.0;
double time_RNG = 0.0;

__declspec(align(64)) tfloat simStepResult[SIMSTEPS + 1][VECLEN];
__declspec(align(64)) tfloat volArray[SIMSTEPS + 1][VECLEN]; //Simulated Volatilities
__declspec(align(64)) tfloat avgMean[VECLEN];
__declspec(align(64)) tfloat callValue[VECLEN];
ALIGN64 tfloat simStepResult[SIMSTEPS + 1][VECLEN];
ALIGN64 tfloat volArray[SIMSTEPS + 1][VECLEN]; //Simulated Volatilities
ALIGN64 tfloat avgMean[VECLEN];
ALIGN64 tfloat callValue[VECLEN];

timer<timer_enabled> tt;
timer<timer_enabled> ttRng;
32 changes: 32 additions & 0 deletions AsianOptionsPricing/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#Copyright (c) Intel Corporation 2019-2020

#Intel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.



include ../Makefile.include


ifeq ($(arch),x86_64)
CXX=icpc
COMMON_FLAGS= -std=c++14 -fimf-precision=low -no-prec-div -no-prec-sqrt -vecabi=cmdtarget -qopt-report=5 -qopt-report-phase=vec -Wall -mkl -qopt-zmm-usage=high -fimf-domain-exclusion=31 -fno-alias -qopt-assume-safe-padding -restrict -Bstatic -Wl,--start-group -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -Wl,--end-group -Bdynamic -lpthread
CXXFLAGS=-O3 -g $COMMON_FLAGS
LDFLAGS=-lpthread -ltbbmalloc
else
ifeq ($(arch),arm64)
CXXFLAGS=-O3 -g
CXX=clang++
else
CXX=g++
CXXFLAGS=-O3 -fopenmp -g
endif
endif
all: asian-opt

asian-opt:
$(CXX) -std=c++14 $(CXXFLAGS) -o $@ $(LDFLAGS) MCAsianOptions.cpp -ltbb ${EXTRA_INCLUDES} ${EXTRA_LIBS}


clean :
rm -f asian-opt
13 changes: 13 additions & 0 deletions AsianOptionsPricing/mkl_rng.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
#ifdef __x86_64__
#include <mkl.h>
#define ALIGN64 __attribute__ ((aligned(64)))
#else
#include <armpl.h>
#define MKL_malloc calloc
#define mkl_malloc calloc
#define MKL_free free
#define mkl_free free
#define ALIGN64

#endif
#include <cassert>
#include <memory>

@@ -54,13 +65,15 @@ class mkl_rng
T* data;
};

template<>
inline double* mkl_rng<double>::get_gaussian(int rngNums)
{
assert(buffer_size >= sizeof(double)* rngNums);
vdRngGaussian(distribution, state_ptr, rngNums, data, mean, sigma);
return data;
}

template<>
inline float* mkl_rng<float>::get_gaussian(int rngNums)
{
assert(buffer_size >= sizeof(float) * rngNums);
27 changes: 18 additions & 9 deletions BinomialOptions/Makefile
Original file line number Diff line number Diff line change
@@ -5,18 +5,27 @@

#!/bin/bash

CXX=icpc

CXXFLAGS=-O3 -g -restrict -fimf-domain-exclusion=31 -fimf-accuracy-bits=11 -no-prec-div -no-prec-sqrt -fno-alias -qopt-report=5 -qopt-report-phase=vec

include ../Makefile.include

arch := $(shell uname -m)
ifeq ($(arch),x86_64)
CXX=icpc
CXXFLAGS=-O3 -g -restrict -fimf-domain-exclusion=31 -fimf-accuracy-bits=11 -no-prec-div -no-prec-sqrt -fno-alias -qopt-report=5 -qopt-report-phase=vec -fopenmp
LDFLAGS=-lpthread -ltbbmalloc
else
ifeq ($(arch),arm64)
CXXFLAGS=-L/opt/homebrew/opt/libomp/lib -I/opt/homebrew/opt/libomp/include -lomp -Xclang -fopenmp -I /opt/homebrew/opt/tbb/include -L /opt/homebrew/opt/tbb/lib -Wc++11-inline-namespace
CXX=clang++
else
CXX=g++
CXXFLAGS=-O3 -fopenmp -g
endif
endif
all: binomial

all: binomial.avx512

binomial.avx512: binomial_cpu.cpp binomial_main.cpp binomial.h
$(CXX) -std=c++14 -tbb -xCORE-AVX512 -qopenmp -qopt-report-file=binomial.avx512.optrpt $(CXXFLAGS) -o $@ $(LDFLAGS) binomial_main.cpp binomial_cpu.cpp -qopt-zmm-usage=high
binomial: binomial_cpu.cpp binomial_main.cpp binomial.h
$(CXX) -std=c++14 $(CXXFLAGS) -o $@ $(LDFLAGS) $(EXTRA_INCLUDES) $(EXTRA_LIBS) binomial_main.cpp binomial_cpu.cpp -ltbb


clean :
rm -f binomial.avx512 *.optrpt
rm -f binomial
2 changes: 1 addition & 1 deletion BinomialOptions/binomial_cpu.cpp
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ template<> void binomial<TPRECISION>::initialize() {}
template<typename DataType>
void binomial<DataType>::run()
{
#if _OPENMP
#if _OPENMP && !defined(__GNUC__)
kmp_set_defaults("KMP_AFFINITY=scatter,granularity=thread");
#endif

2 changes: 1 addition & 1 deletion BlackScholes/BlackScholesDP.cpp
Original file line number Diff line number Diff line change
@@ -178,8 +178,8 @@ int main(int argc, char* argv[])
#pragma distribute_point
for (int chunkBase = 0; chunkBase < OptPerThread; chunkBase += CHUNKSIZE)
{
#pragma vector aligned
#pragma omp simd
#pragma vector aligned
#pragma vector nontemporal (CallResult, PutResult)
for(int opt = chunkBase; opt < (chunkBase+CHUNKSIZE); opt++)
{
22 changes: 17 additions & 5 deletions BlackScholes/Makefile
Original file line number Diff line number Diff line change
@@ -6,17 +6,29 @@

#!/bin/bash

arch := $(shell uname -m)
ifeq ($(arch),x86_64)
CXX=icpc
COMPILER_VERSION:="$(CXX)-$(shell $(CXX) --version | head -n1 | cut -d' ' -f4)"

CXXFLAGS=-g -O3 -qopenmp -fimf-precision=low -restrict -qopt-report=5 -fimf-domain-exclusion=31 -no-prec-div -no-prec-sqrt -fno-alias \
-DCOMPILER_VERSION=\"$(COMPILER_VERSION)\" -qopt-report-phase=loop -qopt-report-phase=vec -vecabi=cmdtarget
-DCOMPILER_VERSION=\"$(COMPILER_VERSION)\" -qopt-report-phase=loop -qopt-report-phase=vec -vecabi=cmdtarget -xCORE-AVX512 -qopt-zmm-usage=high -qopt-report-file=DP_AVX512.optrpt -fopenmp
else
ifeq ($(arch),arm64)
CXXFLAGS=-std=c++11 -L/opt/homebrew/opt/libomp/lib -I/opt/homebrew/opt/libomp/include -lomp -Xclang -fopenmp -I /opt/homebrew/opt/tbb/include -L /opt/homebrew/opt/tbb/lib -Wc++11-inline-namespace
CXX=clang++
else # Linux aarch64
CXX=g++
CXXFLAGS=-O3 -fopenmp -g

endif
endif

LDFLAGS= -ltbbmalloc
all: BlackScholesDP.avx512
all: BlackScholesDP

BlackScholesDP.avx512: BlackScholesDP.cpp
$(CXX) -xCORE-AVX512 -qopt-zmm-usage=high $(CXXFLAGS) $(LDFLAGS) -qopt-report-file=DP_AVX512.optrpt -o $@ $^
BlackScholesDP: BlackScholesDP.cpp
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)

clean :
rm -f *optrpt BlackScholesDP.avx512
rm -f *optrpt BlackScholesDP
32 changes: 32 additions & 0 deletions LiborMarketModel/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#Copyright (c) Intel Corporation 2019-2020

#Intel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#!/bin/bash

include ../Makefile.include
ifeq ($(arch),x86_64)
CXX=icpc
COMMON_FLAGS= -std=c++14 -fimf-precision=low -no-prec-div -no-prec-sqrt -vecabi=cmdtarget -qopt-report=5 -qopt-report-phase=vec -Wall -mkl -qopt-zmm-usage=high -fimf-domain-exclusion=31 -fno-alias -qopt-assume-safe-padding -restrict -Bstatic -Wl,--start-group -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -Wl,--end-group -Bdynamic -lpthread -ltbb
CXXFLAGS=-O3 -g $COMMON_FLAGS
LDFLAGS=-lpthread -ltbbmalloc
else
ifeq ($(arch),arm64)

CXX=clang++
CXXFLAGS=-O3 -g

else
CXX=g++
CXXFLAGS=-O3 -fopenmp -g
endif
endif
all: liborgreeks

liborgreeks:
$(CXX) -std=c++14 ${CXXFLAGS} -o $@ ${LDFLAGS} main.cpp liborSwaptionGreeks.cpp mklRng.cpp $(EXTRA_INCLUDES) $(EXTRA_LIBS)


clean :
rm -f liborgreeks
6 changes: 5 additions & 1 deletion LiborMarketModel/liborSwaptionGreeks.hpp
Original file line number Diff line number Diff line change
@@ -3,8 +3,12 @@ Copyright (c) 2019-2020
Intel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifdef __x86_64__
#include <mkl_vsl.h>
#else
#include <armpl.h>
#endif


#ifndef _LIBORSWAPTIONGREEKS_HPP_
#define _LIBORSWAPTIONGREEKS_HPP_
4 changes: 4 additions & 0 deletions LiborMarketModel/main.cpp
Original file line number Diff line number Diff line change
@@ -22,7 +22,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <iostream>
#include <sstream>
#include <ctime>
#ifdef __x86_64__
#include <mkl_vsl.h>
#else
#include <armpl.h>
#endif
#include <omp.h>
#include <vector>
#include "mklRng.h"
4 changes: 4 additions & 0 deletions LiborMarketModel/mklRng.cpp
Original file line number Diff line number Diff line change
@@ -16,7 +16,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <vector>
#include <numeric>
#include <omp.h>
#ifdef __x86_64__
#include <mkl_vsl.h>
#else
#include <armpl.h>
#endif
#include <sstream>

inline void genGaussian(VSLStreamStatePtr stream, int num, float* z,
5 changes: 4 additions & 1 deletion LiborMarketModel/mklRng.h
Original file line number Diff line number Diff line change
@@ -4,8 +4,11 @@ Intel Permission is hereby granted, free of charge, to any person obtaining a co
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifdef __x86_64__
#include <mkl_vsl.h>

#else
#include <armpl.h>
#endif
void generateRand(REAL* z, int num, REAL mean, REAL stddev, int seed = 12345);
inline void genGaussian(VSLStreamStatePtr stream, int num, double* z,
double mean, double stddev);
2 changes: 1 addition & 1 deletion LiborMarketModel/params.h
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
*/

#ifndef LIBORSWAPTIONGREEKS_PARAMS_H_
#define LIBORSWAPTIONGREEK_PARAMS_H_
#define LIBORSWAPTIONGREEKS_PARAMS_H_
#ifdef USE_DOUBLE
typedef double REAL;
#define ONE 1.0
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SUBDIRS := BinomialOptions BlackScholes AsianOptionsPricing LiborMarketModel MonteCarloAmericanOptions MonteCarloEuropeanOptions


subdirs:
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir ; \
done

clean:
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir clean ; \
done
20 changes: 20 additions & 0 deletions Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
arch := $(shell uname -m)
ifeq ($(arch),x86_64)
EXTRA_LIBS=-L/opt/intel/oneapi/tbb/latest/lib -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core
else
ifeq ($(arch),arm64)

# Make will not override if these two are set outside the Makefile
ARMPL_LIBRARIES=/opt/arm/armpl_24.04_flang-new_clang_18/lib
ARMPL_INCLUDES=/opt/arm/armpl_24.04_flang-new_clang_18/include

EXTRA_INCLUDES=-I/opt/homebrew/opt/libomp/include -I /opt/homebrew/opt/tbb/include -I ${ARMPL_INCLUDES}
EXTRA_LIBS=-L/opt/homebrew/opt/libomp/lib -lomp -Xclang -fopenmp -L /opt/homebrew/opt/tbb/lib -L ${ARMPL_LIBRARIES} -larmpl

else
CXX=g++
EXTRA_INCLUDES=-I${ARMPL_INCLUDES}
EXTRA_LIBS=-L${ARMPL_LIBRARIES} -larmpl
endif
endif

30 changes: 30 additions & 0 deletions MonteCarloAmericanOptions/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#Copyright (c) Intel Corporation 2019-2020

#Intel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#!/bin/bash

include ../Makefile.include
ifeq ($(arch),x86_64)
CXX=icpc
COMMON_FLAGS= -std=c++14 -fimf-precision=low -no-prec-div -no-prec-sqrt -vecabi=cmdtarget -qopt-report=5 -qopt-report-phase=vec -Wall -mkl -qopt-zmm-usage=high -fimf-domain-exclusion=31 -fno-alias -qopt-assume-safe-padding -restrict -Bstatic -Wl,--start-group -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -Wl,--end-group -Bdynamic -lpthread
CXXFLAGS=-O3 -g $COMMON_FLAGS
LDFLAGS=-lpthread -ltbbmalloc
else
ifeq ($(arch),arm64)

CXX=clang++
else
CXX=g++
CXXFLAGS=-O3 -fopenmp -g
endif
endif
all: amc

amc: main.cpp utilities.cpp
$(CXX) -std=c++14 $(CXXFLAGS) -o $@ $(LDFLAGS) $(EXTRA_INCLUDES) $(EXTRA_LIBS) main.cpp utilities.cpp


clean :
rm -f amc
13 changes: 8 additions & 5 deletions MonteCarloAmericanOptions/main.cpp
Original file line number Diff line number Diff line change
@@ -10,18 +10,21 @@ This file also contains problem-size definitions
*/

#include "utilities.h"
#include <stdlib.h>

#include "chrono"
#include <ctime>

#include "Timer.hpp"
#include <cmath>
#include <cstdlib>
#include <malloc.h>
#include <iomanip>
#include <iostream>
#include <numeric>
#ifdef __x86_64__
#include <mkl_vsl.h>
#else
#include <armpl.h>
#endif
#include <omp.h>

#define progLoops 50//*120-power
@@ -60,7 +63,7 @@ int main(int argc, char** argv)
REAL avgPathFactor = REAL(1.0) / REAL(numPaths);

REAL *cashFlowPut1;
cashFlowPut1 = (REAL*) memalign(64,sizeof(REAL)*(numPaths));
posix_memalign((void**) &cashFlowPut1, 64, sizeof(REAL)*(numPaths));

#pragma omp parallel for
for(int i=0; i<numPaths; i++)
@@ -70,9 +73,9 @@ int main(int argc, char** argv)
// now go back in time using regression

REAL **asset;
asset = (REAL**) memalign(64,sizeof(REAL*)*(nStepsPlusOne));
posix_memalign((void**) &asset, 64, sizeof(REAL*)*(nStepsPlusOne));
for(int i =0; i<nStepsPlusOne; i++)
asset[i] = (REAL *) memalign(64,sizeof(REAL)*(numPaths));
posix_memalign((void**) (asset + i), 64,sizeof(REAL)*(numPaths));

int nthreads = 1;
nthreads = omp_get_max_threads();
4 changes: 4 additions & 0 deletions MonteCarloAmericanOptions/utilities.cpp
Original file line number Diff line number Diff line change
@@ -12,7 +12,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <iomanip>
#include <cmath>
#include <cstdlib>
#ifdef __x86_64__
#include <mkl_vsl.h>
#else
#include <armpl.h>
#endif
#include <omp.h>

#define FUZZ 0.00000001
5 changes: 4 additions & 1 deletion MonteCarloAmericanOptions/utilities.h
Original file line number Diff line number Diff line change
@@ -7,8 +7,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
*/

#pragma once

#ifdef __x86_64__
#include <mkl_vsl.h>
#else
#include <armpl.h>
#endif

#define REAL_BYTES 8

24 changes: 19 additions & 5 deletions MonteCarloEuropeanOptions/Makefile
Original file line number Diff line number Diff line change
@@ -3,17 +3,31 @@
#Intel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

include ../Makefile.include

ifeq ($(arch),x86_64)
CXX=icpc
COMPILER_VERSION:="$(CXX)-$(shell $(CXX) --version | head -n1 | cut -d' ' -f4)"
CXXFLAGS=-g -O3 -fimf-precision=low -qopenmp -restrict -qopt-report=5 -fimf-domain-exclusion=31 -no-prec-div -no-prec-sqrt \
-DCOMPILER_VERSION=\"$(COMPILER_VERSION)\" -qopt-report-phase=vec -DMKL_ILP64 -I${MKLROOT}/include
-DCOMPILER_VERSION=\"$(COMPILER_VERSION)\" -qopt-report-phase=vec -DMKL_ILP64 -I${MKLROOT}/include -xCORE-AVX512 -qopt-zmm-usage=high

LDFLAGS=-L${TBBROOT}/lib/intel64/gcc4.4 -ltbbmalloc -Bstatic -L${MKLROOT}/lib/intel64/ -Wl,--start-group -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -Wl,--end-group

all: MonteCarloInsideBlockingDP.avx512
else
ifeq ($(arch),arm64)
CXX=clang++
CXXFLAGS=-O3 -g
else
CXX=g++
CXXFLAGS=-O3 -fopenmp -g
endif
endif


all: MonteCarloInsideBlockingDP

MonteCarloInsideBlockingDP.avx512: MonteCarloInsideBlockingDP.cpp
$(CXX) $^ -xCORE-AVX512 -qopt-zmm-usage=high $(LDFLAGS) $(CXXFLAGS) -o $@
MonteCarloInsideBlockingDP: MonteCarloInsideBlockingDP.cpp
$(CXX) --std=c++14 $^ $(LDFLAGS) $(CXXFLAGS) $(EXTRA_INCLUDES) $(EXTRA_LIBS) -o $@

clean :
rm -f *.optrpt MonteCarloInsideBlockingDP.avx512
rm -f *.optrpt MonteCarloInsideBlockingDP
8 changes: 7 additions & 1 deletion MonteCarloEuropeanOptions/MonteCarloInsideBlockingDP.cpp
Original file line number Diff line number Diff line change
@@ -15,13 +15,19 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <ctime>
#include <tbb/scalable_allocator.h>
#include <omp.h>

#include <math.h>
#ifdef __INTEL_COMPILER
#include <mathimf.h>
#endif

#ifdef __x86_64__
#include <mkl_vsl.h>
#include <mkl_service.h>
#else
#define scalable_aligned_malloc(a,b) malloc((a))
#define scalable_aligned_free(a) free((a))
#include <armpl.h>
#endif

/******* VERSION *******/
#define MAJOR 1