Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Grzegorzek, Dominik" <dominik.grzegorzek@intel.com>
To: "Kempczynski, Zbigniew" <zbigniew.kempczynski@intel.com>
Cc: "Patelczyk, Maciej" <maciej.patelczyk@intel.com>,
	"Hajda, Andrzej" <andrzej.hajda@intel.com>,
	"Kuoppala, Mika" <mika.kuoppala@intel.com>,
	"Piatkowski, Dominik Karol" <dominik.karol.piatkowski@intel.com>,
	"Manszewski, Christoph" <christoph.manszewski@intel.com>,
	"Mun, Gwan-gyeong" <gwan-gyeong.mun@intel.com>,
	"igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>,
	"kamil.konieczny@linux.intel.com"
	<kamil.konieczny@linux.intel.com>,
	"Sikora, Pawel" <pawel.sikora@intel.com>,
	Kolanupaka Naveena <kolanupaka.naveena@intel.com>
Subject: Re: [PATCH i-g-t v6 16/17] tests/xe_eudebug_online: Debug client which runs workloads on EU
Date: Wed, 18 Sep 2024 06:44:36 +0000	[thread overview]
Message-ID: <de331d9a8268938a25514c90de43669600f84788.camel@intel.com> (raw)
In-Reply-To: <20240918050854.7f4gs3vjt74nxr3f@zkempczy-mobl2>

