コード例 #1
0
ファイル: cache_trace.c プロジェクト: tereshinvs/Prac
int main(int argc, char *argv[]) {
//****************************************************
// Хочется получить трассу запросов для:
	int *a, *b; // a == 1000, b == 2000

	for (int i = 0; i < 10000; i++) {
		a[i] = a[i] + b[i];
		print_read((void *)(1000 + i * sizeof(int)));
		print_read((void *)(2000 + i * sizeof(int)));
		print_write((void *)(1000 + i * sizeof(int)));
	}

	return 0;
}
コード例 #2
0
ファイル: print_clusters.c プロジェクト: vibansal/HapCUT2
int print_clusters(struct alignedread** readlist, int s, int e, FRAGMENT* flist, VARIANT* varlist) {
    // function called after clusters have been generated using init_clusters function
    int cluster_start = 0, cluster_end = 0, reads = 0, blocksize = 0, i = 0, j = 0, prevpos = -1;
    double mean = 0, std = 0, value = 0, obs = 0;

    cluster_start = s;
    for (i = s; i < e - 1; i++) {
        if (readlist[i]->IS < 0 || ((readlist[i]->flag & 1024) == 1024)) continue;
        j = i + 1;
        while (readlist[j]->IS < 0 || (((readlist[j]->flag & 1024) == 1024) && j < e)) j++;
        if (j < e && readlist[i]->cluster == readlist[j]->cluster) {
            cluster_end = j;
            print_read(readlist, i, prevpos, flist, varlist);
            if (readlist[j]->mquality > 0) {
                value = (readlist[j]->position - readlist[i]->position);
                mean += value;
                std += value*value;
                reads++;
                obs++;
            }
            prevpos = readlist[i]->position;
        } else if (j < e && readlist[i]->cluster != readlist[j]->cluster) {
            // print cluster information
            print_read(readlist, i, prevpos, flist, varlist);
            blocksize = readlist[cluster_end]->position - readlist[cluster_start]->position;
            fprintf(stdout, "cluster chr%s:%d-%d length %d reads %d ", readlist[cluster_start]->chrom, readlist[cluster_start]->position, readlist[cluster_end]->position, blocksize, reads);
            if (reads >= 5) {
                mean /= obs;
                std /= obs;
                std -= mean*mean;
                if (std > 0) std = sqrt(std);
                fprintf(stdout, "mean %0.2f %0.2f std %0.2f ", mean, mean * (obs), std);
            }
            if (reads >= 5) fprintf(stdout, "good \n\n");
            else if (reads == 0) fprintf(stdout, "repeat \n\n");
            else if (reads == 1) fprintf(stdout, "singleton \n\n");
            else fprintf(stdout, "weak \n\n");
            if (readlist[j]->mquality > 0) reads = 1;
            else reads = 0;
            cluster_start = j;
            cluster_end = j;
            prevpos = readlist[i]->position;
            mean = 0;
            std = 0;
            obs = 0;
        }
    }
    return 1;
}
コード例 #3
0
ファイル: print_clusters.c プロジェクト: vibansal/HapCUT2
void print_reads_window(struct alignedread** readlist, int s, int e, FRAGMENT* flist, VARIANT* varlist, int if_variant_read) {
    int i = 0, prevpos = -1;
    FRAGMENT fragment;
    fragment.variants = 0;
    fragment.alist = (allele*) malloc(sizeof (allele)*1024);
    fprintf(stdout, "cluster chr%s:%d-%d length %d reads %d\n", readlist[s]->chrom, readlist[s]->position, readlist[e - 1]->position, readlist[e - 1]->position - readlist[s]->position, e - s);
    for (i = s; i < e; i++) {
        if (readlist[i]->IS < 0 || ((readlist[i]->flag & 1024) == 1024)) continue;
        if (readlist[i]->IS > 1000) {
            fprintf(stdout, "P-DEL ");
            print_read(readlist, i, prevpos, flist, varlist);
        } else if (readlist[i]->position - prevpos > 1000 && prevpos > 0) print_read(readlist, i, prevpos, flist, varlist);
        //else if (if_variant_read ==0) print_read(readlist,i,prevpos,flist,varlist);
        //else if (readlist[i]->findex >= 0 || (readlist[i]->mateindex > 0 && readlist[readlist[i]->mateindex].findex >=0)) print_read(readlist,i,prevpos,flist,varlist);
        prevpos = readlist[i]->position;
    }
    free(fragment.alist);
}
コード例 #4
0
ファイル: dvd.c プロジェクト: emukidid/swiss-gc
void dvd_read_patched_section() {
	// Check if this read offset+size lies in our patched area, if so, we write a 0xE000 cmd to the drive and read from SDGecko.
	volatile unsigned long* dvd = (volatile unsigned long*)0xCC006000;
	u32 dst = dvd[5];
	u32 len = dvd[4];
	u32 offset = (dvd[3]<<2);
	int ret = 0;

#ifdef DEBUG
	usb_sendbuffer_safe("New Read: ",10);
	print_read((void*)dst,len,offset);
#endif

	// If it doesn't let the value about to be passed to the DVD drive be DVD_DMA | DVD_START
	if((ret=is_frag_read(offset, len))) {
#ifdef DEBUG
		if(ret == 2) {
			usb_sendbuffer_safe("SPLIT FRAG\r\n",12);
		}
		usb_sendbuffer_safe("FRAG READ!\r\n",12);
#endif
		device_frag_read((void*)(dst | 0x80000000), len, offset);
		dcache_flush_icache_inv((void*)(dst | 0x80000000), len);
		dvd[3] = 0;
		dvd[4] = 0x20;
		dvd[5] = 0;
		dvd[6] = 0x20;
		dvd[7] = 3;
	}
	else {
#ifdef DEBUG
		usb_sendbuffer_safe("NORM READ!\r\n",12);
#endif
		dvd[7] = 3;	// DVD_DMA | DVD_START
	}
}
コード例 #5
0
ファイル: strings.c プロジェクト: tvandera/GPI-2
int main (int argc, char *argv[])
{
  gaspi_proc_init(GASPI_BLOCK);
  gaspi_rank_t myRank;
  gaspi_rank_t nProc;
  gaspi_proc_rank(&myRank);
  gaspi_proc_num(&nProc);

  if(nProc < 2)
    goto end;
  
  gaspi_number_t queue_size;
  gaspi_number_t queue_max;
  gaspi_queue_size_max(&queue_max);
  if (myRank == 0)
    gaspi_printf("Queue max is %d\n", queue_max);

  gaspi_printf("Rank %i of %i started.\n", myRank, nProc);

  const gaspi_segment_id_t segment_id = 0;
  const gaspi_size_t nrReads = NR_OF_READS;

  gaspi_group_commit(GASPI_GROUP_ALL,GASPI_BLOCK);
  gaspi_segment_create(segment_id, nrReads * (RAWREADLENGTH) * sizeof(gaspi_char),GASPI_GROUP_ALL,GASPI_BLOCK,GASPI_ALLOC_DEFAULT);

  gaspi_pointer_t _vptr;			//pointer to the segment
  if(gaspi_segment_ptr(segment_id, &_vptr) != GASPI_SUCCESS)
    printf("gaspi_segment_ptr failed\n");
  gaspi_char * shared_ptr = (gaspi_char *) _vptr;

  // initialize and print segment
  initReads(shared_ptr, nrReads, READLENGTH, myRank);

  gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK);

  //push the reads from the master to the slaves
  gaspi_size_t r = 0;
  int rawReadSize = RAWREADLENGTH * sizeof(gaspi_char);
  int nrWorkers = nProc - 1;

  int toRank;
  gaspi_notification_id_t notif_id;
  if (myRank == 0) {
    for (r = 0; r < nrReads; r++) {
      gaspi_queue_size(0, &queue_size);
      if(queue_size > queue_max - 1)
	gaspi_wait(0, GASPI_BLOCK);		//wait for queue to become free again... (note: max is 1024)

      toRank = (r % nrWorkers) + 1;
      //			notif_id = r + 1;
      notif_id = ((r / nrWorkers) + 1);
      if ( gaspi_write_notify(	segment_id,								// from segment
				r*rawReadSize,							// from offset
				toRank,									// to-rank
				segment_id,								// to segment
				//										((int)(r/nrWorkers))*rawReadSize,		// to-offset
				r * rawReadSize,
				rawReadSize,							// size
				notif_id,								// notification id
				r+1,									// notification value (> 0!)
				(gaspi_queue_id_t) 0,					// notification queue
				GASPI_BLOCK) == GASPI_SUCCESS)			// block until written
	gaspi_printf("Sending read %d from %d to rank %d with id %d\n", r, myRank, toRank, notif_id);
      if (toRank == 2)
	print_read(shared_ptr, r, READLENGTH, myRank);
    }
  }

  //ranks receive reads from the master rank
  if (myRank != 0) {
    gaspi_notification_id_t fid;
    gaspi_notification_t notification_value;
    int nrOfReceives = (int)(nrReads / (nProc-1));
    if (myRank <= nrReads % nrWorkers)
      nrOfReceives++;
    gaspi_printf("Rank %d -- listening for %d events...\n", myRank, nrOfReceives);
    int complete = 0;
    while (complete < nrOfReceives) {
      if(gaspi_notify_waitsome(	segment_id, 		// segment
				1,					// id of first notification to wait for
				//										nrReads,
				nrOfReceives,		// id of last notification to wait for (alternative)
				&fid,				// identifier (output parameter with the identifier of a received notification (?))
				GASPI_TEST			// immediately return (GASPI_TEST)
				) == GASPI_SUCCESS) {
	if(gaspi_notify_reset(	segment_id,				// segment
				fid,					// notification identifier
				&notification_value		// notification value
				) == GASPI_SUCCESS) {
	  complete++ ;
	  gaspi_printf("Rank %d -- got notification: read %d received (%d completed)\n", myRank, notification_value-1, complete);
	  if (myRank == 2)
	    print_read(shared_ptr, notification_value-1, READLENGTH, myRank);
	}
      }
    }
  }

  // all values received ! print !
  gaspi_barrier(GASPI_GROUP_ALL,GASPI_BLOCK);
  gaspi_printf("Printing reads\n");
  print_char_array_segment(shared_ptr, nrReads, READLENGTH, myRank);
  //	print_read(shared_ptr, 0, READLENGTH, myRank);

  gaspi_barrier(GASPI_GROUP_ALL,GASPI_BLOCK);
  gaspi_printf("Rank %d done\n", myRank);

  //block and exit
 end:
  gaspi_barrier(GASPI_GROUP_ALL,GASPI_BLOCK);
  gaspi_proc_term(GASPI_BLOCK);
  return EXIT_SUCCESS;
}
コード例 #6
0
/* 
    Print statments in proc
*/
void print_stmt(Stmt stmt, char* proc_id) {

    // Print based on statement kind
    switch (stmt->kind) {
        case STMT_ASSIGN:
            print_assign(stmt->info.assign, proc_id);
            break;      
        case STMT_ASSIGN_ARRAY:
            print_assign_array(stmt->info.assign, 
                stmt->info.assign.exprs, proc_id);
            break;
        case STMT_COND:{
            printf("#if\n");

            // Form label
            char ifCountStr[15];
            char str[80];
            if (stmt->info.cond.else_branch != NULL) {
                sprintf(ifCountStr, "%d", ifcount);
                strcpy (str,"else_");
                strcat (str,ifCountStr);
            }
            else {
                sprintf(ifCountStr, "%d", ifcount);
                strcpy (str,"end_if_");
                strcat (str,ifCountStr);
            }

            int currentIfCount = ifcount;
            ifcount++;
            
            // print conditions of if statment
            print_cond(stmt->info.cond.cond, proc_id, 0, 0, str, "");

            // Print then statements
            print_stmts(stmt->info.cond.then_branch, proc_id);

            // Print labels
            char endIfLabel[80];
            char currCountStr[15];
            sprintf(currCountStr, "%d", currentIfCount);
            strcpy (endIfLabel,"end_if_");
            strcat (endIfLabel,currCountStr);

            // Print else statements
            if (stmt->info.cond.else_branch != NULL) {
                // Branch unconditional
                printf("branch_uncond %s\n", endIfLabel);

                // Do False
                printf("%s:\n", str);

                print_stmts(stmt->info.cond.else_branch, proc_id);
            }
        
            // print label
            printf("%s:\n", endIfLabel);

            printf("\n");
            break;
        }
        case STMT_WHILE:{

            // Print start of while label
            printf("#while\n");
            char whileStr[15];
            sprintf(whileStr, "%d", loopcount);
            char top[80];
            strcpy (top,"top_of_loop_");
            strcat (top,whileStr);

            char loopbreak[80];
            strcpy (loopbreak,"loop_is_false_");
            strcat (loopbreak,whileStr);

            int currentLoopCount = loopcount;
            loopcount++;

            // print while condition
            print_cond(stmt->info.loop.cond, proc_id, 0, 1, top, loopbreak);

            // Print statements
            print_stmts(stmt->info.loop.body, proc_id);

            // Print unconditional branch
            printf("branch_uncond %s\n", top);

            // Print end loop label
            printf("%s:\n", loopbreak);
            printf("\n");

            break;
        }
        case STMT_READ:
            print_read(stmt, proc_id);
            break;      
        case STMT_READ_ARRAY:
            print_read_array(stmt, proc_id);
            break;
        case STMT_WRITE:
            print_write(stmt, proc_id);
            break;
        case STMT_FNCALL:
            print_fncall(stmt, proc_id);
            break;
    }
}