libpsm2/libpsm2-calc-checksum.patch

35 lines
994 B
Diff

Index: libpsm2-10.3.1/psm_context.c
===================================================================
--- libpsm2-10.3.1.orig/psm_context.c
+++ libpsm2-10.3.1/psm_context.c
@@ -146,6 +146,19 @@ static int psmi_get_envvar(const char *e
return 0;
}
+static inline
+uint8_t
+calc_hash(void *ptr, size_t nbytes)
+{
+ uint8_t *ucp = (uint8_t *) ptr;
+ uint8_t hash = 0;
+
+ while (nbytes--)
+ hash ^= *ucp++;
+
+ return hash;
+}
+
static
psm2_error_t
psmi_compute_start_and_end_unit(psmi_context_t *context,long unit_param,
@@ -180,8 +193,7 @@ psmi_compute_start_and_end_unit(psmi_con
/* else, we are going to being looking at:
(a hash of the job key plus the local rank id ) mod nunits. */
- for (i=0;i < sizeof(job_key);i++)
- hashedjk ^= job_key[i];
+ hashedjk = calc_hash(job_key, sizeof(psm2_uuid_t));
*unit_start = (psmi_get_envvar("MPI_LOCALRANKID") + hashedjk) % nunits;
if (*unit_start > 0)
*unit_end = *unit_start - 1;