On Wed, 2024-09-18 at 07:08 +0200, Zbigniew Kempczyński wrote:
> On Tue, Sep 17, 2024 at 09:34:20PM +0200, Grzegorzek, Dominik wrote:
> 
> <cut>
> 
> > > > +static int count_set_bits(void *ptr, size_t size)
> > > > +{
> > > > +	uint8_t *p = ptr;
> > > > +	int count = 0;
> > > > +	int i, j;
> > > > +
> > > 
> > > hweight()?
> > > 
> > Are you proposing here to change the name or to implement it without second loop like below?
> 
> Yes, I just want to get rid of second loop.
> 
> > 
> > static int count_set_bits(void *ptr, size_t size)
> > {
> > 	uint32_t *p = ptr;
> > 	int count = 0;
> > 	int i;
> > 
> > 	igt_assert(size % 4 == 0);
> > 
> > 	for (i = 0; i < size/4; i++)
> > 		count += igt_hweight(p[i]);
> > 
> > 	return count;
> > }
> 
> You may iterate over uint8_t to cover all sizes, not only % 4.
> But if you're sure buffer will always be multiple of 4, this
> imo is ok.
> 
> <cut>
> 
> > > > +static void copy_first_bit(uint8_t *dst, uint8_t *src, int size)
> > > > +{
> > > > +	bool found = false;
> > > > +	int i, j;
> > > > +
> > > > +	for (i = 0; i < size; i++) {
> > > > +		if (found) {
> > > > +			dst[i] = 0;
> > > 
> > > Function is static, but according to line above I would add some
> > > comment that it is cleaning dst buffer. copy_first_bit() is misleading
> > > as you mean first bit set. First bit is src[0] & 1.
> > > 
> > > And what 'first' means? Having lets say src = { 0x0, 0xff, 0xcc, 0xaa }
> > > I would expect first should be most significant bit of 0xff.
> > > 
> > > 
> > > > +		} else {
> > > > +			uint32_t tmp = src[i]; /* in case dst == src */
> > > > +
> > > > +			for (j = 0; j < 8; j++) {
> > > 
> > > ffs()? But according to copy copy_nth_bit() I've doubts shouldn't this
> > > be fls()?
> > > 
> > > > +				dst[i] = tmp & (1 << j);
> > > > +				if (dst[i]) {
> > > > +					found = true;
> > > > +					break;
> > > > +				}
> > > > +			}
> > > > +		}
> > > > +	}
> > > > +}
> > > > +
> > > > +static void copy_nth_bit(uint8_t *dst, uint8_t *src, int size, int n)
> > > > +{
> > > > +	int count = 0;
> > > > +
> > > > +	for (int i = 0; i < size; i++) {
> > > > +		uint32_t tmp = src[i];
> > > > +
> > > > +		for (int j = 7; j >= 0; j--) {
> > > 
> > > I'm confused. In above function you iterate starting from least
> > > significant bit, here you start from most significant bit.
> > > Same concern about function name - shouldn't this be copy_nth_bit_set()?
> > > 
> > > > +			if (tmp & (1 << j)) {
> > > > +				count++;
> > > > +				if (count == n)
> > > > +					dst[i] |= (1 << j);
> > > > +				else
> > > > +					dst[i] &= ~(1 << j);
> > > 
> > > Do I understand correctly that you are clearing other bits in dst?
> > > It's extremely weird calling function copy_nth_bit() where it scans
> > > for n-th bit set, zeroing other bits in dst. Or I just don't understand
> > > logic behind this decision.
> > 
> > You've raised bunch of valid inaccuracies. How about:
> > 
> > static void only_nth_set_bit(uint8_t *dst, uint8_t *src, int size, int n)
> > {
> > 	int count = 0;
> > 
> > 	for (int i = 0; i < size; i++) {
> > 		if (count < n) {
> > 			uint8_t tmp = src[i];
> > 
> > 			for (int j = 0; j < 8; j++) {
> > 				if (tmp & (1 << j)) {
> > 					count++;
> > 					if (count == n)
> > 						dst[i] |= (1 << j);
> > 					else
> > 						dst[i] &= ~(1 << j);
> > 				} else {
> > 					dst[i] &= ~(1 << j);
> > 				}
> > 			}
> > 		} else {
> > 			dst[i] = 0;
> > 		}
> > 	}
> > }
> 
> Likely I would copy octet by octet from src[i] -> dst[i], tracking
> previous/current hweight and when it is bigger than n zeroing rest of bits in
> current octet. But this is implementation detail.
> 
> In above code you're copying from least significant bit, is this intended?
> Previous code was copying from most significant bit so this is
> definitely semantic change which according to hw behavior may be
> incorrect. May you double check this?
From the test pov this really doesn'm matter. We just wanted to keep single bit in the bitmask to
resume different thread. As long as different n gave different bit it was fine. However,
by 'first' I think we meant least significant bit, so I deliberately changed it that way. 

Regards,
Dominik

> 
> > 
> > static void only_first_set_bit(uint8_t *dst, uint8_t *src, int size)
> > {
> > 	return only_nth_set_bit(dst, src, size, 1);
> > }
> 
> Nice, code reuse is always good.
> 
> I'll drop rest of email to reply in another email. This will narrow
> our conversation to interesting part only.
> 
> --
> Zbigniew
>  


  reply	other threads:[~2024-09-18  6:44 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-05  9:27 [PATCH i-g-t v6 00/17] Test coverage for GPU debug support Christoph Manszewski
2024-09-05  9:27 ` [PATCH i-g-t v6 01/17] drm-uapi/xe: Sync with oa uapi fix Christoph Manszewski
2024-09-06 14:41   ` Kamil Konieczny
2024-09-05  9:27 ` [PATCH i-g-t v6 02/17] lib/xe_ioctl: Add wrapper with vm_bind_op extension parameter Christoph Manszewski
2024-09-05  9:27 ` [PATCH i-g-t v6 03/17] lib/gpgpu_shader: Extend shader building library Christoph Manszewski
2024-09-05 11:56   ` Zbigniew Kempczyński
2024-09-09  6:54   ` Zbigniew Kempczyński
2024-09-05  9:27 ` [PATCH i-g-t v6 04/17] lib/gpgpu_shader: Add write_on_exception template Christoph Manszewski
2024-09-05 10:51   ` Zbigniew Kempczyński
2024-09-06  5:58     ` Andrzej Hajda
2024-09-06  6:54       ` Zbigniew Kempczyński
2024-09-05  9:28 ` [PATCH i-g-t v6 05/17] lib/gpgpu_shader: Add set/clear exception register (cr0.1) helpers Christoph Manszewski
2024-09-05  9:28 ` [PATCH i-g-t v6 06/17] lib/intel_batchbuffer: Add helper to get pointer at specified offset Christoph Manszewski
2024-09-06  7:46   ` Zbigniew Kempczyński
2024-09-05  9:28 ` [PATCH i-g-t v6 07/17] lib/gpgpu_shader: Allow enabling illegal opcode exceptions in shader Christoph Manszewski
2024-09-05  9:28 ` [PATCH i-g-t v6 08/17] tests/xe_exec_sip: Add sanity-after-timeout test Christoph Manszewski
2024-09-05  9:28 ` [PATCH i-g-t v6 09/17] tests/xe_exec_sip: Introduce invalid instruction tests Christoph Manszewski
2024-09-05 18:39   ` Zbigniew Kempczyński
2024-09-09  7:21   ` Zbigniew Kempczyński
2024-09-13 11:50     ` Manszewski, Christoph
2024-09-05  9:28 ` [PATCH i-g-t v6 10/17] drm-uapi/xe: Sync with eudebug uapi Christoph Manszewski
2024-09-05  9:28 ` [PATCH i-g-t v6 11/17] lib/xe_eudebug: Introduce eu debug testing framework Christoph Manszewski
2024-09-09  8:46   ` Zbigniew Kempczyński
2024-09-13 15:14     ` Manszewski, Christoph
2024-09-16  6:48       ` Zbigniew Kempczyński
2024-09-10  5:32   ` Zbigniew Kempczyński
2024-09-05  9:28 ` [PATCH i-g-t v6 12/17] scripts/igt_doc: Add '--exclude-files' parameter Christoph Manszewski
2024-09-09 11:31   ` Kamil Konieczny
2024-09-09 13:57     ` Zbigniew Kempczyński
2024-09-13 13:24       ` Manszewski, Christoph
2024-09-13 16:40         ` Kamil Konieczny
2024-09-05  9:28 ` [PATCH i-g-t v6 13/17] tests/xe_eudebug: Test eudebug resource tracking and manipulation Christoph Manszewski
2024-09-06 14:46   ` Kamil Konieczny
2024-09-09 10:34     ` Zbigniew Kempczyński
2024-09-12  8:04   ` Zbigniew Kempczyński
2024-09-17 14:44     ` Manszewski, Christoph
2024-09-17 16:00     ` Manszewski, Christoph
2024-09-18  4:47       ` Zbigniew Kempczyński
2024-09-05  9:28 ` [PATCH i-g-t v6 14/17] lib/intel_batchbuffer: Add support for long-running mode execution Christoph Manszewski
2024-09-05  9:28 ` [PATCH i-g-t v6 15/17] tests/xe_exec_sip_eudebug: Port tests for shaders and sip Christoph Manszewski
2024-09-05  9:28 ` [PATCH i-g-t v6 16/17] tests/xe_eudebug_online: Debug client which runs workloads on EU Christoph Manszewski
2024-09-13 11:39   ` Zbigniew Kempczyński
2024-09-17 19:34     ` Grzegorzek, Dominik
2024-09-18  5:08       ` Zbigniew Kempczyński
2024-09-18  6:44         ` Grzegorzek, Dominik [this message]
2024-09-18  5:21       ` Zbigniew Kempczyński
2024-09-05  9:28 ` [PATCH i-g-t v6 17/17] tests/xe_live_ktest: Add xe_eudebug live test Christoph Manszewski
2024-09-05 21:04 ` ✗ GitLab.Pipeline: warning for Test coverage for GPU debug support (rev6) Patchwork
2024-09-05 21:33 ` ✓ CI.xeBAT: success " Patchwork
2024-09-05 21:40 ` ✗ Fi.CI.BAT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=de331d9a8268938a25514c90de43669600f84788.camel@intel.com \
    --to=dominik.grzegorzek@intel.com \
    --cc=andrzej.hajda@intel.com \
    --cc=christoph.manszewski@intel.com \
    --cc=dominik.karol.piatkowski@intel.com \
    --cc=gwan-gyeong.mun@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=kolanupaka.naveena@intel.com \
    --cc=maciej.patelczyk@intel.com \
    --cc=mika.kuoppala@intel.com \
    --cc=pawel.sikora@intel.com \
    --cc=zbigniew.kempczynski@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox