Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] aarch64: Add OpenBSD runtime detection of dotprod and i8mm using sysctl
@ 2024-06-23  2:52 Brad Smith
  2024-06-24  8:15 ` Martin Storsjö
  0 siblings, 1 reply; 3+ messages in thread
From: Brad Smith @ 2024-06-23  2:52 UTC (permalink / raw)
  To: ffmpeg-devel

[PATCH] aarch64: Add OpenBSD runtime detection of dotprod and i8mm using sysctl

Signed-off-by: Brad Smith <brad@comstyle.com>
---
 libavutil/aarch64/cpu.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/libavutil/aarch64/cpu.c b/libavutil/aarch64/cpu.c
index 196bdaf6b0..40fcc8d1ff 100644
--- a/libavutil/aarch64/cpu.c
+++ b/libavutil/aarch64/cpu.c
@@ -65,6 +65,41 @@ static int detect_flags(void)
     return flags;
 }
 
+#elif defined(__OpenBSD__)
+#include <machine/armreg.h>
+#include <machine/cpu.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+static int detect_flags(void)
+{
+    int flags = 0;
+    int mib[2];
+    uint64_t isar0;
+    uint64_t isar1;
+    size_t len;
+
+    mib[0] = CTL_MACHDEP;
+    mib[1] = CPU_ID_AA64ISAR0;
+    len = sizeof(isar0);
+    if (sysctl(mib, 2, &isar0, &len, NULL, 0) != -1) {
+        if (ID_AA64ISAR0_DP(isar0) >= ID_AA64ISAR0_DP_IMPL)
+            flags |= AV_CPU_FLAG_DOTPROD;
+    }
+
+    mib[0] = CTL_MACHDEP;
+    mib[1] = CPU_ID_AA64ISAR1;
+    len = sizeof(isar1);
+    if (sysctl(mib, 2, &isar1, &len, NULL, 0) != -1) {
+#ifdef ID_AA64ISAR1_I8MM_IMPL
+        if (ID_AA64ISAR1_I8MM(isar1) >= ID_AA64ISAR1_I8MM_IMPL)
+            flags |= AV_CPU_FLAG_I8MM;
+#endif
+    }
+
+    return flags;
+}
+
 #elif defined(_WIN32)
 #include <windows.h>
 
-- 
2.45.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] aarch64: Add OpenBSD runtime detection of dotprod and i8mm using sysctl
  2024-06-23  2:52 [FFmpeg-devel] [PATCH] aarch64: Add OpenBSD runtime detection of dotprod and i8mm using sysctl Brad Smith
@ 2024-06-24  8:15 ` Martin Storsjö
  2024-06-26  6:11   ` Brad Smith
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Storsjö @ 2024-06-24  8:15 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Sat, 22 Jun 2024, Brad Smith wrote:

> [PATCH] aarch64: Add OpenBSD runtime detection of dotprod and i8mm using sysctl
>
> Signed-off-by: Brad Smith <brad@comstyle.com>
> ---
> libavutil/aarch64/cpu.c | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/libavutil/aarch64/cpu.c b/libavutil/aarch64/cpu.c
> index 196bdaf6b0..40fcc8d1ff 100644
> --- a/libavutil/aarch64/cpu.c
> +++ b/libavutil/aarch64/cpu.c
> @@ -65,6 +65,41 @@ static int detect_flags(void)
>     return flags;
> }
>
> +#elif defined(__OpenBSD__)
> +#include <machine/armreg.h>
> +#include <machine/cpu.h>
> +#include <sys/types.h>
> +#include <sys/sysctl.h>
> +
> +static int detect_flags(void)
> +{
> +    int flags = 0;
> +    int mib[2];
> +    uint64_t isar0;
> +    uint64_t isar1;
> +    size_t len;
> +
> +    mib[0] = CTL_MACHDEP;
> +    mib[1] = CPU_ID_AA64ISAR0;
> +    len = sizeof(isar0);
> +    if (sysctl(mib, 2, &isar0, &len, NULL, 0) != -1) {
> +        if (ID_AA64ISAR0_DP(isar0) >= ID_AA64ISAR0_DP_IMPL)
> +            flags |= AV_CPU_FLAG_DOTPROD;
> +    }
> +
> +    mib[0] = CTL_MACHDEP;
> +    mib[1] = CPU_ID_AA64ISAR1;
> +    len = sizeof(isar1);
> +    if (sysctl(mib, 2, &isar1, &len, NULL, 0) != -1) {
> +#ifdef ID_AA64ISAR1_I8MM_IMPL
> +        if (ID_AA64ISAR1_I8MM(isar1) >= ID_AA64ISAR1_I8MM_IMPL)
> +            flags |= AV_CPU_FLAG_I8MM;
> +#endif
> +    }
> +
> +    return flags;
> +}
> +
> #elif defined(_WIN32)
> #include <windows.h>

This LGTM. Although, in 
https://code.videolan.org/videolan/dav1d/-/merge_requests/1673 you wrapped 
most of this in an #ifdef CPU_ID_AA64ISAR0, so would that be useful here 
too?

Feel free to push either with or without that.

// Martin

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] aarch64: Add OpenBSD runtime detection of dotprod and i8mm using sysctl
  2024-06-24  8:15 ` Martin Storsjö
