static void ringhelper_destroy (ringhelper *self) { if (self->plan) kill_real_plan(self->plan); DEALLOC(self->shiftarr); DEALLOC(self->work); ringhelper_init(self); }
static void sharp_make_mpi_info (MPI_Comm comm, const sharp_job *job, sharp_mpi_info *minfo) { minfo->comm = comm; MPI_Comm_size (comm, &minfo->ntasks); MPI_Comm_rank (comm, &minfo->mytask); minfo->nm=RALLOC(int,minfo->ntasks); MPI_Allgather ((int *)(&job->ainfo->nm),1,MPI_INT,minfo->nm,1,MPI_INT,comm); minfo->ofs_m=RALLOC(int,minfo->ntasks+1); minfo->ofs_m[0]=0; for (int i=1; i<=minfo->ntasks; ++i) minfo->ofs_m[i] = minfo->ofs_m[i-1]+minfo->nm[i-1]; minfo->nmtotal=minfo->ofs_m[minfo->ntasks]; minfo->mval=RALLOC(int,minfo->nmtotal); MPI_Allgatherv(job->ainfo->mval, job->ainfo->nm, MPI_INT, minfo->mval, minfo->nm, minfo->ofs_m, MPI_INT, comm); minfo->mmax=sharp_get_mmax(minfo->mval,minfo->nmtotal); minfo->npair=RALLOC(int,minfo->ntasks); MPI_Allgather ((int *)(&job->ginfo->npairs), 1, MPI_INT, minfo->npair, 1, MPI_INT, comm); minfo->ofs_pair=RALLOC(int,minfo->ntasks+1); minfo->ofs_pair[0]=0; for (int i=1; i<=minfo->ntasks; ++i) minfo->ofs_pair[i] = minfo->ofs_pair[i-1]+minfo->npair[i-1]; minfo->npairtotal=minfo->ofs_pair[minfo->ntasks]; double *theta_tmp=RALLOC(double,job->ginfo->npairs); int *ispair_tmp=RALLOC(int,job->ginfo->npairs); for (int i=0; i<job->ginfo->npairs; ++i) { theta_tmp[i]=job->ginfo->pair[i].r1.theta; ispair_tmp[i]=job->ginfo->pair[i].r2.nph>0; } minfo->theta=RALLOC(double,minfo->npairtotal); minfo->ispair=RALLOC(int,minfo->npairtotal); MPI_Allgatherv(theta_tmp, job->ginfo->npairs, MPI_DOUBLE, minfo->theta, minfo->npair, minfo->ofs_pair, MPI_DOUBLE, comm); MPI_Allgatherv(ispair_tmp, job->ginfo->npairs, MPI_INT, minfo->ispair, minfo->npair, minfo->ofs_pair, MPI_INT, comm); DEALLOC(theta_tmp); DEALLOC(ispair_tmp); minfo->nph=2*job->nmaps*job->ntrans; minfo->almcount=RALLOC(int,minfo->ntasks); minfo->almdisp=RALLOC(int,minfo->ntasks+1); minfo->mapcount=RALLOC(int,minfo->ntasks); minfo->mapdisp=RALLOC(int,minfo->ntasks+1); minfo->almdisp[0]=minfo->mapdisp[0]=0; for (int i=0; i<minfo->ntasks; ++i) { minfo->almcount[i] = 2*minfo->nph*minfo->nm[minfo->mytask]*minfo->npair[i]; minfo->almdisp[i+1] = minfo->almdisp[i]+minfo->almcount[i]; minfo->mapcount[i] = 2*minfo->nph*minfo->nm[i]*minfo->npair[minfo->mytask]; minfo->mapdisp[i+1] = minfo->mapdisp[i]+minfo->mapcount[i]; } }
//**************************************************************************** void RemoveFromSuspendedListByID(long processID) { if( ((PCB*)gSuspendedList->head->data)->processID == processID ) { ListNode* temp = gSuspendedList->head; gSuspendedList->head = gSuspendedList->head->next; DEALLOC(temp); gSuspendedList->count--; return; } ListNode* prevNode = gSuspendedList->head; ListNode* currentNode = prevNode->next; while( currentNode ) { if( ((PCB*)currentNode->data)->processID == processID ) { prevNode->next = currentNode->next; DEALLOC(currentNode); gSuspendedList->count--; break; } prevNode = currentNode; currentNode = currentNode->next; } return; }
PUBLIC void strdtor (void) { StringPrivate * priv = OBJECT_GET_PRIVATE (String, actual_string); if (priv->ptr != NULL) { DEALLOC (priv->ptr); } DEALLOC (priv); DEALLOC (actual_string); }
void play(char *buf){ char *key; video *toplay; if (streq(buf,"trolololo A")) { ALLOC(0, (void**)&toplay, sizeof(video)); toplay->key = 'A'; toplay->encbuf = r_bin; toplay->elen = r_bin_len-4; toplay->csum = *(uint32_t*)(r_bin+r_bin_len-4); decode(toplay,'A'); if(toplay->decbuf){ SSENDL(toplay->dlen,(char *)toplay->decbuf); SSENDL(sizeof(FINISHED)-1,FINISHED); DEALLOC((void*)toplay->decbuf, toplay->dlen); }else{ SSENDL(sizeof(NOSUCHVID)-1,NOSUCHVID); } DEALLOC((void*)toplay, sizeof(video)); return; } key = strchr(buf,' '); if(!key) { SSENDL(sizeof(NOSUCHVID)-1,NOSUCHVID); return; } *key = '\0'; if(!*(key+1) || *(key+2)){ SSENDL(sizeof(NOSUCHVID)-1,NOSUCHVID); return; } key += 1; toplay = get_video_by_name(buf); if(!toplay) { SSENDL(sizeof(NOSUCHVID)-1,NOSUCHVID); return; } decode(toplay,*key); if(toplay->decbuf){ SSENDL(toplay->dlen,(char *)toplay->decbuf); SSENDL(sizeof(FINISHED)-1,FINISHED); }else{ SSENDL(sizeof(NOSUCHVID)-1,NOSUCHVID); } }
void psht_make_healpix_geom_info (int nside, int stride, psht_geom_info **geom_info) { double *weight=RALLOC(double,2*nside); SET_ARRAY(weight,0,2*nside,1); psht_make_weighted_healpix_geom_info (nside, stride, weight, geom_info); DEALLOC(weight); }
vd ring_uninit(vpp ring_pptr) { ring_p ring; if (IS_NNL(ring_pptr) && IS_NNL(ring = (ring_p)(*ring_pptr))) { DEALLOC(ring); } }
//**************************************************************************** void TerminateAllProcess() { int i; ListNode* currentProcessNode = gGlobalProcessList->head; for( i = 0; i < gGlobalProcessList->count; ++i ) { PCB* pcb = (PCB*)currentProcessNode->data; RemoveFromTimerQueueByID(pcb->processID); RemoveFromReadyQueueByID(pcb->processID); DEALLOC(pcb->messages); DEALLOC(pcb); currentProcessNode = currentProcessNode->next; } ListRelease(gGlobalProcessList); }
void radix_end(struct ROOTSTRUCT * tree, int (*cb)(LEAFTYPE)) { if (! tree->leafcount == 0) { if (tree->leafcount == 1) { cb(tree->root.leaf); } else { _dfs(tree->root.node, cb, _dealloc_internal_node, 0, 1); } } DEALLOC(tree); }
PUBLIC void strSetContent (char * content) { StringPrivate * priv = OBJECT_GET_PRIVATE (String, actual_string); //OBJECT_GET_PRIVATE (String, actual_string); priv->len = strlen (content); priv->ptr = ALLOC (priv->len, char); priv->ptr = strdup(content); DEALLOC (content); }
void psht_make_gauss_geom_info_2 (int nrings, int nphi, int stride_lon, int stride_lat, psht_geom_info **geom_info) { const double pi=3.141592653589793238462643383279502884197; double *theta=RALLOC(double,nrings); double *weight=RALLOC(double,nrings); int *nph=RALLOC(int,nrings); double *phi0=RALLOC(double,nrings); ptrdiff_t *ofs=RALLOC(ptrdiff_t,nrings); int *stride_=RALLOC(int,nrings); int m; gauleg(-1,1,theta,weight,nrings); for (m=0; m<nrings; ++m) { theta[m] = acos(theta[m]); nph[m]=nphi; phi0[m]=0; ofs[m]=(ptrdiff_t)m*stride_lat; stride_[m]=stride_lon; weight[m]*=2*pi/nphi; } psht_make_geom_info (nrings, nph, ofs, stride_, phi0, theta, weight, geom_info); DEALLOC(theta); DEALLOC(weight); DEALLOC(nph); DEALLOC(phi0); DEALLOC(ofs); DEALLOC(stride_); }
static void sharp_communicate_alm2map (const sharp_mpi_info *minfo, dcmplx **ph) { dcmplx *phas_tmp = RALLOC(dcmplx,minfo->mapdisp[minfo->ntasks]/2); MPI_Alltoallv (*ph,minfo->almcount,minfo->almdisp,MPI_DOUBLE,phas_tmp, minfo->mapcount,minfo->mapdisp,MPI_DOUBLE,minfo->comm); DEALLOC(*ph); ALLOC(*ph,dcmplx,minfo->nph*minfo->npair[minfo->mytask]*minfo->nmtotal); for (int task=0; task<minfo->ntasks; ++task) for (int th=0; th<minfo->npair[minfo->mytask]; ++th) for (int mi=0; mi<minfo->nm[task]; ++mi) { int m = minfo->mval[mi+minfo->ofs_m[task]]; int o1 = minfo->nph*(th*(minfo->mmax+1) + m); int o2 = minfo->mapdisp[task]/2+minfo->nph*(mi+th*minfo->nm[task]); for (int i=0; i<minfo->nph; ++i) (*ph)[o1+i] = phas_tmp[o2+i]; } DEALLOC(phas_tmp); }
PUBLIC void StrmDtor (void) { StreamPrivate * priv = OBJECT_GET_PRIVATE (Stream, actual_stream); scanner (priv->s)->dtor (); out (priv->o)->dtor (); if (priv->fp != NULL && priv->fp != stdout && priv->fp != stdin && priv->fp != stderr) { fflush (priv->fp); fclose (priv->fp); } DEALLOC (priv); DEALLOC (actual_stream); actual_stream = NULL; priv = NULL; }
//**************************************************************************** Message* RemoveMessageBySenderID(PCB* pcb, long processID) { Message* res = NULL; List* messages = pcb->messages; if( messages->count == 0 ) { return res; } if( ((Message*)messages->head->data)->senderProcessID == processID ) { res = (Message*)messages->head->data; ListNode* temp = messages->head; messages->head = messages->head->next; DEALLOC(temp); messages->count--; return res; } ListNode* prev = messages->head; ListNode* current = prev->next; while( current ) { if( ((Message*)current->data)->senderProcessID == processID ) { prev->next = current->next; res = (Message*)current->data; DEALLOC(current); messages->count--; break; } prev = current; current = current->next; } return res; }
//**************************************************************************** void ResetReadyQueueKeys() { int i; MinPriQueue* temp = (MinPriQueue*)ALLOC(MinPriQueue); MinPriQueueInit(temp, MAX_PROCESS_NUM); for( i = 0; i < gReadyQueue->heap.size; ++i ) { PCB* pcb = GetReadyQueueProcess(i); pcb->readyQueueKey = pcb->priority; MinPriQueuePush(temp, pcb->readyQueueKey, (void*)pcb); } DEALLOC(gReadyQueue); gReadyQueue = temp; }
void psht_make_geom_info (int nrings, const int *nph, const ptrdiff_t *ofs, const int *stride, const double *phi0, const double *theta, const double *weight, psht_geom_info **geom_info) { psht_geom_info *info = RALLOC(psht_geom_info,1); psht_ringinfo *infos = RALLOC(psht_ringinfo,nrings); int pos=0; int m; info->pair=RALLOC(psht_ringpair,nrings); info->npairs=0; *geom_info = info; for (m=0; m<nrings; ++m) { infos[m].theta = theta[m]; infos[m].cth = cos(theta[m]); infos[m].sth = sin(theta[m]); infos[m].weight = weight[m]; infos[m].phi0 = phi0[m]; infos[m].ofs = ofs[m]; infos[m].stride = stride[m]; infos[m].nph = nph[m]; } qsort(infos,nrings,sizeof(psht_ringinfo),ringinfo_compare); while (pos<nrings) { if ((pos<nrings-1) && FAPPROX(infos[pos].cth,-infos[pos+1].cth,1e-12)) { info->pair[info->npairs].r1=infos[pos]; info->pair[info->npairs].r2=infos[pos+1]; pos+=2; ++info->npairs; } else { info->pair[info->npairs].r1=infos[pos]; info->pair[info->npairs].r2.nph=-1; ++pos; ++info->npairs; } } DEALLOC(infos); qsort(info->pair,info->npairs,sizeof(psht_ringpair),ringpair_compare); }
void real_plan_forward_fftpack (real_plan plan, double *data) { if (plan->bluestein) { size_t m; size_t n=plan->length; double *tmp = RALLOC(double,2*n); for (m=0; m<n; ++m) { tmp[2*m] = data[m]; tmp[2*m+1] = 0.; } bluestein(n,tmp,plan->work,-1); data[0] = tmp[0]; memcpy (data+1, tmp+2, (n-1)*sizeof(double)); DEALLOC(tmp); }
LEAFTYPE radix_del(struct ROOTSTRUCT * tree, LEAFTYPE leaf, EXTRA_ARG aux) { LEAFTYPE result; struct _internal_node * node, * parent; uint32_t dir, dir2; if (tree->leafcount == 0) return NO_LEAF; if (tree->leafcount == 1) { result = tree->root.leaf; if (COMPARE(result, leaf) == -1) { tree->root.leaf = NO_LEAF; tree->leafcount --; return result; } else return NO_LEAF; } /* else */ node = tree->root.node; while (1) { dir = DECIDE(leaf, node->critbit, aux); if (IS_LEAF(node, dir)) { result = node->child[dir].leaf; break; } else { node = node->child[dir].node; } } if (COMPARE(result, leaf) == -1) { parent = tree->root.node; while (1) { dir2 = DECIDE(leaf, parent->critbit, aux); if (parent->child[dir2].node == node) break; else parent = parent->child[dir2].node; } if (IS_LEAF(node, 1 - dir)) { parent->child[dir2].leaf = node->child[1 - dir].leaf; SET_LEAF(parent, dir2); } else { parent->child[dir2].node = node->child[1 - dir].node; } tree->leafcount --; DEALLOC(node); return result; } else return NO_LEAF; }
void psht_make_ecp_geom_info_2 (int nrings, int nphi, double phi0, int stride_lon, int stride_lat, psht_geom_info **geom_info) { const double pi=3.141592653589793238462643383279502884197; double *theta=RALLOC(double,nrings); double *weight=RALLOC(double,nrings); int *nph=RALLOC(int,nrings); double *phi0_=RALLOC(double,nrings); ptrdiff_t *ofs=RALLOC(ptrdiff_t,nrings); int *stride_=RALLOC(int,nrings); int m; UTIL_ASSERT((nrings&1)==0, "Even number of rings needed for equidistant grid!"); makeweights(nrings/2,weight); for (m=0; m<nrings; ++m) { theta[m] = (m+0.5)*pi/nrings; nph[m]=nphi; phi0_[m]=phi0; ofs[m]=(ptrdiff_t)m*stride_lat; stride_[m]=stride_lon; weight[m]*=2*pi/nphi; } psht_make_geom_info (nrings, nph, ofs, stride_, phi0_, theta, weight, geom_info); DEALLOC(theta); DEALLOC(weight); DEALLOC(nph); DEALLOC(phi0_); DEALLOC(ofs); DEALLOC(stride_); }
//**************************************************************************** void SchedulerTerminate() { DEALLOC(gScheduler); }
int ELFNAMEEND(loadfile)(int fd, Elf_Ehdr *elf, u_long *marks, int flags) { Elf_Shdr *shp; Elf_Phdr *phdr; int i, j; ssize_t sz; int first; Elf_Addr shpp; Elf_Addr minp = ~0, maxp = 0, pos = 0, elfp = 0; u_long offset = marks[MARK_START]; ssize_t nr; struct __packed { Elf_Nhdr nh; uint8_t name[ELF_NOTE_NETBSD_NAMESZ + 1]; uint8_t desc[ELF_NOTE_NETBSD_DESCSZ]; } note; char *shstr = NULL; int boot_load_ctf = 1; /* some ports dont use the offset */ (void)&offset; internalize_ehdr(elf->e_ident[EI_DATA], elf); sz = elf->e_phnum * sizeof(Elf_Phdr); phdr = ALLOC(sz); if (lseek(fd, elf->e_phoff, SEEK_SET) == -1) { WARN(("lseek phdr")); goto freephdr; } nr = read(fd, phdr, sz); if (nr == -1) { WARN(("read program headers")); goto freephdr; } if (nr != sz) { errno = EIO; WARN(("read program headers")); goto freephdr; } for (first = 1, i = 0; i < elf->e_phnum; i++) { internalize_phdr(elf->e_ident[EI_DATA], &phdr[i]); #ifndef MD_LOADSEG /* Allow processor ABI specific segment loads */ #define MD_LOADSEG(a) /*CONSTCOND*/0 #endif if (MD_LOADSEG(&phdr[i])) goto loadseg; if (phdr[i].p_type != PT_LOAD || (phdr[i].p_flags & (PF_W|PF_X)) == 0) continue; #define IS_TEXT(p) (p.p_flags & PF_X) #define IS_DATA(p) (p.p_flags & PF_W) #define IS_BSS(p) (p.p_filesz < p.p_memsz) /* * XXX: Assume first address is lowest */ if ((IS_TEXT(phdr[i]) && (flags & LOAD_TEXT)) || (IS_DATA(phdr[i]) && (flags & LOAD_DATA))) { loadseg: if (marks[MARK_DATA] == 0 && IS_DATA(phdr[i])) marks[MARK_DATA] = LOADADDR(phdr[i].p_vaddr); /* Read in segment. */ PROGRESS(("%s%lu", first ? "" : "+", (u_long)phdr[i].p_filesz)); if (lseek(fd, phdr[i].p_offset, SEEK_SET) == -1) { WARN(("lseek text")); goto freephdr; } nr = READ(fd, phdr[i].p_vaddr, phdr[i].p_filesz); if (nr == -1) { WARN(("read text error")); goto freephdr; } if (nr != (ssize_t)phdr[i].p_filesz) { errno = EIO; WARN(("read text")); goto freephdr; } first = 0; } if ((IS_TEXT(phdr[i]) && (flags & (LOAD_TEXT|COUNT_TEXT))) || (IS_DATA(phdr[i]) && (flags & (LOAD_DATA|COUNT_TEXT)))) { pos = phdr[i].p_vaddr; if (minp > pos) minp = pos; pos += phdr[i].p_filesz; if (maxp < pos) maxp = pos; } /* Zero out bss. */ if (IS_BSS(phdr[i]) && (flags & LOAD_BSS)) { PROGRESS(("+%lu", (u_long)(phdr[i].p_memsz - phdr[i].p_filesz))); BZERO((phdr[i].p_vaddr + phdr[i].p_filesz), phdr[i].p_memsz - phdr[i].p_filesz); } if (IS_BSS(phdr[i]) && (flags & (LOAD_BSS|COUNT_BSS))) { pos += phdr[i].p_memsz - phdr[i].p_filesz; if (maxp < pos) maxp = pos; } } DEALLOC(phdr, sz); /* * Copy the ELF and section headers. */ maxp = roundup(maxp, ELFROUND); if (flags & (LOAD_HDR|COUNT_HDR)) { elfp = maxp; maxp += sizeof(Elf_Ehdr); } if (flags & (LOAD_SYM|COUNT_SYM)) { if (lseek(fd, elf->e_shoff, SEEK_SET) == -1) { WARN(("lseek section headers")); return 1; } sz = elf->e_shnum * sizeof(Elf_Shdr); shp = ALLOC(sz); nr = read(fd, shp, sz); if (nr == -1) { WARN(("read section headers")); goto freeshp; } if (nr != sz) { errno = EIO; WARN(("read section headers")); goto freeshp; } shpp = maxp; maxp += roundup(sz, ELFROUND); #ifndef _STANDALONE /* Internalize the section headers. */ for (i = 0; i < elf->e_shnum; i++) internalize_shdr(elf->e_ident[EI_DATA], &shp[i]); #endif /* ! _STANDALONE */ /* * First load the section names section. */ if (boot_load_ctf && (elf->e_shstrndx != 0)) { if (flags & LOAD_SYM) { if (lseek(fd, shp[elf->e_shstrndx].sh_offset, SEEK_SET) == -1) { WARN(("lseek symbols")); goto freeshp; } nr = READ(fd, maxp, shp[elf->e_shstrndx].sh_size); if (nr == -1) { WARN(("read symbols")); goto freeshp; } if (nr != (ssize_t)shp[elf->e_shstrndx].sh_size) { errno = EIO; WARN(("read symbols")); goto freeshp; } shstr = ALLOC(shp[elf->e_shstrndx].sh_size); if (lseek(fd, shp[elf->e_shstrndx].sh_offset, SEEK_SET) == -1) { WARN(("lseek symbols")); goto freeshp; } nr = read(fd, shstr, shp[elf->e_shstrndx].sh_size); if (nr == -1) { WARN(("read symbols")); goto freeshp; } } shp[elf->e_shstrndx].sh_offset = maxp - elfp; maxp += roundup(shp[elf->e_shstrndx].sh_size, ELFROUND); } /* * Now load the symbol sections themselves. Make sure * the sections are aligned. Don't bother with any * string table that isn't referenced by a symbol * table. */ for (first = 1, i = 0; i < elf->e_shnum; i++) { if (i == elf->e_shstrndx) { /* already loaded this section */ continue; } switch (shp[i].sh_type) { case SHT_PROGBITS: if (boot_load_ctf && shstr) { /* got a CTF section? */ if (strncmp(".SUNW_ctf", &shstr[shp[i].sh_name], 10) == 0) { goto havesym; } } /* Not loading this, so zero out the offset. */ shp[i].sh_offset = 0; break; case SHT_STRTAB: for (j = 0; j < elf->e_shnum; j++) if (shp[j].sh_type == SHT_SYMTAB && shp[j].sh_link == (unsigned int)i) goto havesym; /* FALLTHROUGH */ default: /* Not loading this, so zero out the offset. */ shp[i].sh_offset = 0; break; havesym: case SHT_SYMTAB: if (flags & LOAD_SYM) { PROGRESS(("%s%ld", first ? " [" : "+", (u_long)shp[i].sh_size)); if (lseek(fd, shp[i].sh_offset, SEEK_SET) == -1) { WARN(("lseek symbols")); goto freeshp; } nr = READ(fd, maxp, shp[i].sh_size); if (nr == -1) { WARN(("read symbols")); goto freeshp; } if (nr != (ssize_t)shp[i].sh_size) { errno = EIO; WARN(("read symbols")); goto freeshp; } } shp[i].sh_offset = maxp - elfp; maxp += roundup(shp[i].sh_size, ELFROUND); first = 0; break; case SHT_NOTE: if ((flags & LOAD_NOTE) == 0) break; if (shp[i].sh_size < sizeof(note)) { shp[i].sh_offset = 0; break; } if (lseek(fd, shp[i].sh_offset, SEEK_SET) == -1) { WARN(("lseek note")); goto freeshp; } nr = read(fd, ¬e, sizeof(note)); if (nr == -1) { WARN(("read note")); goto freeshp; } if (note.nh.n_namesz == ELF_NOTE_NETBSD_NAMESZ && note.nh.n_descsz == ELF_NOTE_NETBSD_DESCSZ && note.nh.n_type == ELF_NOTE_TYPE_NETBSD_TAG && memcmp(note.name, ELF_NOTE_NETBSD_NAME, sizeof(note.name)) == 0) { memcpy(&netbsd_version, ¬e.desc, sizeof(netbsd_version)); } shp[i].sh_offset = 0; break; } } if (flags & LOAD_SYM) { #ifndef _STANDALONE /* Externalize the section headers. */ for (i = 0; i < elf->e_shnum; i++) externalize_shdr(elf->e_ident[EI_DATA], &shp[i]); #endif /* ! _STANDALONE */ BCOPY(shp, shpp, sz); if (first == 0) PROGRESS(("]")); } DEALLOC(shp, sz); } if (shstr) { DEALLOC(shstr, shp[elf->e_shstrndx].sh_size); } /* * Frob the copied ELF header to give information relative * to elfp. */ if (flags & LOAD_HDR) { elf->e_phoff = 0; elf->e_shoff = sizeof(Elf_Ehdr); elf->e_phentsize = 0; elf->e_phnum = 0; externalize_ehdr(elf->e_ident[EI_DATA], elf); BCOPY(elf, elfp, sizeof(*elf)); internalize_ehdr(elf->e_ident[EI_DATA], elf); } marks[MARK_START] = LOADADDR(minp); marks[MARK_ENTRY] = LOADADDR(elf->e_entry); /* * Since there can be more than one symbol section in the code * and we need to find strtab too in order to do anything * useful with the symbols, we just pass the whole elf * header back and we let the kernel debugger find the * location and number of symbols by itself. */ marks[MARK_NSYM] = 1; /* XXX: Kernel needs >= 0 */ marks[MARK_SYM] = LOADADDR(elfp); marks[MARK_END] = LOADADDR(maxp); return 0; freephdr: DEALLOC(phdr, sz); return 1; freeshp: DEALLOC(shp, sz); return 1; }
static void sharp_execute_job_mpi (sharp_job *job, MPI_Comm comm) { int ntasks; MPI_Comm_size(comm, &ntasks); if (ntasks==1) /* fall back to scalar implementation */ { sharp_execute_job (job); return; } MPI_Barrier(comm); double timer=wallTime(); job->opcnt=0; sharp_mpi_info minfo; sharp_make_mpi_info(comm, job, &minfo); if (minfo.npairtotal>minfo.ntasks*300) { int nsub=(minfo.npairtotal+minfo.ntasks*200-1)/(minfo.ntasks*200); for (int isub=0; isub<nsub; ++isub) { sharp_job ljob=*job; // When creating a_lm, every sub-job produces a complete set of // coefficients; they need to be added up. if ((isub>0)&&(job->type==SHARP_MAP2ALM)) ljob.flags|=SHARP_ADD; sharp_geom_info lginfo; lginfo.pair=RALLOC(sharp_ringpair,(job->ginfo->npairs/nsub)+1); lginfo.npairs=0; lginfo.nphmax = job->ginfo->nphmax; while (lginfo.npairs*nsub+isub<job->ginfo->npairs) { lginfo.pair[lginfo.npairs]=job->ginfo->pair[lginfo.npairs*nsub+isub]; ++lginfo.npairs; } ljob.ginfo=&lginfo; sharp_execute_job_mpi (&ljob,comm); job->opcnt+=ljob.opcnt; DEALLOC(lginfo.pair); } } else { int lmax = job->ainfo->lmax; job->norm_l = sharp_Ylmgen_get_norm (lmax, job->spin); /* clear output arrays if requested */ init_output (job); alloc_phase_mpi (job,job->ainfo->nm,job->ginfo->npairs,minfo.mmax+1, minfo.npairtotal); double *cth = RALLOC(double,minfo.npairtotal), *sth = RALLOC(double,minfo.npairtotal); int *mlim = RALLOC(int,minfo.npairtotal); for (int i=0; i<minfo.npairtotal; ++i) { cth[i] = cos(minfo.theta[i]); sth[i] = sin(minfo.theta[i]); mlim[i] = sharp_get_mlim(lmax, job->spin, sth[i], cth[i]); } /* map->phase where necessary */ map2phase (job, minfo.mmax, 0, job->ginfo->npairs); map2alm_comm (job, &minfo); #pragma omp parallel if ((job->flags&SHARP_NO_OPENMP)==0) { sharp_job ljob = *job; sharp_Ylmgen_C generator; sharp_Ylmgen_init (&generator,lmax,minfo.mmax,ljob.spin); alloc_almtmp(&ljob,lmax); #pragma omp for schedule(dynamic,1) for (int mi=0; mi<job->ainfo->nm; ++mi) { /* alm->alm_tmp where necessary */ alm2almtmp (&ljob, lmax, mi); /* inner conversion loop */ inner_loop (&ljob, minfo.ispair, cth, sth, 0, minfo.npairtotal, &generator, mi, mlim); /* alm_tmp->alm where necessary */ almtmp2alm (&ljob, lmax, mi); } sharp_Ylmgen_destroy(&generator); dealloc_almtmp(&ljob); #pragma omp critical job->opcnt+=ljob.opcnt; } /* end of parallel region */ alm2map_comm (job, &minfo); /* phase->map where necessary */ phase2map (job, minfo.mmax, 0, job->ginfo->npairs); DEALLOC(mlim); DEALLOC(cth); DEALLOC(sth); DEALLOC(job->norm_l); dealloc_phase (job); } sharp_destroy_mpi_info(&minfo); job->time=wallTime()-timer; }
void kill_real_plan (real_plan plan) { DEALLOC(plan->work); DEALLOC(plan); }
static void sharp_destroy_mpi_info (sharp_mpi_info *minfo) { DEALLOC(minfo->nm); DEALLOC(minfo->ofs_m); DEALLOC(minfo->mval); DEALLOC(minfo->npair); DEALLOC(minfo->ofs_pair); DEALLOC(minfo->theta); DEALLOC(minfo->ispair); DEALLOC(minfo->almcount); DEALLOC(minfo->almdisp); DEALLOC(minfo->mapcount); DEALLOC(minfo->mapdisp); }
static uint32_t _dealloc_internal_node(struct _internal_node * node) { DEALLOC(node); return 1; }
void psht_make_weighted_healpix_geom_info (int nside, int stride, const double *weight, psht_geom_info **geom_info) { const double pi=3.141592653589793238462643383279502884197; ptrdiff_t npix=(ptrdiff_t)nside*nside*12; ptrdiff_t ncap=2*(ptrdiff_t)nside*(nside-1); int nrings=4*nside-1; double *theta=RALLOC(double,nrings); double *weight_=RALLOC(double,nrings); int *nph=RALLOC(int,nrings); double *phi0=RALLOC(double,nrings); ptrdiff_t *ofs=RALLOC(ptrdiff_t,nrings); int *stride_=RALLOC(int,nrings); int m; for (m=0; m<nrings; ++m) { int ring=m+1; ptrdiff_t northring = (ring>2*nside) ? 4*nside-ring : ring; stride_[m] = stride; if (northring < nside) { theta[m] = 2*asin(northring/(sqrt(6.)*nside)); nph[m] = 4*northring; phi0[m] = pi/nph[m]; ofs[m] = 2*northring*(northring-1)*stride; } else { double fact1 = (8.*nside)/npix; double costheta = (2*nside-northring)*fact1; theta[m] = acos(costheta); nph[m] = 4*nside; if ((northring-nside) & 1) phi0[m] = 0; else phi0[m] = pi/nph[m]; ofs[m] = (ncap + (northring-nside)*nph[m])*stride; } if (northring != ring) /* southern hemisphere */ { theta[m] = pi-theta[m]; ofs[m] = (npix - nph[m])*stride - ofs[m]; } weight_[m]=4.*pi/npix*weight[northring-1]; } #if 0 { double *w2=RALLOC(double,nrings); make_healpix_weights(nside,w2); for (m=0; m<nrings; ++m) weight_[m]*=w2[m]; DEALLOC(w2); } #endif psht_make_geom_info (nrings, nph, ofs, stride_, phi0, theta, weight_, geom_info); DEALLOC(theta); DEALLOC(weight_); DEALLOC(nph); DEALLOC(phi0); DEALLOC(ofs); DEALLOC(stride_); }
void operator delete( void * ptr ) { LOGV( "dealloc pointer: %p\n", ptr ); DEALLOC( ptr ); }
static void make_healpix_weights (int nside, double *weight) { int lmax = (int)(3.5*nside); double dth1 = 1./(3*nside*nside); double dth2 = 2./(3*nside); int nring = 2*nside; int npix = 12*nside*nside; double **mat, *z=RALLOC(double,nring); int *nir=RALLOC(int,nring); double *b=RALLOC(double,nring); svd_obj svd; int ith, l; ALLOC2D(mat,double,lmax/2+1,nring); for (ith=0; ith<nring; ++ith) { if (ith<nside-1) { nir[ith] = 8*(ith+1); z[ith] = 1 - dth1*(ith+1)*(ith+1); } else { nir[ith]=8*nside; z[ith] = (2*nside-ith-1)*dth2; } } nir[nring-1]/=2; for (l=0; l<=lmax/2; ++l) for (ith=0; ith<nring; ++ith) mat[l][ith]=0; for (ith=0; ith<nring; ++ith) { double p0 = 1; double p1 = z[ith]; mat[0][ith] = p0; for (l=2; l<=lmax; ++l) { double p2 = z[ith]*p1*(2*l-1) - p0*(l-1); p2/=l; if ((l%2)==0) mat[l/2][ith] = p2; p0 = p1; p1 = p2; } } for (l=0; l<=lmax/2; ++l) { double bb=0; for (ith=0; ith<nring; ++ith) bb+=mat[l][ith]*nir[ith]; b[l] = -bb; } b[0] += npix; svd_init(mat,1e-14,lmax/2+1,nring,&svd); svd_solve(&svd,b); svd_destroy(&svd); for (l=0;l<nring;++l) weight[l]=weight[2*nring-l-2] = 1.+b[l]/nir[l]; DEALLOC2D(mat); DEALLOC(b); DEALLOC(z); DEALLOC(nir); }
void kill_complex_plan (complex_plan plan) { DEALLOC(plan->work); DEALLOC(plan); }
PUBLIC void odtor (void) { OutPrivate * priv = OBJECT_GET_PRIVATE (Out, actual_out); DEALLOC (priv); DEALLOC (actual_out); }