interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / src / omega_gpu_engine.c

480 lines · 18625 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0
2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * Omega GPU Engine core (A3a). See src/omega_gpu_engine.h and
19 * docs/numeric/OMEGA_GPU_ENGINE.md.
20 *
21 * omega_gpu_execute drives the backend function table in one fixed order:
22 * open, channel, alloc x5, copy-in x3, poison fill, build -> PREPARED
23 * submit -> SUBMITTED
24 * marker wait, marker2 wait (unless NO_C3), release wait -> GPU_COMPLETE
25 * barrier, copy-out -> OUTPUT_VISIBLE
26 * compare every output word with its poison word -> OUTPUT_PRODUCED
27 * free every buffer (reverse order), close -> SUCCESS
28 * Every exit runs cleanup EXCEPT an uncertain completion (any non-zero result
29 * from one of the three completion waits), which keeps the context and every
30 * allocation, sets the process-wide block and reports retained = 1.
31 * The engine never judges the math: it only checks that output words changed.
32 *
33 * Marker comments of the form MUT:<name> label the lines that
34 * tools/gpu_engine_mutations.sh breaks one at a time.
35 */
36#include "omega_gpu_engine.h"
37
38#include <stdatomic.h>
39#include <string.h>
40#ifdef OMEGA_GPU_NO_POSIX
41/* Freestanding link target (native v1 P07 cut A, aienos#286 cut A): no errno
42 * and no POSIX clock. err_no is always 0, and the millisecond clock must be
43 * installed with omega_gpu_engine_set_clock before any job runs; without one
44 * omega_gpu_execute refuses at STEP_CLOCK_CHECK instead of guessing. */
45#define ERRNO_CLEAR() ((void)0)
46#define ERRNO_READ() 0
47#else
48#include <errno.h>
49#include <time.h>
50#define ERRNO_CLEAR() (errno = 0)
51#define ERRNO_READ() (errno)
52#endif
53
54static const char *const FAILURE_NAMES[OMEGA_GPU_ENGINE_FAILURE_COUNT] = {
55 "OK",
56 "DEVICE_OPEN",
57 "CHANNEL_CREATE",
58 "ALLOC",
59 "PREPARE",
60 "SUBMIT",
61 "COMPLETION_WAIT",
62 "RELEASE_WAIT",
63 "VISIBILITY_WAIT",
64 "OUTPUT_UNCHANGED",
65 "INVALID_ARGS",
66 "INTERNAL_INVARIANT",
67 "CLEANUP",
68 "UNCERTAIN_COMPLETION_BLOCKED",
69};
70
71static const char *const STATE_NAMES[OMEGA_GPU_ENGINE_STATE_COUNT] = {
72 "INITIAL",
73 "PREPARED",
74 "SUBMITTED",
75 "GPU_COMPLETE",
76 "OUTPUT_VISIBLE",
77 "OUTPUT_PRODUCED",
78 "SUCCESS",
79};
80
81static const char *const WAIT_NAMES[OMEGA_GPU_ENGINE_WAIT_COUNT] = {
82 "NONE",
83 "MARKER",
84 "RELEASE_SEMAPHORE",
85 "MARKER2",
86};
87
88static const char *const STEP_NAMES[OMEGA_GPU_ENGINE_STEP_COUNT] = {
89 "NONE",
90 "VALIDATE",
91 "BACKEND_CHECK",
92 "BLOCKED",
93 "NOT_IMPLEMENTED",
94 "OPEN_DEVICE",
95 "CREATE_CHANNEL",
96 "ALLOC",
97 "COPY_IN",
98 "FILL_POISON",
99 "BUILD",
100 "SUBMIT",
101 "WAIT_MARKER",
102 "WAIT_MARKER2",
103 "WAIT_RELEASE_SEMAPHORE",
104 "BARRIER",
105 "COPY_OUT",
106 "SCAN",
107 "FREE",
108 "CLOSE",
109 "CLOCK_CHECK",
110};
111
112static _Atomic(const OmegaGpuBackend *) g_backend;
113static atomic_int g_blocked;
114static uint64_t (*g_clock)(void); /* installed clock; NULL means CLOCK_MONOTONIC on the host, none when freestanding */
115
116const char *omega_gpu_engine_failure_name(int failure)
117{
118 if (failure < 0 || failure >= (int)OMEGA_GPU_ENGINE_FAILURE_COUNT) return "UNKNOWN";
119 return FAILURE_NAMES[failure];
120}
121
122const char *omega_gpu_engine_state_name(int state)
123{
124 if (state < 0 || state >= (int)OMEGA_GPU_ENGINE_STATE_COUNT) return "UNKNOWN";
125 return STATE_NAMES[state];
126}
127
128const char *omega_gpu_engine_wait_name(int wait)
129{
130 if (wait < 0 || wait >= (int)OMEGA_GPU_ENGINE_WAIT_COUNT) return "UNKNOWN";
131 return WAIT_NAMES[wait];
132}
133
134const char *omega_gpu_engine_step_name(int step)
135{
136 if (step < 0 || step >= (int)OMEGA_GPU_ENGINE_STEP_COUNT) return "UNKNOWN";
137 return STEP_NAMES[step];
138}
139
140void omega_gpu_engine_set_backend(const OmegaGpuBackend *backend)
141{
142 atomic_store(&g_backend, backend);
143}
144
145int omega_gpu_engine_is_blocked(void)
146{
147 return atomic_load(&g_blocked) ? 1 : 0;
148}
149
150void omega_gpu_engine_test_reset_block(void)
151{
152 atomic_store(&g_blocked, 0);
153}
154
155void omega_gpu_engine_test_force_block(void)
156{
157 atomic_store(&g_blocked, 1);
158}
159
160void omega_gpu_engine_set_clock(uint64_t (*now_ms)(void))
161{
162 g_clock = now_ms;
163}
164
165void omega_gpu_engine_test_set_clock(uint64_t (*now_ms)(void))
166{
167 g_clock = now_ms;
168}
169
170#ifdef OMEGA_GPU_NO_POSIX
171static uint64_t now_ms(void)
172{
173 return g_clock ? g_clock() : 0u; /* unreachable without a clock: omega_gpu_execute refuses first */
174}
175#else
176static uint64_t mono_ms(void)
177{
178 struct timespec ts;
179 if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) return 0u;
180 return (uint64_t)ts.tv_sec * 1000u + (uint64_t)ts.tv_nsec / 1000000u;
181}
182
183static uint64_t now_ms(void)
184{
185 return g_clock ? g_clock() : mono_ms();
186}
187#endif
188
189static int backend_complete(const OmegaGpuBackend *b)
190{
191 return b->open_device && b->create_channel && b->alloc && b->copy_in && b->fill_poison &&
192 b->build && b->submit && b->wait_marker && b->wait_marker2 &&
193 b->wait_release_semaphore && b->barrier && b->copy_out && b->diagnostics &&
194 b->free_buf && b->close;
195}
196
197/* Returns 1 when the job is well formed for the VECTOR_1D layout. */
198static int job_valid(const OmegaGpuJob *job)
199{
200 uint64_t bytes;
201 if (!job->program || job->program_len == 0) return 0; /* MUT:VALID_PROGRAM */
202 if (job->layout != OMEGA_GPU_LAYOUT_VECTOR_1D) return 0; /* MUT:VALID_LAYOUT */
203 if (job->element_count == 0) return 0; /* MUT:VALID_COUNT_ZERO */
204 bytes = (uint64_t)job->element_count * 4u;
205 if (!job->input_a || (uint64_t)job->input_a_len != bytes) return 0;
206 if (!job->input_b || (uint64_t)job->input_b_len != bytes) return 0;
207 if (!job->output || (uint64_t)job->output_len != bytes) return 0;
208 if (((uintptr_t)job->output & 3u) != 0) return 0; /* MUT:VALID_ALIGN */
209 if (!job->poison || (uint64_t)job->poison_count != (uint64_t)job->element_count) return 0; /* MUT:VALID_POISON_COUNT */
210 if ((job->flags & ~(uint32_t)OMEGA_GPU_ENGINE_FLAG_NO_C3) != 0) return 0; /* MUT:VALID_FLAGS */
211 if (job->timeouts.marker_ms == 0) return 0; /* MUT:VALID_TIMEOUT_MARKER1 */
212 if (job->timeouts.release_semaphore_ms == 0) return 0;
213 if (job->timeouts.visibility_ms == 0) return 0;
214 if ((job->flags & OMEGA_GPU_ENGINE_FLAG_NO_C3) == 0 && job->timeouts.marker2_ms == 0) return 0; /* MUT:VALID_TIMEOUT_MARKER2 */
215 return 1;
216}
217
218/* What the engine still owes the device: close if opened, free each allocated buffer. */
219typedef struct {
220 int opened;
221 int allocated[OMEGA_GPU_BUF_ROLE_COUNT];
222} Run;
223
224/* Failure before any backend call: nothing to capture, nothing to clean. */
225static int stop(OmegaGpuResult *result, int failure, int step)
226{
227 result->failure = failure;
228 result->failed_step = step;
229 return failure;
230}
231
232/* Copies the backend diagnostics (driver code, text, observed words) into the result. */
233static void capture(const OmegaGpuBackend *b, OmegaGpuResult *result)
234{
235 OmegaGpuBackendDiag d;
236 memset(&d, 0, sizeof d);
237 b->diagnostics(b->ctx, &d);
238 result->drv_rc = d.drv_rc;
239 memcpy(result->drv_text, d.drv_text, sizeof result->drv_text);
240 result->drv_text[sizeof result->drv_text - 1u] = '\0';
241 result->sync_valid = d.sync_valid;
242 result->marker = d.marker;
243 result->marker2 = d.marker2;
244 memcpy(result->semaphore, d.semaphore, sizeof result->semaphore);
245}
246
247/* Records the failure of a backend call. err is errno captured right after that call. */
248static int fail(const OmegaGpuBackend *b, OmegaGpuResult *result, int failure, int step, int err)
249{
250 capture(b, result);
251 result->failure = failure;
252 result->failed_step = step;
253 result->err_no = err;
254 return failure;
255}
256
257/* A cleanup call failed. The first failure of the run is never overwritten. */
258static void cleanup_fault(const OmegaGpuBackend *b, OmegaGpuResult *result, int step, int err)
259{
260 if (result->failure == OMEGA_GPU_ENGINE_OK) /* MUT:CLEANUP_OVERWRITES_FIRST */
261 (void)fail(b, result, OMEGA_GPU_ENGINE_CLEANUP, step, err);
262 result->cleanup_failed = 1; /* MUT:CLEANUP_FLAG_NOT_SET */
263}
264
265/* Frees every allocated buffer (reverse of allocation order), then closes the
266 * device. A failing call does not stop the rest. Returns result->failure. */
267static int leave(const OmegaGpuBackend *b, const Run *run, OmegaGpuResult *result)
268{
269 int role;
270 int rc;
271 int e;
272 for (role = (int)OMEGA_GPU_BUF_ROLE_COUNT - 1; role >= 0; role--) {
273 if (!run->allocated[role]) continue; /* MUT:FREE_UNALLOCATED */
274 ERRNO_CLEAR();
275 rc = b->free_buf(b->ctx, role); /* MUT:FREE_SKIPPED */
276 e = ERRNO_READ();
277 if (rc != 0) cleanup_fault(b, result, OMEGA_GPU_ENGINE_STEP_FREE, e);
278 }
279 if (run->opened) {
280 ERRNO_CLEAR();
281 rc = b->close(b->ctx); /* MUT:CLOSE_SKIPPED */
282 e = ERRNO_READ();
283 if (rc != 0) cleanup_fault(b, result, OMEGA_GPU_ENGINE_STEP_CLOSE, e);
284 }
285 return result->failure;
286}
287
288/* A completion wait gave a non-zero result: completion is uncertain. Keep the
289 * context and every allocation (no free, no close), say so, and block the process. */
290static int uncertain(const OmegaGpuBackend *b, OmegaGpuResult *result, int failure, int step,
291 int wait, uint64_t limit_ms, uint64_t waited_ms, int err)
292{
293 (void)fail(b, result, failure, step, err);
294 result->wait = wait;
295 result->wait_timeout_ms = limit_ms;
296 result->waited_ms = waited_ms;
297 result->retained = 1; /* MUT:RETAINED_FLAG_NOT_SET */
298 atomic_store(&g_blocked, 1); /* MUT:NO_BLOCK */
299 return failure;
300}
301
302/* Calls a timed backend callback; captures errno right after it and measures the wait. */
303static int timed_call(int (*fn)(void *, uint64_t), void *ctx, uint64_t ms, uint64_t *waited_ms,
304 int *err)
305{
306 uint64_t t0 = now_ms();
307 uint64_t t1;
308 int rc;
309 ERRNO_CLEAR();
310 rc = fn(ctx, ms);
311 *err = ERRNO_READ();
312 t1 = now_ms();
313 *waited_ms = t1 >= t0 ? t1 - t0 : 0u; /* MUT:WAITED_NOT_A_DIFFERENCE */
314 return rc;
315}
316
317static int copy_in_role(const OmegaGpuBackend *b, int role, const void *src, size_t bytes, int *err)
318{
319 int rc;
320 ERRNO_CLEAR();
321 rc = b->copy_in(b->ctx, role, src, bytes);
322 *err = ERRNO_READ();
323 return rc;
324}
325
326/* Device bytes for a buffer role. SCRATCH (pushbuffer, marker page, QMD) is the
327 * backend's own business, so the engine passes 0 and the backend sizes it. */
328static size_t buf_bytes(const OmegaGpuJob *job, int role)
329{
330 switch (role) {
331 case OMEGA_GPU_BUF_PROGRAM: return job->program_len;
332 case OMEGA_GPU_BUF_INPUT_A: return job->input_a_len;
333 case OMEGA_GPU_BUF_INPUT_B: return job->input_b_len;
334 case OMEGA_GPU_BUF_OUTPUT: return job->output_len;
335 default: return 0u;
336 }
337}
338
339int omega_gpu_execute(const OmegaGpuJob *job, OmegaGpuResult *result)
340{
341 const OmegaGpuBackend *b;
342 Run run;
343 uint64_t waited = 0u;
344 uint64_t unchanged = 0u;
345 size_t i;
346 int role;
347 int rc;
348 int e = 0;
349
350 if (!result) return OMEGA_GPU_ENGINE_INVALID_ARGS;
351 memset(result, 0, sizeof *result);
352 result->failure = OMEGA_GPU_ENGINE_OK;
353 result->last_state = OMEGA_GPU_ENGINE_STATE_INITIAL;
354 result->failed_step = OMEGA_GPU_ENGINE_STEP_NONE;
355 result->wait = OMEGA_GPU_ENGINE_WAIT_NONE;
356 if (omega_gpu_engine_is_blocked()) /* MUT:BLOCK_CHECK_SKIPPED */
357 return stop(result, OMEGA_GPU_ENGINE_UNCERTAIN_COMPLETION_BLOCKED,
358 OMEGA_GPU_ENGINE_STEP_BLOCKED);
359 if (!job || !job_valid(job)) /* MUT:VALIDATE_SKIPPED */
360 return stop(result, OMEGA_GPU_ENGINE_INVALID_ARGS, OMEGA_GPU_ENGINE_STEP_VALIDATE);
361 b = atomic_load(&g_backend);
362 if (!b)
363 return stop(result, OMEGA_GPU_ENGINE_INTERNAL_INVARIANT, OMEGA_GPU_ENGINE_STEP_NOT_IMPLEMENTED);
364 if (!backend_complete(b)) /* MUT:BACKEND_CHECK_SKIPPED */
365 return stop(result, OMEGA_GPU_ENGINE_INTERNAL_INVARIANT,
366 OMEGA_GPU_ENGINE_STEP_BACKEND_CHECK);
367#ifdef OMEGA_GPU_NO_POSIX
368 if (!g_clock) /* no platform clock: waited_ms could not be measured; refuse before touching the device */
369 return stop(result, OMEGA_GPU_ENGINE_INTERNAL_INVARIANT, OMEGA_GPU_ENGINE_STEP_CLOCK_CHECK);
370#endif
371 memset(&run, 0, sizeof run);
372
373 /* INITIAL -> PREPARED */
374 ERRNO_CLEAR();
375 rc = b->open_device(b->ctx);
376 e = ERRNO_READ();
377 if (rc != 0) {
378 (void)fail(b, result, OMEGA_GPU_ENGINE_DEVICE_OPEN, OMEGA_GPU_ENGINE_STEP_OPEN_DEVICE, e);
379 return leave(b, &run, result);
380 }
381 run.opened = 1; /* MUT:OPEN_NOT_TRACKED */
382
383 ERRNO_CLEAR();
384 rc = b->create_channel(b->ctx);
385 e = ERRNO_READ();
386 if (rc != 0) {
387 (void)fail(b, result, OMEGA_GPU_ENGINE_CHANNEL_CREATE, OMEGA_GPU_ENGINE_STEP_CREATE_CHANNEL, e);
388 return leave(b, &run, result); /* MUT:CLEANUP_SKIPPED_CHANNEL */
389 }
390
391 for (role = 0; role < (int)OMEGA_GPU_BUF_ROLE_COUNT; role++) {
392 ERRNO_CLEAR();
393 rc = b->alloc(b->ctx, role, buf_bytes(job, role));
394 e = ERRNO_READ();
395 if (rc != 0) {
396 (void)fail(b, result, OMEGA_GPU_ENGINE_ALLOC, OMEGA_GPU_ENGINE_STEP_ALLOC, e);
397 return leave(b, &run, result); /* MUT:CLEANUP_SKIPPED_ALLOC */
398 }
399 run.allocated[role] = 1; /* MUT:ALLOC_NOT_TRACKED */
400 }
401
402 rc = copy_in_role(b, OMEGA_GPU_BUF_PROGRAM, job->program, job->program_len, &e);
403 if (rc == 0) rc = copy_in_role(b, OMEGA_GPU_BUF_INPUT_A, job->input_a, job->input_a_len, &e);
404 if (rc == 0) rc = copy_in_role(b, OMEGA_GPU_BUF_INPUT_B, job->input_b, job->input_b_len, &e);
405 if (rc != 0) {
406 (void)fail(b, result, OMEGA_GPU_ENGINE_PREPARE, OMEGA_GPU_ENGINE_STEP_COPY_IN, e);
407 return leave(b, &run, result); /* MUT:CLEANUP_SKIPPED_COPY_IN */
408 }
409
410 ERRNO_CLEAR(); rc = b->fill_poison(b->ctx, job->poison, job->poison_count); e = ERRNO_READ(); /* MUT:POISON_FILL_SKIPPED */
411 if (rc != 0) {
412 (void)fail(b, result, OMEGA_GPU_ENGINE_PREPARE, OMEGA_GPU_ENGINE_STEP_FILL_POISON, e);
413 return leave(b, &run, result);
414 }
415
416 ERRNO_CLEAR();
417 rc = b->build(b->ctx, job);
418 e = ERRNO_READ();
419 if (rc != 0) {
420 (void)fail(b, result, OMEGA_GPU_ENGINE_PREPARE, OMEGA_GPU_ENGINE_STEP_BUILD, e);
421 return leave(b, &run, result);
422 }
423 result->last_state = OMEGA_GPU_ENGINE_STATE_PREPARED; /* MUT:STATE_PREPARED_SKIPPED */
424
425 /* PREPARED -> SUBMITTED. A failed submit is a known failure, not an uncertain completion. */
426 ERRNO_CLEAR();
427 rc = b->submit(b->ctx);
428 e = ERRNO_READ();
429 if (rc != 0) {
430 (void)fail(b, result, OMEGA_GPU_ENGINE_SUBMIT, OMEGA_GPU_ENGINE_STEP_SUBMIT, e);
431 return leave(b, &run, result); /* MUT:CLEANUP_SKIPPED_SUBMIT */
432 }
433 result->last_state = OMEGA_GPU_ENGINE_STATE_SUBMITTED; /* MUT:STATE_SUBMITTED_SKIPPED */
434
435 /* SUBMITTED -> GPU_COMPLETE: marker, marker2 (unless NO_C3), release semaphore.
436 * Any non-zero result is an uncertain completion. */
437 rc = timed_call(b->wait_marker, b->ctx, job->timeouts.marker_ms, &waited, &e); /* MUT:MARKER1_WAIT_SKIPPED MUT:MARKER1_TIMEOUT_WRONG */
438 if (rc != 0) return uncertain(b, result, OMEGA_GPU_ENGINE_COMPLETION_WAIT, OMEGA_GPU_ENGINE_STEP_WAIT_MARKER, OMEGA_GPU_ENGINE_WAIT_MARKER, job->timeouts.marker_ms, waited, e); /* MUT:MARKER1_RESULT_IGNORED MUT:UNCERTAIN_FREES_MARKER1 */
439 if (!(job->flags & OMEGA_GPU_ENGINE_FLAG_NO_C3)) { /* MUT:MARKER2_WAIT_SKIPPED MUT:C3_FLAG_IGNORED */
440 rc = timed_call(b->wait_marker2, b->ctx, job->timeouts.marker2_ms, &waited, &e);
441 if (rc != 0) return uncertain(b, result, OMEGA_GPU_ENGINE_COMPLETION_WAIT, OMEGA_GPU_ENGINE_STEP_WAIT_MARKER2, OMEGA_GPU_ENGINE_WAIT_MARKER2, job->timeouts.marker2_ms, waited, e); /* MUT:MARKER2_RESULT_IGNORED MUT:UNCERTAIN_FREES_MARKER2 */
442 }
443 rc = timed_call(b->wait_release_semaphore, b->ctx, job->timeouts.release_semaphore_ms, &waited, &e); /* MUT:RELEASE_WAIT_SKIPPED */
444 if (rc != 0) return uncertain(b, result, OMEGA_GPU_ENGINE_RELEASE_WAIT, OMEGA_GPU_ENGINE_STEP_WAIT_RELEASE_SEMAPHORE, OMEGA_GPU_ENGINE_WAIT_RELEASE_SEMAPHORE, job->timeouts.release_semaphore_ms, waited, e); /* MUT:RELEASE_RESULT_IGNORED MUT:UNCERTAIN_FREES_RELEASE */
445 result->last_state = OMEGA_GPU_ENGINE_STATE_GPU_COMPLETE; /* MUT:STATE_GPU_COMPLETE_SKIPPED */
446
447 /* GPU_COMPLETE -> OUTPUT_VISIBLE: completion is known here, so a failure cleans up. */
448 rc = timed_call(b->barrier, b->ctx, job->timeouts.visibility_ms, &waited, &e); /* MUT:BARRIER_SKIPPED */
449 if (rc != 0) { /* MUT:BARRIER_RESULT_IGNORED */
450 (void)fail(b, result, OMEGA_GPU_ENGINE_VISIBILITY_WAIT, OMEGA_GPU_ENGINE_STEP_BARRIER, e);
451 return leave(b, &run, result);
452 }
453 ERRNO_CLEAR();
454 rc = b->copy_out(b->ctx, job->output, job->output_len);
455 e = ERRNO_READ();
456 if (rc != 0) {
457 (void)fail(b, result, OMEGA_GPU_ENGINE_VISIBILITY_WAIT, OMEGA_GPU_ENGINE_STEP_COPY_OUT, e);
458 return leave(b, &run, result);
459 }
460 result->last_state = OMEGA_GPU_ENGINE_STATE_OUTPUT_VISIBLE; /* MUT:STATE_OUTPUT_VISIBLE_SKIPPED */
461
462 /* OUTPUT_VISIBLE -> OUTPUT_PRODUCED: no output word may still equal its poison word. */
463 for (i = 0; i < (size_t)job->element_count; i++) {
464 uint32_t w;
465 memcpy(&w, (const unsigned char *)job->output + i * 4u, sizeof w);
466 if (w == job->poison[i]) unchanged++; /* MUT:POISON_INDEX_FIXED MUT:UNCHANGED_COUNT_SATURATES */
467 }
468 result->n_outputs = 1u;
469 result->output_unchanged_words[0] = unchanged;
470 if (unchanged != 0u) { /* MUT:UNCHANGED_CHECK_SKIPPED */
471 (void)fail(b, result, OMEGA_GPU_ENGINE_OUTPUT_UNCHANGED, OMEGA_GPU_ENGINE_STEP_SCAN, 0);
472 return leave(b, &run, result);
473 }
474 result->last_state = OMEGA_GPU_ENGINE_STATE_OUTPUT_PRODUCED; /* MUT:STATE_OUTPUT_PRODUCED_SKIPPED */
475
476 /* OUTPUT_PRODUCED -> SUCCESS, only when cleanup also went well. */
477 rc = leave(b, &run, result);
478 if (rc == OMEGA_GPU_ENGINE_OK) result->last_state = OMEGA_GPU_ENGINE_STATE_SUCCESS; /* MUT:STATE_SUCCESS_SKIPPED MUT:SUCCESS_AFTER_CLEANUP_FAIL */
479 return rc;
480}