@ 2024-06-26  6:11   ` Brad Smith
  0 siblings, 0 replies; 3+ messages in thread
From: Brad Smith @ 2024-06-26  6:11 UTC (permalink / raw)
  To: FFmpeg development discussions and patches, Martin Storsjö

On 2024-06-24 4:15 a.m., Martin Storsjö wrote:
> On Sat, 22 Jun 2024, Brad Smith wrote:
>
>> [PATCH] aarch64: Add OpenBSD runtime detection of dotprod and i8mm 
>> using sysctl
>>
>> Signed-off-by: Brad Smith <brad@comstyle.com>
>> ---
>> libavutil/aarch64/cpu.c | 35 +++++++++++++++++++++++++++++++++++
>> 1 file changed, 35 insertions(+)
>>
>> diff --git a/libavutil/aarch64/cpu.c b/libavutil/aarch64/cpu.c
>> index 196bdaf6b0..40fcc8d1ff 100644
>> --- a/libavutil/aarch64/cpu.c
>> +++ b/libavutil/aarch64/cpu.c
>> @@ -65,6 +65,41 @@ static int detect_flags(void)
>>     return flags;
>> }
>>
>> +#elif defined(__OpenBSD__)
>> +#include <machine/armreg.h>
>> +#include <machine/cpu.h>
>> +#include <sys/types.h>
>> +#include <sys/sysctl.h>
>> +
>> +static int detect_flags(void)
>> +{
>> +    int flags = 0;
>> +    int mib[2];
>> +    uint64_t isar0;
>> +    uint64_t isar1;
>> +    size_t len;
>> +
>> +    mib[0] = CTL_MACHDEP;
>> +    mib[1] = CPU_ID_AA64ISAR0;
>> +    len = sizeof(isar0);
>> +    if (sysctl(mib, 2, &isar0, &len, NULL, 0) != -1) {
>> +        if (ID_AA64ISAR0_DP(isar0) >= ID_AA64ISAR0_DP_IMPL)
>> +            flags |= AV_CPU_FLAG_DOTPROD;
>> +    }
>> +
>> +    mib[0] = CTL_MACHDEP;
>> +    mib[1] = CPU_ID_AA64ISAR1;
>> +    len = sizeof(isar1);
>> +    if (sysctl(mib, 2, &isar1, &len, NULL, 0) != -1) {
>> +#ifdef ID_AA64ISAR1_I8MM_IMPL
>> +        if (ID_AA64ISAR1_I8MM(isar1) >= ID_AA64ISAR1_I8MM_IMPL)
>> +            flags |= AV_CPU_FLAG_I8MM;
>> +#endif
>> +    }
>> +
>> +    return flags;
>> +}
>> +
>> #elif defined(_WIN32)
>> #include <windows.h>
>
> This LGTM. Although, in 
> https://code.videolan.org/videolan/dav1d/-/merge_requests/1673 you 
> wrapped most of this in an #ifdef CPU_ID_AA64ISAR0, so would that be 
> useful here too?


That would be a good idea. I will do the same. Thanks.

> Feel free to push either with or without that.
>
> // Martin
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-26  6:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-23  2:52 [FFmpeg-devel] [PATCH] aarch64: Add OpenBSD runtime detection of dotprod and i8mm using sysctl Brad Smith
2024-06-24  8:15 ` Martin Storsjö
2024-06-26  6:11   ` Brad Smith

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git