Skip to content

Conversation

@zy97140
Copy link

@zy97140 zy97140 commented Mar 6, 2018

As described in issue #4188 and benchmark, optimal OpenMP threshold is dependent on operation type, CPU type and tensors' contiguity.
This PR add a parameter named OMP_THRESHOLD for macros TH_TENSOR_APPLYX_OMP to control the OpenMP threshold.

@ezyang
Copy link
Contributor

ezyang commented Mar 7, 2018

@pytorchbot test this please

#endif

#ifdef _OPENMP
LAB_IMPLEMENT_BASIC_FUNCTION(log,TH_MATH_NAME(log),HYPER_TH_OMP_OVERHEAD_THRESHOLD)

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@ezyang
Copy link
Contributor

ezyang commented Mar 7, 2018

CC @cpuhrsch

@cpuhrsch
Copy link
Contributor

cpuhrsch commented Mar 7, 2018

Thanks @ezyang. I'm not sure what the philosophy here is, but CC @colesbury should know more.

@zy97140
Copy link
Author

zy97140 commented Mar 13, 2018

@ezyang @colesbury Could you spare some time to review this PR? I want to optimize nn module based on these macros.

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with merging this but I don't regularly interact with this code.

@ezyang
Copy link
Contributor

ezyang commented Mar 13, 2018

@pytorchbot retest this please

@ezyang
Copy link
Contributor

ezyang commented Mar 23, 2018

@pytorchbot retest this please

@zy97140
Copy link
Author

zy97140 commented Mar 27, 2018

@fmassa @zdevito @vedanuj , some changes in this PR is related to #5010. A parameter named VECTORIZE is added to determine whether to use THVector_(NAME) implementation or not. This can avoid defining a new macro just for sigmoid.
@ezyang The latest commit has implemented C macros with optional parameters to avoid duplicating definitions for all pointwise operations as you commented before. Could you spare some time to review this PR? I want to optimize nn module based on these macros. Thank you very much.

@ezyang
Copy link
Contributor

ezyang commented Mar 27, 2018

@pytorchbot test this please

} else {\
PRAGMA(simd) \
PRAGMA( omp parallel for if (SIZE > TH_OMP_OVERHEAD_THRESHOLD_OMP) ) \
PRAGMA( omp parallel for if (SIZE > OMP_THRESHOLD * 10) ) \

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.


#define HYPER_TH_OMP_OVERHEAD_THRESHOLD 2000
#define ORDIN_TH_OMP_OVERHEAD_THRESHOLD 20000
#define UNCERTAIN_TH_OMP_OVERHEAD_THRESHOLD 50000

This comment was marked as off-topic.

This comment was marked as off-topic.

Modify macro LAB_IMPLEMENT_VECTORIZED_FUNCTION to enable optional parameters

This reverts commit 8ef783a.

Conflicts:
	aten/src/TH/generic/THTensorMath.c
@ezyang
Copy link
Contributor

ezyang commented Mar 29, 2018

@pytorchbot test this please

@zy97140
Copy link
Author

zy97140 commented Apr 23, 2018

@ezyang Could you spare some time to review this PR? I want to optimize nn module based on these macros.

@ezyang ezyang merged commit d9bde84 into pytorch:master Apr 25, 2018
@zy97140 zy97140 deleted the th-omp-threshold branch April 25, 2018 05:22
@sighingnow sighingnow mentioned this pull request Apr 25, 2018
Jorghi12 pushed a commit to wsttiger/pytorch that referenced this pull request May 10, 2018
* add threshold for ops using omp macro

* modify interface for ops using omp macro

* modify some thresholds

* implement C macros with optional parameters to avoid duplicating definitions for all pointwise operations

* add a parameter of LAB_IMPLEMENT_BASIC_FUNCTION for vectorizing

* modify the comment

* Revert "add a parameter of LAB_IMPLEMENT_BASIC_FUNCTION for vectorizing"
Modify macro LAB_IMPLEMENT_VECTORIZED_FUNCTION to enable optional parameters

This reverts commit 8ef783a.

Conflicts:
	aten/src/TH/generic/THTensorMath.c

* fix build error on windows

* retrigger the test
weiyangfb pushed a commit to weiyangfb/pytorch that referenced this pull request Jun 11, 2018
* add threshold for ops using omp macro

* modify interface for ops using omp macro

* modify some thresholds

* implement C macros with optional parameters to avoid duplicating definitions for all pointwise operations

* add a parameter of LAB_IMPLEMENT_BASIC_FUNCTION for vectorizing

* modify the comment

* Revert "add a parameter of LAB_IMPLEMENT_BASIC_FUNCTION for vectorizing"
Modify macro LAB_IMPLEMENT_VECTORIZED_FUNCTION to enable optional parameters

This reverts commit 8ef783a.

Conflicts:
	aten/src/TH/generic/THTensorMath.c

* fix build error on windows

* retrigger the test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants