Skip to content

Commit

Permalink
Merge pull request #85 from gdonval/fix-malloc
Browse files Browse the repository at this point in the history
Use `size_t` in `mr2d_malloc` instead of index-bound `Int`
  • Loading branch information
langou authored Aug 6, 2024
2 parents 0234af9 + eaabe78 commit 25935e1
Show file tree
Hide file tree
Showing 21 changed files with 84 additions and 82 deletions.
14 changes: 7 additions & 7 deletions REDIST/SRC/pcgemr.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ Cpcgemr2d(m, n,
assert((myprow1 < p1 && mypcol1 < q1) || (myprow1 == -1 && mypcol1 == -1));
/* exchange the missing parameters among the processors: shape of grids and
* location of the processors */
param = (Int *) mr2d_malloc(3 * (nprocs * 2 + NBPARAM) * sizeof(Int));
param = (Int *) mr2d_malloc(3 * ((size_t)nprocs * 2 + NBPARAM) * sizeof(Int));
ra = param + nprocs * 2 + NBPARAM;
ca = param + (nprocs * 2 + NBPARAM) * 2;
for (i = 0; i < nprocs * 2 + NBPARAM; i++)
Expand Down Expand Up @@ -467,10 +467,10 @@ Cpcgemr2d(m, n,
/* allocing room for the tabs, alloc for the worst case,local_n or local_m
* intervals, in fact the worst case should be less, perhaps half that,I
* should think of that one day. */
h_inter = (IDESC *) mr2d_malloc(DIVUP(ma->n, q0 * ma->nbcol) *
ma->nbcol * sizeof(IDESC));
v_inter = (IDESC *) mr2d_malloc(DIVUP(ma->m, p0 * ma->nbrow)
* ma->nbrow * sizeof(IDESC));
h_inter = (IDESC *) mr2d_malloc((size_t)(DIVUP(ma->n, q0 * ma->nbcol)) *
(size_t)ma->nbcol * sizeof(IDESC));
v_inter = (IDESC *) mr2d_malloc((size_t)(DIVUP(ma->m, p0 * ma->nbrow))
* (size_t)ma->nbrow * sizeof(IDESC));
/* We go for the scanning of indices. For each processor including mypnum,
* we fill the sendbuff buffer (scanD0(SENDBUFF)) and when it is done send
* it. Then for each processor, we compute the size of message to be
Expand Down Expand Up @@ -570,7 +570,7 @@ init_chenille(Int mypnum, Int nprocs, Int n0, Int *proc0, Int n1, Int *proc1, In
Int ns, nr, i, tot;
Int *sender, *recver, *g0, *g1;
tot = max(n0, n1);
sender = (Int *) mr2d_malloc((nprocs + tot) * sizeof(Int) * 2);
sender = (Int *) mr2d_malloc((size_t)(nprocs + tot) * sizeof(Int) * 2);
recver = sender + tot;
*psend = sender;
*precv = recver;
Expand Down Expand Up @@ -706,7 +706,7 @@ gridreshape(Int *ctxtp)
Int i, j;
ori = *ctxtp;
Cblacs_gridinfo(ori, &nprow, &npcol, &myrow, &mycol);
usermap = mr2d_malloc(sizeof(Int) * nprow * npcol);
usermap = mr2d_malloc(sizeof(Int) * (size_t)nprow * (size_t)npcol);
for (i = 0; i < nprow; i++)
for (j = 0; j < npcol; j++) {
usermap[i + j * nprow] = Cblacs_pnum(ori, i, j);
Expand Down
2 changes: 1 addition & 1 deletion REDIST/SRC/pcgemr2.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ setmemory(complex **adpointer, Int blocksize)
return;
}
*adpointer = (complex *) mr2d_malloc(
blocksize * sizeof(complex));
(size_t)blocksize * sizeof(complex));
}
/******************************************************************/
/* Free the memory space after the malloc */
Expand Down
14 changes: 7 additions & 7 deletions REDIST/SRC/pctrmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ Cpctrmr2d(uplo, diag, m, n,
assert((myprow1 < p1 && mypcol1 < q1) || (myprow1 == -1 && mypcol1 == -1));
/* exchange the missing parameters among the processors: shape of grids and
* location of the processors */
param = (Int *) mr2d_malloc(3 * (nprocs * 2 + NBPARAM) * sizeof(Int));
param = (Int *) mr2d_malloc(3 * ((size_t)nprocs * 2 + NBPARAM) * sizeof(Int));
ra = param + nprocs * 2 + NBPARAM;
ca = param + (nprocs * 2 + NBPARAM) * 2;
for (i = 0; i < nprocs * 2 + NBPARAM; i++)
Expand Down Expand Up @@ -484,10 +484,10 @@ Cpctrmr2d(uplo, diag, m, n,
/* allocing room for the tabs, alloc for the worst case,local_n or local_m
* intervals, in fact the worst case should be less, perhaps half that,I
* should think of that one day. */
h_inter = (IDESC *) mr2d_malloc(DIVUP(ma->n, q0 * ma->nbcol) *
ma->nbcol * sizeof(IDESC));
v_inter = (IDESC *) mr2d_malloc(DIVUP(ma->m, p0 * ma->nbrow)
* ma->nbrow * sizeof(IDESC));
h_inter = (IDESC *) mr2d_malloc((size_t)(DIVUP(ma->n, q0 * ma->nbcol)) *
(size_t)ma->nbcol * sizeof(IDESC));
v_inter = (IDESC *) mr2d_malloc((size_t)(DIVUP(ma->m, p0 * ma->nbrow))
* (size_t)ma->nbrow * sizeof(IDESC));
/* We go for the scanning of indices. For each processor including mypnum,
* we fill the sendbuff buffer (scanD0(SENDBUFF)) and when it is done send
* it. Then for each processor, we compute the size of message to be
Expand Down Expand Up @@ -592,7 +592,7 @@ init_chenille(Int mypnum, Int nprocs, Int n0, Int *proc0, Int n1, Int *proc1, In
Int ns, nr, i, tot;
Int *sender, *recver, *g0, *g1;
tot = max(n0, n1);
sender = (Int *) mr2d_malloc((nprocs + tot) * sizeof(Int) * 2);
sender = (Int *) mr2d_malloc((size_t)(nprocs + tot) * sizeof(Int) * 2);
recver = sender + tot;
*psend = sender;
*precv = recver;
Expand Down Expand Up @@ -664,7 +664,7 @@ gridreshape(Int *ctxtp)
Int i, j;
ori = *ctxtp;
Cblacs_gridinfo(ori, &nprow, &npcol, &myrow, &mycol);
usermap = mr2d_malloc(sizeof(Int) * nprow * npcol);
usermap = mr2d_malloc(sizeof(Int) * (size_t)nprow * (size_t)npcol);
for (i = 0; i < nprow; i++)
for (j = 0; j < npcol; j++) {
usermap[i + j * nprow] = Cblacs_pnum(ori, i, j);
Expand Down
2 changes: 1 addition & 1 deletion REDIST/SRC/pctrmr2.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ setmemory(complex **adpointer, Int blocksize)
return;
}
*adpointer = (complex *) mr2d_malloc(
blocksize * sizeof(complex));
(size_t)blocksize * sizeof(complex));
}
/******************************************************************/
/* Free the memory space after the malloc */
Expand Down
14 changes: 7 additions & 7 deletions REDIST/SRC/pdgemr.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ Cpdgemr2d(m, n,
assert((myprow1 < p1 && mypcol1 < q1) || (myprow1 == -1 && mypcol1 == -1));
/* exchange the missing parameters among the processors: shape of grids and
* location of the processors */
param = (Int *) mr2d_malloc(3 * (nprocs * 2 + NBPARAM) * sizeof(Int));
param = (Int *) mr2d_malloc(3 * ((size_t)nprocs * 2 + NBPARAM) * sizeof(Int));
ra = param + nprocs * 2 + NBPARAM;
ca = param + (nprocs * 2 + NBPARAM) * 2;
for (i = 0; i < nprocs * 2 + NBPARAM; i++)
Expand Down Expand Up @@ -464,10 +464,10 @@ Cpdgemr2d(m, n,
/* allocing room for the tabs, alloc for the worst case,local_n or local_m
* intervals, in fact the worst case should be less, perhaps half that,I
* should think of that one day. */
h_inter = (IDESC *) mr2d_malloc(DIVUP(ma->n, q0 * ma->nbcol) *
ma->nbcol * sizeof(IDESC));
v_inter = (IDESC *) mr2d_malloc(DIVUP(ma->m, p0 * ma->nbrow)
* ma->nbrow * sizeof(IDESC));
h_inter = (IDESC *) mr2d_malloc((size_t)(DIVUP(ma->n, q0 * ma->nbcol)) *
(size_t)ma->nbcol * sizeof(IDESC));
v_inter = (IDESC *) mr2d_malloc((size_t)(DIVUP(ma->m, p0 * ma->nbrow))
* (size_t)ma->nbrow * sizeof(IDESC));
/* We go for the scanning of indices. For each processor including mypnum,
* we fill the sendbuff buffer (scanD0(SENDBUFF)) and when it is done send
* it. Then for each processor, we compute the size of message to be
Expand Down Expand Up @@ -569,7 +569,7 @@ init_chenille(mypnum, nprocs, n0, proc0, n1, proc1, psend, precv, myrang)
Int ns, nr, i, tot;
Int *sender, *recver, *g0, *g1;
tot = max(n0, n1);
sender = (Int *) mr2d_malloc((nprocs + tot) * sizeof(Int) * 2);
sender = (Int *) mr2d_malloc((size_t)(nprocs + tot) * sizeof(Int) * 2);
recver = sender + tot;
*psend = sender;
*precv = recver;
Expand Down Expand Up @@ -713,7 +713,7 @@ gridreshape(Int *ctxtp)
Int i, j;
ori = *ctxtp;
Cblacs_gridinfo(ori, &nprow, &npcol, &myrow, &mycol);
usermap = mr2d_malloc(sizeof(Int) * nprow * npcol);
usermap = mr2d_malloc(sizeof(Int) * (size_t)nprow * (size_t)npcol);
for (i = 0; i < nprow; i++)
for (j = 0; j < npcol; j++) {
usermap[i + j * nprow] = Cblacs_pnum(ori, i, j);
Expand Down
2 changes: 1 addition & 1 deletion REDIST/SRC/pdgemr2.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ setmemory(double **adpointer, Int blocksize)
return;
}
*adpointer = (double *) mr2d_malloc(
blocksize * sizeof(double));
(size_t)blocksize * sizeof(double));
}
/******************************************************************/
/* Free the memory space after the malloc */
Expand Down
14 changes: 7 additions & 7 deletions REDIST/SRC/pdtrmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ Cpdtrmr2d(uplo, diag, m, n,
assert((myprow1 < p1 && mypcol1 < q1) || (myprow1 == -1 && mypcol1 == -1));
/* exchange the missing parameters among the processors: shape of grids and
* location of the processors */
param = (Int *) mr2d_malloc(3 * (nprocs * 2 + NBPARAM) * sizeof(Int));
param = (Int *) mr2d_malloc(3 * ((size_t)nprocs * 2 + NBPARAM) * sizeof(Int));
ra = param + nprocs * 2 + NBPARAM;
ca = param + (nprocs * 2 + NBPARAM) * 2;
for (i = 0; i < nprocs * 2 + NBPARAM; i++)
Expand Down Expand Up @@ -481,10 +481,10 @@ Cpdtrmr2d(uplo, diag, m, n,
/* allocing room for the tabs, alloc for the worst case,local_n or local_m
* intervals, in fact the worst case should be less, perhaps half that,I
* should think of that one day. */
h_inter = (IDESC *) mr2d_malloc(DIVUP(ma->n, q0 * ma->nbcol) *
ma->nbcol * sizeof(IDESC));
v_inter = (IDESC *) mr2d_malloc(DIVUP(ma->m, p0 * ma->nbrow)
* ma->nbrow * sizeof(IDESC));
h_inter = (IDESC *) mr2d_malloc((size_t)(DIVUP(ma->n, q0 * ma->nbcol)) *
(size_t)ma->nbcol * sizeof(IDESC));
v_inter = (IDESC *) mr2d_malloc((size_t)(DIVUP(ma->m, p0 * ma->nbrow))
* (size_t)ma->nbrow * sizeof(IDESC));
/* We go for the scanning of indices. For each processor including mypnum,
* we fill the sendbuff buffer (scanD0(SENDBUFF)) and when it is done send
* it. Then for each processor, we compute the size of message to be
Expand Down Expand Up @@ -589,7 +589,7 @@ init_chenille(Int mypnum, Int nprocs, Int n0, Int *proc0, Int n1, Int *proc1, In
Int ns, nr, i, tot;
Int *sender, *recver, *g0, *g1;
tot = max(n0, n1);
sender = (Int *) mr2d_malloc((nprocs + tot) * sizeof(Int) * 2);
sender = (Int *) mr2d_malloc((size_t)(nprocs + tot) * sizeof(Int) * 2);
recver = sender + tot;
*psend = sender;
*precv = recver;
Expand Down Expand Up @@ -661,7 +661,7 @@ gridreshape(Int *ctxtp)
Int i, j;
ori = *ctxtp;
Cblacs_gridinfo(ori, &nprow, &npcol, &myrow, &mycol);
usermap = mr2d_malloc(sizeof(Int) * nprow * npcol);
usermap = mr2d_malloc(sizeof(Int) * (size_t)nprow * (size_t)npcol);
for (i = 0; i < nprow; i++)
for (j = 0; j < npcol; j++) {
usermap[i + j * nprow] = Cblacs_pnum(ori, i, j);
Expand Down
2 changes: 1 addition & 1 deletion REDIST/SRC/pdtrmr2.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ setmemory(double **adpointer, Int blocksize)
return;
}
*adpointer = (double *) mr2d_malloc(
blocksize * sizeof(double));
(size_t)blocksize * sizeof(double));
}
/******************************************************************/
/* Free the memory space after the malloc */
Expand Down
5 changes: 3 additions & 2 deletions REDIST/SRC/pgemraux.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ extern void Cpigemr2d();
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
const size_t NEGFLAG = ~( ((size_t)-1) >> 1);
void *
mr2d_malloc(Int n)
mr2d_malloc(size_t n)
{
void *ptr;
assert(n > 0);
assert((n & NEGFLAG) == 0);
ptr = (void *) malloc(n);
if (ptr == NULL) {
fprintf(stderr, "xxmr2d:out of memory\n");
Expand Down
14 changes: 7 additions & 7 deletions REDIST/SRC/pigemr.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ Cpigemr2d(m, n,
assert((myprow1 < p1 && mypcol1 < q1) || (myprow1 == -1 && mypcol1 == -1));
/* exchange the missing parameters among the processors: shape of grids and
* location of the processors */
param = (Int *) mr2d_malloc(3 * (nprocs * 2 + NBPARAM) * sizeof(Int));
param = (Int *) mr2d_malloc(3 * ((size_t)nprocs * 2 + NBPARAM) * sizeof(Int));
ra = param + nprocs * 2 + NBPARAM;
ca = param + (nprocs * 2 + NBPARAM) * 2;
for (i = 0; i < nprocs * 2 + NBPARAM; i++)
Expand Down Expand Up @@ -464,10 +464,10 @@ Cpigemr2d(m, n,
/* allocing room for the tabs, alloc for the worst case,local_n or local_m
* intervals, in fact the worst case should be less, perhaps half that,I
* should think of that one day. */
h_inter = (IDESC *) mr2d_malloc(DIVUP(ma->n, q0 * ma->nbcol) *
ma->nbcol * sizeof(IDESC));
v_inter = (IDESC *) mr2d_malloc(DIVUP(ma->m, p0 * ma->nbrow)
* ma->nbrow * sizeof(IDESC));
h_inter = (IDESC *) mr2d_malloc((size_t)(DIVUP(ma->n, q0 * ma->nbcol)) *
(size_t)ma->nbcol * sizeof(IDESC));
v_inter = (IDESC *) mr2d_malloc((size_t)(DIVUP(ma->m, p0 * ma->nbrow))
* (size_t)ma->nbrow * sizeof(IDESC));
/* We go for the scanning of indices. For each processor including mypnum,
* we fill the sendbuff buffer (scanD0(SENDBUFF)) and when it is done send
* it. Then for each processor, we compute the size of message to be
Expand Down Expand Up @@ -567,7 +567,7 @@ init_chenille(Int mypnum, Int nprocs, Int n0, Int *proc0, Int n1, Int *proc1, In
Int ns, nr, i, tot;
Int *sender, *recver, *g0, *g1;
tot = max(n0, n1);
sender = (Int *) mr2d_malloc((nprocs + tot) * sizeof(Int) * 2);
sender = (Int *) mr2d_malloc((size_t)(nprocs + tot) * sizeof(Int) * 2);
recver = sender + tot;
*psend = sender;
*precv = recver;
Expand Down Expand Up @@ -703,7 +703,7 @@ gridreshape(Int *ctxtp)
Int i, j;
ori = *ctxtp;
Cblacs_gridinfo(ori, &nprow, &npcol, &myrow, &mycol);
usermap = mr2d_malloc(sizeof(Int) * nprow * npcol);
usermap = mr2d_malloc(sizeof(Int) * (size_t)nprow * (size_t)npcol);
for (i = 0; i < nprow; i++)
for (j = 0; j < npcol; j++) {
usermap[i + j * nprow] = Cblacs_pnum(ori, i, j);
Expand Down
2 changes: 1 addition & 1 deletion REDIST/SRC/pigemr2.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ setmemory(Int **adpointer, Int blocksize)
return;
}
*adpointer = (Int *) mr2d_malloc(
blocksize * sizeof(Int));
(size_t)blocksize * sizeof(Int));
}
/******************************************************************/
/* Free the memory space after the malloc */
Expand Down
14 changes: 7 additions & 7 deletions REDIST/SRC/pitrmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ Cpitrmr2d(uplo, diag, m, n,
assert((myprow1 < p1 && mypcol1 < q1) || (myprow1 == -1 && mypcol1 == -1));
/* exchange the missing parameters among the processors: shape of grids and
* location of the processors */
param = (Int *) mr2d_malloc(3 * (nprocs * 2 + NBPARAM) * sizeof(Int));
param = (Int *) mr2d_malloc(3 * ((size_t)nprocs * 2 + NBPARAM) * sizeof(Int));
ra = param + nprocs * 2 + NBPARAM;
ca = param + (nprocs * 2 + NBPARAM) * 2;
for (i = 0; i < nprocs * 2 + NBPARAM; i++)
Expand Down Expand Up @@ -481,10 +481,10 @@ Cpitrmr2d(uplo, diag, m, n,
/* allocing room for the tabs, alloc for the worst case,local_n or local_m
* intervals, in fact the worst case should be less, perhaps half that,I
* should think of that one day. */
h_inter = (IDESC *) mr2d_malloc(DIVUP(ma->n, q0 * ma->nbcol) *
ma->nbcol * sizeof(IDESC));
v_inter = (IDESC *) mr2d_malloc(DIVUP(ma->m, p0 * ma->nbrow)
* ma->nbrow * sizeof(IDESC));
h_inter = (IDESC *) mr2d_malloc((size_t)(DIVUP(ma->n, q0 * ma->nbcol)) *
(size_t)(ma->nbcol) * sizeof(IDESC));
v_inter = (IDESC *) mr2d_malloc((size_t)(DIVUP(ma->m, p0 * ma->nbrow))
* (size_t)ma->nbrow * sizeof(IDESC));
/* We go for the scanning of indices. For each processor including mypnum,
* we fill the sendbuff buffer (scanD0(SENDBUFF)) and when it is done send
* it. Then for each processor, we compute the size of message to be
Expand Down Expand Up @@ -589,7 +589,7 @@ init_chenille(Int mypnum, Int nprocs, Int n0, Int *proc0, Int n1, Int *proc1, In
Int ns, nr, i, tot;
Int *sender, *recver, *g0, *g1;
tot = max(n0, n1);
sender = (Int *) mr2d_malloc((nprocs + tot) * sizeof(Int) * 2);
sender = (Int *) mr2d_malloc((size_t)(nprocs + tot) * sizeof(Int) * 2);
recver = sender + tot;
*psend = sender;
*precv = recver;
Expand Down Expand Up @@ -661,7 +661,7 @@ gridreshape(Int *ctxtp)
Int i, j;
ori = *ctxtp;
Cblacs_gridinfo(ori, &nprow, &npcol, &myrow, &mycol);
usermap = mr2d_malloc(sizeof(Int) * nprow * npcol);
usermap = mr2d_malloc(sizeof(Int) * (size_t)nprow * (size_t)npcol);
for (i = 0; i < nprow; i++)
for (j = 0; j < npcol; j++) {
usermap[i + j * nprow] = Cblacs_pnum(ori, i, j);
Expand Down
2 changes: 1 addition & 1 deletion REDIST/SRC/pitrmr2.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ setmemory(Int **adpointer, Int blocksize)
return;
}
*adpointer = (Int *) mr2d_malloc(
blocksize * sizeof(Int));
(size_t)blocksize * sizeof(Int));
}
/******************************************************************/
/* Free the memory space after the malloc */
Expand Down
14 changes: 7 additions & 7 deletions REDIST/SRC/psgemr.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ Cpsgemr2d(m, n,
assert((myprow1 < p1 && mypcol1 < q1) || (myprow1 == -1 && mypcol1 == -1));
/* exchange the missing parameters among the processors: shape of grids and
* location of the processors */
param = (Int *) mr2d_malloc(3 * (nprocs * 2 + NBPARAM) * sizeof(Int));
param = (Int *) mr2d_malloc(3 * ((size_t)nprocs * 2 + NBPARAM) * sizeof(Int));
ra = param + nprocs * 2 + NBPARAM;
ca = param + (nprocs * 2 + NBPARAM) * 2;
for (i = 0; i < nprocs * 2 + NBPARAM; i++)
Expand Down Expand Up @@ -464,10 +464,10 @@ Cpsgemr2d(m, n,
/* allocing room for the tabs, alloc for the worst case,local_n or local_m
* intervals, in fact the worst case should be less, perhaps half that,I
* should think of that one day. */
h_inter = (IDESC *) mr2d_malloc(DIVUP(ma->n, q0 * ma->nbcol) *
ma->nbcol * sizeof(IDESC));
v_inter = (IDESC *) mr2d_malloc(DIVUP(ma->m, p0 * ma->nbrow)
* ma->nbrow * sizeof(IDESC));
h_inter = (IDESC *) mr2d_malloc((size_t)(DIVUP(ma->n, q0 * ma->nbcol)) *
(size_t)ma->nbcol * sizeof(IDESC));
v_inter = (IDESC *) mr2d_malloc((size_t)(DIVUP(ma->m, p0 * ma->nbrow))
* (size_t)ma->nbrow * sizeof(IDESC));
/* We go for the scanning of indices. For each processor including mypnum,
* we fill the sendbuff buffer (scanD0(SENDBUFF)) and when it is done send
* it. Then for each processor, we compute the size of message to be
Expand Down Expand Up @@ -567,7 +567,7 @@ init_chenille(Int mypnum, Int nprocs, Int n0, Int *proc0, Int n1, Int *proc1, In
Int ns, nr, i, tot;
Int *sender, *recver, *g0, *g1;
tot = max(n0, n1);
sender = (Int *) mr2d_malloc((nprocs + tot) * sizeof(Int) * 2);
sender = (Int *) mr2d_malloc((size_t)(nprocs + tot) * sizeof(Int) * 2);
recver = sender + tot;
*psend = sender;
*precv = recver;
Expand Down Expand Up @@ -703,7 +703,7 @@ gridreshape(Int *ctxtp)
Int i, j;
ori = *ctxtp;
Cblacs_gridinfo(ori, &nprow, &npcol, &myrow, &mycol);
usermap = mr2d_malloc(sizeof(Int) * nprow * npcol);
usermap = mr2d_malloc(sizeof(Int) * (size_t)nprow * (size_t)npcol);
for (i = 0; i < nprow; i++)
for (j = 0; j < npcol; j++) {
usermap[i + j * nprow] = Cblacs_pnum(ori, i, j);
Expand Down
2 changes: 1 addition & 1 deletion REDIST/SRC/psgemr2.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ setmemory(float **adpointer, Int blocksize)
return;
}
*adpointer = (float *) mr2d_malloc(
blocksize * sizeof(float));
(size_t)blocksize * sizeof(float));
}
/******************************************************************/
/* Free the memory space after the malloc */
Expand Down
Loading

0 comments on commit 25935e1

Please sign in to comment.