pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

py-torch: builds libtorch.so, but not torch_python.so



Module Name:	pkgsrc-wip
Committed By:	mayuresh <mayuresh%acm.org@localhost>
Pushed By:	mayuresh
Date:		Sun Jul 24 13:42:13 2022 +0530
Changeset:	1f0fca70ef601c8275002d713a8b523305abded0

Modified Files:
	py-torch/Makefile
	py-torch/TODO
	py-torch/distinfo
Added Files:
	py-torch/patches/patch-CMakeLists.txt
	py-torch/patches/patch-c10_test_util_exception__test.cpp
	py-torch/patches/patch-cmake_Dependencies.cmake
	py-torch/patches/patch-third__party_XNNPACK_CMakeLists.txt
	py-torch/patches/patch-third__party_cpuinfo_CMakeLists.txt
	py-torch/patches/patch-third__party_cpuinfo_include_cpuinfo.h
	py-torch/patches/patch-third__party_fbgemm_third__party_cpuinfo_CMakeLists.txt
	py-torch/patches/patch-third__party_kineto_libkineto_src_ThreadUtil.cpp
	py-torch/patches/patch-third__party_pthreadpool_CMakeLists.txt
	py-torch/patches/patch-third__party_sleef_Configure.cmake
	py-torch/patches/patch-third__party_xnnpack.buck.bzl

Log Message:
py-torch: builds libtorch.so, but not torch_python.so

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=1f0fca70ef601c8275002d713a8b523305abded0

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 py-torch/Makefile                                  | 32 ++++++++++++--
 py-torch/TODO                                      | 30 ++++++++++++-
 py-torch/distinfo                                  | 12 ++++++
 py-torch/patches/patch-CMakeLists.txt              | 13 ++++++
 .../patch-c10_test_util_exception__test.cpp        | 13 ++++++
 py-torch/patches/patch-cmake_Dependencies.cmake    | 13 ++++++
 .../patch-third__party_XNNPACK_CMakeLists.txt      | 38 +++++++++++++++++
 .../patch-third__party_cpuinfo_CMakeLists.txt      | 49 ++++++++++++++++++++++
 .../patch-third__party_cpuinfo_include_cpuinfo.h   | 16 +++++++
 ...arty_fbgemm_third__party_cpuinfo_CMakeLists.txt | 49 ++++++++++++++++++++++
 ...hird__party_kineto_libkineto_src_ThreadUtil.cpp | 31 ++++++++++++++
 .../patch-third__party_pthreadpool_CMakeLists.txt  | 13 ++++++
 .../patch-third__party_sleef_Configure.cmake       | 13 ++++++
 .../patches/patch-third__party_xnnpack.buck.bzl    | 40 ++++++++++++++++++
 14 files changed, 356 insertions(+), 6 deletions(-)

diffs:
diff --git a/py-torch/Makefile b/py-torch/Makefile
index d1382b1036..37aedc97ca 100644
--- a/py-torch/Makefile
+++ b/py-torch/Makefile
@@ -12,19 +12,42 @@ HOMEPAGE=	https://pytorch.org/
 COMMENT=	Tensors and Dynamic neural networks in Python with GPU acceleration
 #LICENSE=	# TODO: (see mk/license.mk)
 
-# This neeeds to be set as environment variable, not sure how
-#USE_CUDA=	0
-
 DEPENDS+=	${PYPKGPREFIX}-yaml>=5.4.1:../../textproc/py-yaml
 DEPENDS+=	${PYPKGPREFIX}-typing-extensions>=3.10.0.2:../../devel/py-typing-extensions
 DEPENDS+=	git-base-[0-9]*:../../devel/git-base
 DEPENDS+=	cmake>=3.17:../../devel/cmake
