From 6ad1fb497d5c8f5426307ceefd118bfd84a555ae Mon Sep 17 00:00:00 2001 From: Hu Shiwen Date: Fri, 22 May 2020 00:07:20 +0800 Subject: [PATCH 1/7] change _Pragma to #pragma._Pragma not work with msvc --- src/io/batchify.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/io/batchify.cc b/src/io/batchify.cc index 72a3ed4e0cf5..a21b86b365fe 100644 --- a/src/io/batchify.cc +++ b/src/io/batchify.cc @@ -150,7 +150,7 @@ class StackBatchify : public BatchifyFunction { } int sbs = static_cast(bs); MSHADOW_TYPE_SWITCH_WITH_BOOL(dtype, DType, { - _Pragma("omp parallel for num_threads(bs)") + #pragma omp parallel for num_threads(bs) for (int j = 0; j < sbs; ++j) { omp_exc_.Run([&] { // inputs[j][i].WaitToRead(); @@ -276,7 +276,7 @@ class PadBatchify : public BatchifyFunction { DType *ptr = (*outputs)[i].data().dptr(); auto asize = ashape.Size(); int sbs = static_cast(bs); - _Pragma("omp parallel for num_threads(bs)") + #pragma omp parallel for num_threads(bs)") for (int j = 0; j < sbs; ++j) { using namespace mshadow::expr; auto compact_shapes = CompactShapes(ashape, inputs[j][i].shape()); From 7e0b9d7e3c09055af2695b885c1a40328060954f Mon Sep 17 00:00:00 2001 From: Hu Shiwen Date: Fri, 22 May 2020 15:11:50 +0800 Subject: [PATCH 2/7] new plan --- src/io/batchify.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/io/batchify.cc b/src/io/batchify.cc index a21b86b365fe..d1a009416331 100644 --- a/src/io/batchify.cc +++ b/src/io/batchify.cc @@ -37,6 +37,17 @@ namespace mxnet { namespace io { + +#ifdef _MSC_VER + #if _MSC_VER < 1925 + #define omp_parallel __pragma(omp parallel for num_threads(bs)) + #else + #define omp_parallel _Pragma("omp parallel for num_threads(bs)") + #endif +#else + #define omp_parallel _Pragma("omp parallel for num_threads(bs)") +#endif + struct GroupBatchifyParam : public dmlc::Parameter { mxnet::Tuple functions; // declare parameters @@ -150,7 +161,7 @@ class StackBatchify : public BatchifyFunction { } int sbs = static_cast(bs); MSHADOW_TYPE_SWITCH_WITH_BOOL(dtype, DType, { - #pragma omp parallel for num_threads(bs) + omp_parallel for (int j = 0; j < sbs; ++j) { omp_exc_.Run([&] { // inputs[j][i].WaitToRead(); @@ -276,7 +287,7 @@ class PadBatchify : public BatchifyFunction { DType *ptr = (*outputs)[i].data().dptr(); auto asize = ashape.Size(); int sbs = static_cast(bs); - #pragma omp parallel for num_threads(bs)") + omp_parallel for (int j = 0; j < sbs; ++j) { using namespace mshadow::expr; auto compact_shapes = CompactShapes(ashape, inputs[j][i].shape()); From 8044affc75db62a1fa08ba521dde562416edd44c Mon Sep 17 00:00:00 2001 From: Hu Shiwen Date: Fri, 22 May 2020 15:29:15 +0800 Subject: [PATCH 3/7] fix lint --- src/io/batchify.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/io/batchify.cc b/src/io/batchify.cc index d1a009416331..21fd7bd53fa9 100644 --- a/src/io/batchify.cc +++ b/src/io/batchify.cc @@ -39,13 +39,13 @@ namespace mxnet { namespace io { #ifdef _MSC_VER - #if _MSC_VER < 1925 + #if _MSC_VER < 1925 #define omp_parallel __pragma(omp parallel for num_threads(bs)) #else - #define omp_parallel _Pragma("omp parallel for num_threads(bs)") + #define omp_parallel _Pragma("omp parallel for num_threads(bs)") #endif #else - #define omp_parallel _Pragma("omp parallel for num_threads(bs)") + #define omp_parallel _Pragma("omp parallel for num_threads(bs)") #endif struct GroupBatchifyParam : public dmlc::Parameter { From 660543e07c40cf813c7ce5f70ba24ee30be55142 Mon Sep 17 00:00:00 2001 From: Hu Shiwen Date: Sat, 23 May 2020 10:57:56 +0800 Subject: [PATCH 4/7] add arg --- src/io/batchify.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/io/batchify.cc b/src/io/batchify.cc index 21fd7bd53fa9..fa22f01c959b 100644 --- a/src/io/batchify.cc +++ b/src/io/batchify.cc @@ -38,14 +38,17 @@ namespace mxnet { namespace io { + +#define tostr(s) #s + #ifdef _MSC_VER - #if _MSC_VER < 1925 - #define omp_parallel __pragma(omp parallel for num_threads(bs)) + #if _MSC_VER < 1926 + #define omp_parallel(t) __pragma(omp parallel for num_threads(t)) #else - #define omp_parallel _Pragma("omp parallel for num_threads(bs)") + #define omp_parallel(t) _Pragma(tostr(omp parallel for num_threads( ## t ## ))) #endif #else - #define omp_parallel _Pragma("omp parallel for num_threads(bs)") + #define omp_parallel(t) _Pragma(tostr(omp parallel for num_threads( ## t ## ))) #endif struct GroupBatchifyParam : public dmlc::Parameter { @@ -161,7 +164,7 @@ class StackBatchify : public BatchifyFunction { } int sbs = static_cast(bs); MSHADOW_TYPE_SWITCH_WITH_BOOL(dtype, DType, { - omp_parallel + omp_parallel(bs) for (int j = 0; j < sbs; ++j) { omp_exc_.Run([&] { // inputs[j][i].WaitToRead(); @@ -287,7 +290,7 @@ class PadBatchify : public BatchifyFunction { DType *ptr = (*outputs)[i].data().dptr(); auto asize = ashape.Size(); int sbs = static_cast(bs); - omp_parallel + omp_parallel(bs) for (int j = 0; j < sbs; ++j) { using namespace mshadow::expr; auto compact_shapes = CompactShapes(ashape, inputs[j][i].shape()); From 61fd4309992247c54d92068c16733425d364d580 Mon Sep 17 00:00:00 2001 From: Hu Shiwen Date: Sat, 23 May 2020 11:00:18 +0800 Subject: [PATCH 5/7] fix --- src/io/batchify.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/io/batchify.cc b/src/io/batchify.cc index fa22f01c959b..feff7a55e49d 100644 --- a/src/io/batchify.cc +++ b/src/io/batchify.cc @@ -42,7 +42,7 @@ namespace io { #define tostr(s) #s #ifdef _MSC_VER - #if _MSC_VER < 1926 + #if _MSC_VER < 1925 #define omp_parallel(t) __pragma(omp parallel for num_threads(t)) #else #define omp_parallel(t) _Pragma(tostr(omp parallel for num_threads( ## t ## ))) From cf638c5eef43196ccacfcfc19f2e0191409ead30 Mon Sep 17 00:00:00 2001 From: Hu Shiwen Date: Sat, 23 May 2020 16:57:47 +0800 Subject: [PATCH 6/7] fix lint --- src/io/batchify.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/io/batchify.cc b/src/io/batchify.cc index feff7a55e49d..dffd06aa8dd2 100644 --- a/src/io/batchify.cc +++ b/src/io/batchify.cc @@ -43,9 +43,9 @@ namespace io { #ifdef _MSC_VER #if _MSC_VER < 1925 - #define omp_parallel(t) __pragma(omp parallel for num_threads(t)) + #define omp_parallel(t) __pragma(omp parallel for num_threads(t)) #else - #define omp_parallel(t) _Pragma(tostr(omp parallel for num_threads( ## t ## ))) + #define omp_parallel(t) _Pragma(tostr(omp parallel for num_threads( ## t ## ))) #endif #else #define omp_parallel(t) _Pragma(tostr(omp parallel for num_threads( ## t ## ))) From 92fe21b0287f6324341b9ab35472af38a364f89d Mon Sep 17 00:00:00 2001 From: Hu Shiwen Date: Sat, 23 May 2020 23:28:10 +0800 Subject: [PATCH 7/7] fix --- src/io/batchify.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/io/batchify.cc b/src/io/batchify.cc index dffd06aa8dd2..27ed850522ff 100644 --- a/src/io/batchify.cc +++ b/src/io/batchify.cc @@ -48,7 +48,7 @@ namespace io { #define omp_parallel(t) _Pragma(tostr(omp parallel for num_threads( ## t ## ))) #endif #else - #define omp_parallel(t) _Pragma(tostr(omp parallel for num_threads( ## t ## ))) + #define omp_parallel(t) _Pragma(tostr(omp parallel for num_threads(t))) #endif struct GroupBatchifyParam : public dmlc::Parameter {