+DEPENDS+=	protobuf>=3.20.1:../../devel/protobuf
+
+USE_CMAKE=	yes
+CMAKE_ARGS+=	-B build \
+		-DBUILD_SHARED_LIBS:BOOL=ON \
+		-DBUILD_BINARY:BOOL=ON \
+		-DBUILD_CAFFE2=OFF \
+		-DCMAKE_BUILD_TYPE:STRING=Release \
+		-DBUILD_PYTHON=OFF \
+		-DBUILD_TEST=OFF \
+		-DONNX_ML=OFF \
+		-DUSE_OPENCV=ON \
+		-DUSE_CUDA=OFF \
+		-DUSE_CUDNN=OFF \
+		-DUSE_BREAKPAD=OFF \
+		-DUSE_FBGEMM=OFF \
+		-DUSE_KINETO=OFF \
+		-DBUILD_CUSTOM_PROTOBUF=OFF \
+		-DUSE_{Q/X}NNPACK=OFF
 
 USE_LANGUAGES+=	c c++
+
 CFLAGS+=	-fopenmp
+CPPFLAGS+=	-fopenmp
 
 WRKSRC=	${WRKDIR}/pytorch
 
+BUILDLINK_TRANSFORM.NetBSD+=	rm:-ldl
+BUILDLINK_TRANSFORM.NetBSD+=	l:libgomp:gomp # Otherwise it links -llibgomp
+BUILDLINK_TRANSFORM.NetBSD+=	opt:-std=c++14:-std=gnu++14 # alloca
+BUILDLINK_TRANSFORM.NetBSD+=	opt:-std=c99:-std=gnu99 # alloca
+
 post-extract:
 	rsync -a /tmp/pytorch ${WRKDIR}
 	# This step takes long. During development use a local copy
@@ -38,5 +61,6 @@ post-extract:
 .include "../../devel/google-glog/buildlink3.mk"
 .include "../../lang/python/egg.mk"
 .include "../../math/py-numpy/buildlink3.mk"
-.include "../../mk/bsd.pkg.mk"
 .include "../../parallel/openmp/buildlink3.mk"
+.include "../../devel/protobuf/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/py-torch/TODO b/py-torch/TODO
index 6545b036cf..30bf883093 100644
--- a/py-torch/TODO
+++ b/py-torch/TODO
@@ -1,5 +1,31 @@
+Patches that change AMD64 to amd64 are not confirmed to be necessary. May be removed if not needed
+
+Patch for cpuinfo is temporary. An external static instance of cpuinfo is created in the header itself. Since cpuinfo functionality is anyway not available on NetBSD, this should not matter.
+
+Various components are switched off. Once the build succeeds, try and enable them one by one.
+
+Warning: reference to the libc supplied alloca(3); this most likely will not work. Please use the compiler provided version of alloca(3), by supplying the appropriate compiler flags (e.g. not -std=c89)
+
+https://github.com/OpenImageIO/oiio/issues/2366
+
+OpenMP
+https://stackoverflow.com/questions/60126203/how-do-i-get-cmake-to-find-openmp-c-openmp-cxx-etc
+
+/usr/pkgsrc/work/wip/py-torch/work/pytorch/third_party/ideep/mkl-dnn/third_party/oneDNN/cmake/OpenMP.cmake
+Check openmp settings, which compiler should be used
+	if(NOT OpenMP_CXX_FOUND AND MSVC AND CMAKE_CXX_COMPILER_ID MATCHES "(Clang|IntelLLVM)")
+
+Which library? libiomp5: both are present in parallel/openmp
+        # Tell DPCPP compiler to link against libgomp. By default, it links
+        # against libiomp5
+
+
+
+ld: /usr/pkgsrc/work/wip/py-torch/work/.buildlink/lib/libgomp.so: warning: Warning: reference to the libc supplied alloca(3); this most likely will not work. Please use the compiler provided version of alloca(3), by supplying the appropriate compiler flags (e.g. not -std=c89).
+
+
 Watch CMake warnings, some of those could be addressable
 
-Also hwo to set USE_CUDA=0 for the entire build. Do not know exactly which all
-phases require it?
+CMake arguments are taken from here, may have to refine
 
+https://forums.freebsd.org/threads/pytorch.85206/
diff --git a/py-torch/distinfo b/py-torch/distinfo
index c37cae4a6a..f9ca707d15 100644
--- a/py-torch/distinfo
+++ b/py-torch/distinfo
@@ -3,3 +3,15 @@ $NetBSD$
 BLAKE2s (pytorch-1.12.0.tar.gz) = e4a7c2b9fba289880fbb6e0dbd854980b22c208fa03620b1c2c39b5cc6571189
 SHA512 (pytorch-1.12.0.tar.gz) = c9c748a2e0047daaaf199a1ba3198d2d1aee47f664170a9b34ccacd3deeb95f2070e4035eeb900012ef48dc62cf6fb6806f1a1dfe22de8c94892963076e593b7
 Size (pytorch-1.12.0.tar.gz) = 106286765 bytes
+SHA1 (patch-CMakeLists.txt) = 4f1d59018c8556621d19dbd75d3a0c532c413868
+SHA1 (patch-c10_test_util_exception__test.cpp) = e95bf41a71cb79b2a8fe9f592fe2d5cad5272b16
+SHA1 (patch-cmake_Dependencies.cmake) = 5a8d8b2ee3714fae4cfa0d913e91e1a98866deb8
+SHA1 (patch-third__party_XNNPACK_CMakeLists.txt) = 7feeb6eb5d79305807f718ebc63c03571aa6ff7b
+SHA1 (patch-third__party_cpuinfo_CMakeLists.txt) = 0f8b971d8d7f7c14a6c5853c9ec25f4fbf2a4f12
+SHA1 (patch-third__party_cpuinfo_include_cpuinfo.h) = fdc83cbcadb3e21c88b028074c0a99a70997db0c
+SHA1 (patch-third__party_fbgemm_third__party_cpuinfo_CMakeLists.txt) = 65350d8ee295d4675950e07ad356f2377d1ca988
+SHA1 (patch-third__party_kineto_libkineto_src_ThreadUtil.cpp) = 498919501910c582ac852220f18ee84aa3e15c82
+SHA1 (patch-third__party_protobuf_post__process__dist.sh) = 71c1d073f43b423721a9f59ad11e25fe14f5ad20
+SHA1 (patch-third__party_pthreadpool_CMakeLists.txt) = 92e56eee650085845b1823c5d7fba5eeffb267f8
+SHA1 (patch-third__party_sleef_Configure.cmake) = 486260fd941b04d5f350ae665eb365b610619a54
+SHA1 (patch-third__party_xnnpack.buck.bzl) = 8d882dcbc8de5b4ae0919baa5ac948035afc3fc7
diff --git a/py-torch/patches/patch-CMakeLists.txt b/py-torch/patches/patch-CMakeLists.txt
new file mode 100644
index 0000000000..50be94bc9e
--- /dev/null
+++ b/py-torch/patches/patch-CMakeLists.txt
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- CMakeLists.txt.orig	2022-07-22 04:45:51.720851373 +0000
++++ CMakeLists.txt
+@@ -133,7 +133,7 @@ endif()
+ set(CPU_AARCH64 OFF)
+ set(CPU_INTEL OFF)
+ 
+-if(CMAKE_SYSTEM_PROCESSOR MATCHES "(AMD64|x86_64)")
++if(CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64|x86_64)")
+   set(CPU_INTEL ON)
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)")
+   set(CPU_AARCH64 ON)
diff --git a/py-torch/patches/patch-c10_test_util_exception__test.cpp b/py-torch/patches/patch-c10_test_util_exception__test.cpp
new file mode 100644
index 0000000000..2a0eef8b38
--- /dev/null
+++ b/py-torch/patches/patch-c10_test_util_exception__test.cpp
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- c10/test/util/exception_test.cpp.orig	2022-07-22 04:45:53.177575954 +0000
++++ c10/test/util/exception_test.cpp
+@@ -35,7 +35,7 @@ TEST(ExceptionTest, TORCH_INTERNAL_ASSER
+ 
+ // On these platforms there's no assert
+ #if !defined(__ANDROID__) && !defined(__APPLE__) && \
+-    !(defined(USE_ROCM) && ROCM_VERSION < 40100)
++    !(defined(USE_ROCM) && ROCM_VERSION < 40100) && !defined(__NetBSD__)
+ TEST(ExceptionTest, CUDA_KERNEL_ASSERT) {
+   // This function always throws even in NDEBUG mode
+   ASSERT_DEATH_IF_SUPPORTED({ CUDA_KERNEL_ASSERT(false); }, "Assert");
diff --git a/py-torch/patches/patch-cmake_Dependencies.cmake b/py-torch/patches/patch-cmake_Dependencies.cmake
new file mode 100644
index 0000000000..941766dae9
--- /dev/null
+++ b/py-torch/patches/patch-cmake_Dependencies.cmake
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- cmake/Dependencies.cmake.orig	2022-07-22 04:45:54.504308990 +0000
++++ cmake/Dependencies.cmake
+@@ -346,7 +346,7 @@ if(USE_NNPACK OR USE_QNNPACK OR USE_PYTO
+         "Turn this warning off by USE_{Q/X}NNPACK=OFF.")
+       set(DISABLE_NNPACK_AND_FAMILY ON)
+     endif()
+-    if(NOT IOS AND NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "^(i686|AMD64|x86_64|armv[0-9].*|arm64|aarch64)$"))
++    if(NOT IOS AND NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "^(i686|amd64|x86_64|armv[0-9].*|arm64|aarch64)$"))
+       message(WARNING
+         "Target architecture \"${CMAKE_SYSTEM_PROCESSOR}\" is not supported in {Q/X}NNPACK. "
+         "Supported architectures are x86, x86-64, ARM, and ARM64. "
diff --git a/py-torch/patches/patch-third__party_XNNPACK_CMakeLists.txt b/py-torch/patches/patch-third__party_XNNPACK_CMakeLists.txt
new file mode 100644
index 0000000000..6abf22a480
--- /dev/null
+++ b/py-torch/patches/patch-third__party_XNNPACK_CMakeLists.txt
@@ -0,0 +1,38 @@
+$NetBSD$
+
+--- third_party/XNNPACK/CMakeLists.txt.orig	2022-07-22 04:48:22.624610681 +0000
++++ third_party/XNNPACK/CMakeLists.txt
+@@ -78,13 +78,13 @@ IF(NOT CMAKE_SYSTEM_PROCESSOR)
+       MESSAGE(FATAL_ERROR "Unsupported XNNPACK build with multiple iOS architectures (${IOS_ARCH}). "
+         "Specify a single architecture in IOS_ARCH and re-configure. ")
+     ENDIF()
+-    IF(NOT IOS_ARCH MATCHES "^(i386|x86_64|AMD64|armv7.*|arm64.*)$")
++    IF(NOT IOS_ARCH MATCHES "^(i386|x86_64|amd64|armv7.*|arm64.*)$")
+       MESSAGE(FATAL_ERROR "Unrecognized IOS_ARCH = ${IOS_ARCH}")
+     ENDIF()
+   ELSE()
+     MESSAGE(FATAL_ERROR "CMAKE_SYSTEM_PROCESSOR is not defined")
+   ENDIF()
+-ELSEIF(NOT XNNPACK_TARGET_PROCESSOR MATCHES "^(i[3-6]86|x86|x86_64|AMD64|armv[5-8].*|aarch64|arm64.*|riscv(32|64|128))$")
++ELSEIF(NOT XNNPACK_TARGET_PROCESSOR MATCHES "^(i[3-6]86|x86|x86_64|amd64|armv[5-8].*|aarch64|arm64.*|riscv(32|64|128))$")
+   MESSAGE(FATAL_ERROR "Unrecognized XNNPACK_TARGET_PROCESSOR = ${XNNPACK_TARGET_PROCESSOR}")
+ ENDIF()
+ 
+@@ -6373,7 +6373,7 @@ IF(XNNPACK_TARGET_PROCESSOR MATCHES "^(a
+   ENDIF()
+   LIST(APPEND JIT_SRCS ${JIT_AARCH64_SRCS})
+ ENDIF()
+-IF(XNNPACK_TARGET_PROCESSOR MATCHES "^(i[3-6]86|x86_64|AMD64)$" OR IOS_ARCH MATCHES "^(i386|x86_64|AMD64)$")
++IF(XNNPACK_TARGET_PROCESSOR MATCHES "^(i[3-6]86|x86_64|amd64)$" OR IOS_ARCH MATCHES "^(i386|x86_64|amd64)$")
+   LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_SSE_MICROKERNEL_SRCS})
+   LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_SSE2_MICROKERNEL_SRCS})
+   LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_SSSE3_MICROKERNEL_SRCS})
+@@ -6461,7 +6461,7 @@ IF(XNNPACK_TARGET_PROCESSOR MATCHES "^(a
+     SET_PROPERTY(SOURCE ${AARCH64_ASM_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -arch arm64 ")
+   ENDIF()
+ ENDIF()
+-IF(XNNPACK_TARGET_PROCESSOR MATCHES "^(i[3-6]86|x86|x86_64|AMD64)$" OR IOS_ARCH MATCHES "^(i386|x86_64|AMD64)$")
++IF(XNNPACK_TARGET_PROCESSOR MATCHES "^(i[3-6]86|x86|x86_64|amd64)$" OR IOS_ARCH MATCHES "^(i386|x86_64|amd64)$")
+   IF(MSVC)
+     IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86" OR CMAKE_SIZEOF_VOID_P EQUAL 4)
+       SET_PROPERTY(SOURCE ${ALL_SSE_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:SSE ")
diff --git a/py-torch/patches/patch-third__party_cpuinfo_CMakeLists.txt b/py-torch/patches/patch-third__party_cpuinfo_CMakeLists.txt
new file mode 100644
index 0000000000..573975a57c
--- /dev/null
+++ b/py-torch/patches/patch-third__party_cpuinfo_CMakeLists.txt
@@ -0,0 +1,49 @@
+$NetBSD$
+
+--- third_party/cpuinfo/CMakeLists.txt.orig	2022-07-22 04:48:26.681522083 +0000
++++ third_party/cpuinfo/CMakeLists.txt
+@@ -61,7 +61,7 @@ IF(NOT CMAKE_SYSTEM_PROCESSOR)
+       "cpuinfo will compile, but cpuinfo_initialize() will always fail.")
+     SET(CPUINFO_SUPPORTED_PLATFORM FALSE)
+   ENDIF()
+-ELSEIF(NOT CPUINFO_TARGET_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86(_64)?|armv[5-8].*|aarch64|arm64)$")
++ELSEIF(NOT CPUINFO_TARGET_PROCESSOR MATCHES "^(i[3-6]86|amd64|x86(_64)?|armv[5-8].*|aarch64|arm64)$")
+   MESSAGE(WARNING
+     "Target processor architecture \"${CPUINFO_TARGET_PROCESSOR}\" is not supported in cpuinfo. "
+     "cpuinfo will compile, but cpuinfo_initialize() will always fail.")
+@@ -119,7 +119,7 @@ SET(CPUINFO_SRCS
+   src/cache.c)
+ 
+ IF(CPUINFO_SUPPORTED_PLATFORM)
+-  IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" AND (CPUINFO_TARGET_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86(_64)?)$" OR IOS_ARCH MATCHES "^(i386|x86_64)$"))
++  IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" AND (CPUINFO_TARGET_PROCESSOR MATCHES "^(i[3-6]86|amd64|x86(_64)?)$" OR IOS_ARCH MATCHES "^(i386|x86_64)$"))
+     LIST(APPEND CPUINFO_SRCS
+       src/x86/init.c
+       src/x86/info.c
+@@ -301,7 +301,7 @@ ENDIF()
+ # ---[ cpuinfo mock library and mock tests
+ IF(CPUINFO_SUPPORTED_PLATFORM AND CPUINFO_BUILD_MOCK_TESTS)
+   SET(CPUINFO_MOCK_SRCS "${CPUINFO_SRCS}")
+-  IF(CPUINFO_TARGET_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86_64)$")
++  IF(CPUINFO_TARGET_PROCESSOR MATCHES "^(i[3-6]86|amd64|x86_64)$")
+     LIST(APPEND CPUINFO_MOCK_SRCS src/x86/mockcpuid.c)
+   ENDIF()
+   IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
+@@ -745,7 +745,7 @@ IF(CPUINFO_SUPPORTED_PLATFORM AND CPUINF
+     ADD_TEST(get-current-test get-current-test)
+   ENDIF()
+ 
+-  IF(CPUINFO_TARGET_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86_64)$")
++  IF(CPUINFO_TARGET_PROCESSOR MATCHES "^(i[3-6]86|amd64|x86_64)$")
+     ADD_EXECUTABLE(brand-string-test test/name/brand-string.cc)
+     CPUINFO_TARGET_ENABLE_CXX11(brand-string-test)
+     CPUINFO_TARGET_RUNTIME_LIBRARY(brand-string-test)
+@@ -812,7 +812,7 @@ IF(CPUINFO_SUPPORTED_PLATFORM AND CPUINF
+     CPUINFO_TARGET_RUNTIME_LIBRARY(cpuinfo-dump)
+   ENDIF()
+ 
+-  IF(CPUINFO_TARGET_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86_64)$")
++  IF(CPUINFO_TARGET_PROCESSOR MATCHES "^(i[3-6]86|amd64|x86_64)$")
+     ADD_EXECUTABLE(cpuid-dump tools/cpuid-dump.c)
+     CPUINFO_TARGET_ENABLE_C99(cpuid-dump)
+     CPUINFO_TARGET_RUNTIME_LIBRARY(cpuid-dump)
diff --git a/py-torch/patches/patch-third__party_cpuinfo_include_cpuinfo.h b/py-torch/patches/patch-third__party_cpuinfo_include_cpuinfo.h
new file mode 100644
index 0000000000..25534f77e3
--- /dev/null
+++ b/py-torch/patches/patch-third__party_cpuinfo_include_cpuinfo.h
@@ -0,0 +1,16 @@
+$NetBSD$
+
+--- third_party/cpuinfo/include/cpuinfo.h.orig	2022-07-22 04:48:26.695995456 +0000
++++ third_party/cpuinfo/include/cpuinfo.h
+@@ -765,7 +765,11 @@ void CPUINFO_ABI cpuinfo_deinitialize(vo
+ 		bool lwp;
+ 	};
+ 
++#ifndef __NetBSD__
+ 	extern struct cpuinfo_x86_isa cpuinfo_isa;
++#else
++	static struct cpuinfo_x86_isa cpuinfo_isa;
++#endif
+ #endif
+ 
+ static inline bool cpuinfo_has_x86_rdtsc(void) {
diff --git a/py-torch/patches/patch-third__party_fbgemm_third__party_cpuinfo_CMakeLists.txt b/py-torch/patches/patch-third__party_fbgemm_third__party_cpuinfo_CMakeLists.txt
new file mode 100644
index 0000000000..d03fe19d5c
--- /dev/null
+++ b/py-torch/patches/patch-third__party_fbgemm_third__party_cpuinfo_CMakeLists.txt
@@ -0,0 +1,49 @@
+$NetBSD$
+
+--- third_party/fbgemm/third_party/cpuinfo/CMakeLists.txt.orig	2022-07-22 04:48:37.982599256 +0000
++++ third_party/fbgemm/third_party/cpuinfo/CMakeLists.txt
+@@ -67,7 +67,7 @@ IF(NOT CMAKE_SYSTEM_PROCESSOR)
+       "cpuinfo will compile, but cpuinfo_initialize() will always fail.")
+     SET(CPUINFO_SUPPORTED_PLATFORM FALSE)
+   ENDIF()
+-ELSEIF(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86(_64)?|armv[5-8].*|aarch64|arm64)$")
++ELSEIF(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|amd64|x86(_64)?|armv[5-8].*|aarch64|arm64)$")
+   MESSAGE(WARNING
+     "Target processor architecture \"${CMAKE_SYSTEM_PROCESSOR}\" is not supported in cpuinfo. "
+     "cpuinfo will compile, but cpuinfo_initialize() will always fail.")
+@@ -125,7 +125,7 @@ SET(CPUINFO_SRCS
+   src/cache.c)
+ 
+ IF(CPUINFO_SUPPORTED_PLATFORM)
+-  IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" AND (CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86(_64)?)$" OR IOS_ARCH MATCHES "^(i386|x86_64)$"))
++  IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" AND (CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|amd64|x86(_64)?)$" OR IOS_ARCH MATCHES "^(i386|x86_64)$"))
+     LIST(APPEND CPUINFO_SRCS
+       src/x86/init.c
+       src/x86/info.c
+@@ -307,7 +307,7 @@ ENDIF()
+ # ---[ cpuinfo mock library and mock tests
+ IF(CPUINFO_SUPPORTED_PLATFORM AND CPUINFO_BUILD_MOCK_TESTS)
+   SET(CPUINFO_MOCK_SRCS "${CPUINFO_SRCS}")
+-  IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86_64)$")
++  IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|amd64|x86_64)$")
+     LIST(APPEND CPUINFO_MOCK_SRCS src/x86/mockcpuid.c)
+   ENDIF()
+   IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
+@@ -751,7 +751,7 @@ IF(CPUINFO_SUPPORTED_PLATFORM AND CPUINF
+     ADD_TEST(get-current-test get-current-test)
+   ENDIF()
+ 
+-  IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86_64)$")
++  IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|amd64|x86_64)$")
+     ADD_EXECUTABLE(brand-string-test test/name/brand-string.cc)
+     CPUINFO_TARGET_ENABLE_CXX11(brand-string-test)
+     CPUINFO_TARGET_RUNTIME_LIBRARY(brand-string-test)
+@@ -818,7 +818,7 @@ IF(CPUINFO_SUPPORTED_PLATFORM AND CPUINF
+     CPUINFO_TARGET_RUNTIME_LIBRARY(cpuinfo-dump)
+   ENDIF()
+ 
+-  IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86_64)$")
++  IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|amd64|x86_64)$")
+     ADD_EXECUTABLE(cpuid-dump tools/cpuid-dump.c)
+     CPUINFO_TARGET_ENABLE_C99(cpuid-dump)
+     CPUINFO_TARGET_RUNTIME_LIBRARY(cpuid-dump)
diff --git a/py-torch/patches/patch-third__party_kineto_libkineto_src_ThreadUtil.cpp b/py-torch/patches/patch-third__party_kineto_libkineto_src_ThreadUtil.cpp
new file mode 100644
index 0000000000..0cec7e908c
--- /dev/null
+++ b/py-torch/patches/patch-third__party_kineto_libkineto_src_ThreadUtil.cpp
@@ -0,0 +1,31 @@
+$NetBSD$
+
+--- third_party/kineto/libkineto/src/ThreadUtil.cpp.orig	2022-07-22 04:49:10.227928374 +0000
++++ third_party/kineto/libkineto/src/ThreadUtil.cpp
+@@ -1,5 +1,8 @@
+ #include "ThreadUtil.h"
+ 
++#ifdef __NetBSD__
++#include <lwp.h>
++#endif
+ #ifndef _MSC_VER
+ #include <pthread.h>
+ #include <unistd.h>
+@@ -48,6 +51,8 @@ int32_t systemThreadId() {
+     _sysTid = (int32_t)syscall(SYS_thread_selfid);
+ #elif defined _MSC_VER
+     _sysTid = (int32_t)GetCurrentThreadId();
++#elif defined __NetBSD__
++    _sysTid = (int32_t) _lwp_self();
+ #else
+     _sysTid = (int32_t)syscall(SYS_gettid);
+ #endif
+@@ -101,6 +106,8 @@ bool setThreadName(const std::string& na
+   std::wstring wname = conv.from_bytes(name);
+   HRESULT hr = _SetThreadDescription(GetCurrentThread(), wname.c_str());
+   return SUCCEEDED(hr);
++#elif defined __NetBSD__
++  return 0 == pthread_setname_np(pthread_self(), name.c_str(), (void*) "%s");
+ #else
+   return 0 == pthread_setname_np(pthread_self(), name.c_str());
+ #endif
diff --git a/py-torch/patches/patch-third__party_pthreadpool_CMakeLists.txt b/py-torch/patches/patch-third__party_pthreadpool_CMakeLists.txt
new file mode 100644
index 0000000000..60c0e9f6d0
--- /dev/null
+++ b/py-torch/patches/patch-third__party_pthreadpool_CMakeLists.txt
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- third_party/pthreadpool/CMakeLists.txt.orig	2022-07-22 04:49:40.612557860 +0000
++++ third_party/pthreadpool/CMakeLists.txt
+@@ -9,7 +9,7 @@ SET_PROPERTY(CACHE PTHREADPOOL_LIBRARY_T
+ OPTION(PTHREADPOOL_ALLOW_DEPRECATED_API "Enable deprecated API functions" ON)
+ SET(PTHREADPOOL_SYNC_PRIMITIVE "default" CACHE STRING "Synchronization primitive (condvar, futex, gcd, event, or default) for worker threads")
+ SET_PROPERTY(CACHE PTHREADPOOL_SYNC_PRIMITIVE PROPERTY STRINGS default condvar futex gcd event)
+-IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86(_64)?)$")
++IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|amd64|x86(_64)?)$")
+   OPTION(PTHREADPOOL_ENABLE_FASTPATH "Enable fast path using atomic decrement instead of atomic compare-and-swap" ON)
+ ELSE()
+   OPTION(PTHREADPOOL_ENABLE_FASTPATH "Enable fast path using atomic decrement instead of atomic compare-and-swap" OFF)
diff --git a/py-torch/patches/patch-third__party_sleef_Configure.cmake b/py-torch/patches/patch-third__party_sleef_Configure.cmake
new file mode 100644
index 0000000000..68a131574f
--- /dev/null
+++ b/py-torch/patches/patch-third__party_sleef_Configure.cmake
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- third_party/sleef/Configure.cmake.orig	2022-07-22 04:49:41.023701353 +0000
++++ third_party/sleef/Configure.cmake
+@@ -87,7 +87,7 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+   set(SLEEF_ARCH_32BIT ON CACHE INTERNAL "True for 32-bit architecture.")
+ endif()
+ 
+-if(SLEEF_TARGET_PROCESSOR MATCHES "(x86|AMD64|amd64|^i.86$)")
++if(SLEEF_TARGET_PROCESSOR MATCHES "(x86|amd64|amd64|^i.86$)")
+   set(SLEEF_ARCH_X86 ON CACHE INTERNAL "True for x86 architecture.")
+ 
+   set(CLANG_FLAGS_ENABLE_PURECFMA_SCALAR "-mavx2;-mfma;-fno-strict-aliasing")
diff --git a/py-torch/patches/patch-third__party_xnnpack.buck.bzl b/py-torch/patches/patch-third__party_xnnpack.buck.bzl
new file mode 100644
index 0000000000..76c6c08e1e
--- /dev/null
+++ b/py-torch/patches/patch-third__party_xnnpack.buck.bzl
@@ -0,0 +1,40 @@
+$NetBSD$
+
+--- third_party/xnnpack.buck.bzl.orig	2022-07-22 04:45:56.384678786 +0000
++++ third_party/xnnpack.buck.bzl
+@@ -822,7 +822,7 @@ def define_xnnpack(third_party, labels =
+         labels = labels,
+         platform_compiler_flags = [
+             (
+-                "^(i[3-6]86|x86|x86_64|AMD64)$",
++                "^(i[3-6]86|x86|x86_64|amd64)$",
+                 [
+                     "-mfma",
+                     "-mf16c",
+@@ -873,7 +873,7 @@ def define_xnnpack(third_party, labels =
+         labels = labels,
+         platform_compiler_flags = [
+             (
+-                "^(i[3-6]86|x86|x86_64|AMD64)$",
++                "^(i[3-6]86|x86|x86_64|amd64)$",
+                 [
+                     "-mfma",
+                     "-mf16c",
+@@ -1108,7 +1108,7 @@ def define_xnnpack(third_party, labels =
+         labels = labels,
+         platform_compiler_flags = [
+             (
+-                "^(i[3-6]86|x86|x86_64|AMD64)$",
++                "^(i[3-6]86|x86|x86_64|amd64)$",
+                 [
+                     "-mavx512f",
+                     "-mavx512cd",
+@@ -1171,7 +1171,7 @@ def define_xnnpack(third_party, labels =
+         labels = labels,
+         platform_compiler_flags = [
+             (
+-                "^(i[3-6]86|x86|x86_64|AMD64)$",
++                "^(i[3-6]86|x86|x86_64|amd64)$",
+                 [
+                     "-mavx512f",
+                     "-mavx512cd",


Home | Main Index | Thread Index | Old Index