void AuxSkillAbility::SetValidity(u32 NewValidity) { ReplaceData(Data->Validity, NewValidity, 5); CheckData(); }
int main( int argc, char **argv ) { MPI_Comm comm; MPI_Request r[MAX_REQ]; MPI_Status s[MAX_REQ]; int msgsize, maxmsg, root, i, j, size, rank, err = 0, msgcnt, toterr; int *sbuf, *rbuf; MPI_Init( &argc, &argv ); comm = MPI_COMM_WORLD; MPI_Comm_size( comm, &size ); MPI_Comm_rank( comm, &rank ); if (size < 2) { printf( "This test requires at least 2 processors\n" ); MPI_Abort( comm, 1 ); } /* First, try large blocking sends to root */ root = 0; maxmsg = MAX_MSG; msgsize = 128; msgcnt = MAX_MSG_CNT; if (rank == root && verbose) printf( "Blocking sends: " ); while (msgsize <= maxmsg) { if (rank == root) { if (verbose) { printf( "%d ", msgsize ); fflush( stdout ); } rbuf = (int *)malloc( msgsize * sizeof(int) ); if (!rbuf) { printf( "Could not allocate %d words\n", msgsize ); MPI_Abort( comm, 1 ); } for (i=0; i<size; i++) { if (i == rank) continue; for (j=0; j<msgcnt; j++) { SetupRdata( rbuf, msgsize ); MPI_Recv( rbuf, msgsize, MPI_INT, i, 2*i, comm, s ); err += CheckData( rbuf, msgsize, 2*i, s ); } } free( rbuf ); } else { sbuf = (int *)malloc( msgsize * sizeof(int) ); if (!sbuf) { printf( "Could not allocate %d words\n", msgsize ); MPI_Abort( comm, 1 ); } SetupData( sbuf, msgsize, 2*rank ); for (j=0; j<msgcnt; j++) MPI_Send( sbuf, msgsize, MPI_INT, root, 2*rank, comm ); free( sbuf ); } msgsize *= 4; } if (rank == 0 && verbose) { printf( "\n" ); fflush( stdout ); } /* Next, try unexpected messages with Isends */ msgsize = 128; maxmsg = MAX_MSG; msgcnt = MAX_REQ; if (rank == root && verbose) printf( "Unexpected recvs: " ); while (msgsize <= maxmsg) { if (rank == root) { if (verbose) { printf( "%d ", msgsize ); fflush( stdout ); } rbuf = (int *)malloc( msgsize * sizeof(int) ); if (!rbuf) { printf( "Could not allocate %d words\n", msgsize ); MPI_Abort( comm, 1 ); } MPI_Barrier( comm ); for (i=0; i<size; i++) { if (i == rank) continue; for (j=0; j<msgcnt; j++) { SetupRdata( rbuf, msgsize ); MPI_Recv( rbuf, msgsize, MPI_INT, i, 2*i, comm, s ); err += CheckData( rbuf, msgsize, 2*i, s ); } } free( rbuf ); } else { sbuf = (int *)malloc( msgsize * sizeof(int) ); if (!sbuf) { printf( "Could not allocate %d words\n", msgsize ); MPI_Abort( comm, 1 ); } SetupData( sbuf, msgsize, 2*rank ); for (j=0; j<msgcnt; j++) { MPI_Isend( sbuf, msgsize, MPI_INT, root, 2*rank, comm, &r[j] ); } MPI_Barrier( comm ); MPI_Waitall( msgcnt, r, s ); free( sbuf ); } msgsize *= 4; } if (rank == 0 && verbose) { printf( "\n" ); fflush( stdout ); } /* Try large synchronous blocking sends to root */ root = 0; msgsize = 128; maxmsg = MAX_MSG; if (rank == root && verbose) printf( "Synchronous sends: " ); while (msgsize <= maxmsg) { if (rank == root) { if (verbose) { printf( "%d ", msgsize ); fflush( stdout ); } rbuf = (int *)malloc( msgsize * sizeof(int) ); if (!rbuf) { printf( "Could not allocate %d words\n", msgsize ); MPI_Abort( comm, 1 ); } for (i=0; i<size; i++) { if (i == rank) continue; for (j=0; j<msgcnt; j++) { SetupRdata( rbuf, msgsize ); MPI_Recv( rbuf, msgsize, MPI_INT, i, 2*i, comm, s ); err += CheckData( rbuf, msgsize, 2*i, s ); } } free( rbuf ); } else { sbuf = (int *)malloc( msgsize * sizeof(int) ); if (!sbuf) { printf( "Could not allocate %d words\n", msgsize ); MPI_Abort( comm, 1 ); } SetupData( sbuf, msgsize, 2*rank ); for (j=0; j<msgcnt; j++) MPI_Ssend( sbuf, msgsize, MPI_INT, root, 2*rank, comm ); free( sbuf ); } msgsize *= 4; } if (rank == 0 && verbose) { printf( "\n" ); fflush( stdout ); } MPI_Allreduce( &err, &toterr, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD ); if (rank == 0) { if (toterr == 0) printf( "No errors\n" ); else printf( "!! found %d errors\n", toterr ); } if (toterr) { printf( "!! found %d errors on processor %d\n", err, rank ); } MPI_Finalize( ); return 0; }
/* LoadFile: load whole file or segments into segStore */ static void LoadFile(char *fn) { BufferInfo info; char labfn[80]; Transcription *trans; long segStIdx,segEnIdx; HTime tStart, tEnd; int i,k,s,ncas,nObs=0,segLen; LLink p; Observation obs; if((pbuf=OpenBuffer(&bufferStack, fn, 10, dff, FALSE_dup, FALSE_dup))==NULL) HError(2150,"LoadFile: Config parameters invalid"); GetBufferInfo(pbuf,&info); CheckData(fn,info); if (firstTime) InitSegStore(&info); if (segId == NULL) { /* load whole parameter file */ nObs = ObsInBuffer(pbuf); tStart = 0.0; tEnd = (info.tgtSampRate * nObs); LoadSegment(segStore, tStart, tEnd, pbuf); segIdx++; } else { /* load segment of parameter file */ MakeFN(fn,labDir,labExt,labfn); trans = LOpen(&transStack,labfn,lff); ncas = NumCases(trans->head,segId); if ( ncas > 0) { for (i=1,nObs=0; i<=ncas; i++) { p = GetCase(trans->head,segId,i); segStIdx = (long)(p->start/info.tgtSampRate); segEnIdx = (long)(p->end/info.tgtSampRate); if (segEnIdx >= ObsInBuffer(pbuf)) segEnIdx = ObsInBuffer(pbuf)-1; if (segEnIdx - segStIdx + 1 >= nStates-2) { LoadSegment(segStore, p->start, p->end, pbuf); nObs += SegLength(segStore, segIdx); segIdx++; } } } } if (hset.hsKind == DISCRETEHS){ for (k=prevSegIdx; k<segIdx; k++){ segLen = SegLength(segStore, k); for (i=1; i<=segLen; i++){ obs = GetSegObs(segStore, k, i); for (s=1; s<=nStreams; s++){ if( (obs.vq[s] < 1) || (obs.vq[s] > maxMixInS[s])) HError(2150,"LoadFile: Discrete data value [ %d ] out of range in stream [ %d ] in file %s",obs.vq[s],s,fn); } } } prevSegIdx=segIdx; } CloseBuffer(pbuf); ResetHeap(&transStack); }
/** * * This function waits until the DMA transaction is finished, checks data, * and cleans up. * * @param None * * @return - XST_SUCCESS if DMA transfer is successful and data is correct, * - XST_FAILURE if fails. * * @note None. * ******************************************************************************/ static int CheckDmaResult(XAxiDma * AxiDmaInstPtr) { XAxiDma_BdRing *TxRingPtr; XAxiDma_BdRing *RxRingPtr; XAxiDma_Bd *BdPtr; int ProcessedBdCount; int FreeBdCount; int Status; TxRingPtr = XAxiDma_GetTxRing(AxiDmaInstPtr); RxRingPtr = XAxiDma_GetRxRing(AxiDmaInstPtr); /* Wait until the one BD TX transaction is done */ while ((ProcessedBdCount = XAxiDma_BdRingFromHw(TxRingPtr, XAXIDMA_ALL_BDS, &BdPtr)) == 0) { xil_printf("wait for Transmit"); } //xil_printf("Transmit ProcessedBdCount = %d\n",ProcessedBdCount); //xil_printf("Transmit ProcessedBdCount = %d\n",ProcessedBdCount); /* Free all processed TX BDs for future transmission */ // Status = XAxiDma_BdRingFree(TxRingPtr, ProcessedBdCount, BdPtr); // if (Status != XST_SUCCESS) { // xil_printf("Failed to free %d tx BDs %d\r\n", // ProcessedBdCount, Status); // return XST_FAILURE; // } xil_printf("CheckFreeTxBd"); /* Wait until the data has been received by the Rx channel */ while ((ProcessedBdCount = XAxiDma_BdRingFromHw(RxRingPtr, XAXIDMA_ALL_BDS, &BdPtr)) == 0) { xil_printf("wait for Recieve"); } xil_printf("Recieve ProcessedBdCount = %d",ProcessedBdCount); /* Check received data */ if (CheckData() != XST_SUCCESS) { return XST_FAILURE; } /* Free all processed RX BDs for future transmission */ Status = XAxiDma_BdRingFree(RxRingPtr, ProcessedBdCount, BdPtr); if (Status != XST_SUCCESS) { xil_printf("Failed to free %d rx BDs %d\r\n", ProcessedBdCount, Status); return XST_FAILURE; } /* Return processed BDs to RX channel so we are ready to receive new * packets: * - Allocate all free RX BDs * - Pass the BDs to RX channel */ FreeBdCount = XAxiDma_BdRingGetFreeCnt(RxRingPtr); Status = XAxiDma_BdRingAlloc(RxRingPtr, FreeBdCount, &BdPtr); if (Status != XST_SUCCESS) { xil_printf("bd alloc failed\r\n"); return XST_FAILURE; } Status = XAxiDma_BdRingToHw(RxRingPtr, FreeBdCount, BdPtr); if (Status != XST_SUCCESS) { xil_printf("Submit %d rx BDs failed %d\r\n", FreeBdCount, Status); return XST_FAILURE; } return XST_SUCCESS; }
/** * * Main function * * This function is the main entry of the interrupt test. It does the following: * - Set up the output terminal if UART16550 is in the hardware build * - Initialize the DMA engine * - Set up Tx and Rx channels * - Set up the interrupt system for the Tx and Rx interrupts * - Submit a transfer * - Wait for the transfer to finish * - Check transfer status * - Disable Tx and Rx interrupts * - Print test status and exit * * @param None * * @return - XST_SUCCESS if tests pass * - XST_FAILURE if fails. * * @note None. * ******************************************************************************/ int main(void) { int Status; XAxiDma_Config *Config; /* Initial setup for Uart16550 */ #ifdef XPAR_UARTNS550_0_BASEADDR Uart550_Setup(); #endif xil_printf("\r\n--- Entering main() --- \r\n"); Config = XAxiDma_LookupConfig(DMA_DEV_ID); if (!Config) { xil_printf("No config found for %d\r\n", DMA_DEV_ID); return XST_FAILURE; } /* Initialize DMA engine */ XAxiDma_CfgInitialize(&AxiDma, Config); if(!XAxiDma_HasSg(&AxiDma)) { xil_printf("Device configured as Simple mode \r\n"); return XST_FAILURE; } /* Set up TX/RX channels to be ready to transmit and receive packets */ Status = TxSetup(&AxiDma); if (Status != XST_SUCCESS) { xil_printf("Failed TX setup\r\n"); return XST_FAILURE; } Status = RxSetup(&AxiDma); if (Status != XST_SUCCESS) { xil_printf("Failed RX setup\r\n"); return XST_FAILURE; } /* Set up Interrupt system */ Status = SetupIntrSystem(&Intc, &AxiDma, TX_INTR_ID, RX_INTR_ID); if (Status != XST_SUCCESS) { xil_printf("Failed intr setup\r\n"); return XST_FAILURE; } /* Initialize flags before start transfer test */ TxDone = 0; RxDone = 0; Error = 0; /* Send a packet */ Status = SendPacket(&AxiDma); if (Status != XST_SUCCESS) { xil_printf("Failed send packet\r\n"); return XST_FAILURE; } /* * Wait TX done and RX done */ while (((TxDone < NUMBER_OF_BDS_TO_TRANSFER) || (RxDone < NUMBER_OF_BDS_TO_TRANSFER)) && !Error) { /* NOP */ } if (Error) { xil_printf("Failed test transmit%s done, " "receive%s done\r\n", TxDone? "":" not", RxDone? "":" not"); goto Done; }else { /* * Test finished, check data */ Status = CheckData(MAX_PKT_LEN * NUMBER_OF_BDS_TO_TRANSFER, 0xC); if (Status != XST_SUCCESS) { xil_printf("Data check failed\r\n"); goto Done; } xil_printf("AXI DMA SG interrupt Test passed\r\n"); } /* Disable TX and RX Ring interrupts and return success */ DisableIntrSystem(&Intc, TX_INTR_ID, RX_INTR_ID); Done: xil_printf("--- Exiting main() --- \r\n"); if (Status != XST_SUCCESS) { return XST_FAILURE; } return XST_SUCCESS; }
void AuxFaction::SetOrder(u32 NewOrder) { ReplaceData(Data->Order, NewOrder, 2); CheckData(); }
//======================================================================= //function : Perform //purpose : //======================================================================= void GEOMAlgo_Gluer2::Perform() { myErrorStatus=0; myWarningStatus=0; // CheckData(); if (myErrorStatus) { return; } // // Initialize the context GEOMAlgo_GluerAlgo::Perform(); // PerformShapesToWork(); if (myErrorStatus) { return; } if (myWarningStatus==1) { // no shapes to glue myShape=myArgument; return; } // FillVertices(); if (myErrorStatus) { return; } // FillEdges(); if (myErrorStatus) { return; } // FillWires(); if (myErrorStatus) { return; } // FillFaces(); if (myErrorStatus) { return; } // FillShells(); if (myErrorStatus) { return; } // FillSolids(); if (myErrorStatus) { return; } // FillCompSolids(); if (myErrorStatus) { return; } // FillCompounds(); if (myErrorStatus) { return; } // BuildResult(); if (myErrorStatus) { return; } // PrepareHistory(); if (myErrorStatus) { return; } // BRepLib::SameParameter(myShape, myTolerance, Standard_True); }
/* This program is from mpich/tsuite/pt2pt and should be changed there only. It needs gcomm and dtype from mpich/tsuite, and can be run with any number of processes > 1. This version uses Pack to send a message and Unpack OR the datatype to receive it. */ int main( int argc, char **argv ) { MPI_Datatype *types; void **inbufs, **outbufs; char **names; char *packbuf, *unpackbuf; int packsize, unpacksize, position; int *counts, *bytesize, ntype; MPI_Comm comms[20]; int ncomm = 20, rank, np, partner, tag, count; int i, j, k, err, toterr, world_rank; int errloc; MPI_Status status; char *obuf; MPI_Init( &argc, &argv ); AllocateForData( &types, &inbufs, &outbufs, &counts, &bytesize, &names, &ntype ); GenerateData( types, inbufs, outbufs, counts, bytesize, names, &ntype ); MPI_Comm_rank( MPI_COMM_WORLD, &world_rank ); MakeComms( comms, 20, &ncomm, 0 ); /* Test over a wide range of datatypes and communicators */ err = 0; for (i=0; i<ncomm; i++) { MPI_Comm_rank( comms[i], &rank ); MPI_Comm_size( comms[i], &np ); if (np < 2) continue; if (world_rank == 0 && verbose) { fprintf( stdout, "Testing with communicator with %d members\n", np ); } tag = i; for (j=0; j<ntype; j++) { if (world_rank == 0 && verbose) fprintf( stdout, "Testing type %s\n", names[j] ); if (rank == 0) { partner = np - 1; MPI_Pack_size( counts[j], types[j], comms[i], &packsize ); packbuf = (char *)malloc( packsize ); if (!packbuf) { fprintf( stderr, "[%i] Aborting\n",rank );fflush(stderr); MPI_Abort( MPI_COMM_WORLD, 1 ); } position = 0; MPI_Pack( inbufs[j], counts[j], types[j], packbuf, packsize, &position, comms[i] ); /* Send twice */ MPI_Send( packbuf, position, MPI_PACKED, partner, tag, comms[i] ); MPI_Send( packbuf, position, MPI_PACKED, partner, tag, comms[i] ); free( packbuf ); } else if (rank == np-1) { partner = 0; obuf = outbufs[j]; for (k=0; k<bytesize[j]; k++) obuf[k] = 0; /* Receive directly */ MPI_Recv( outbufs[j], counts[j], types[j], partner, tag, comms[i], &status ); /* Test correct */ MPI_Get_count( &status, types[j], &count ); if (count != counts[j]) { fprintf( stderr, "Error in counts (got %d expected %d) with type %s\n", count, counts[j], names[j] ); err++; } if (status.MPI_SOURCE != partner) { fprintf( stderr, "Error in source (got %d expected %d) with type %s\n", status.MPI_SOURCE, partner, names[j] ); err++; } if ((errloc = CheckData( inbufs[j], outbufs[j], bytesize[j] ))) { fprintf( stderr, "Error in data at byte %d with type %s (type %d on %d)\n", errloc - 1, names[j], j, world_rank ); err++; } /* Receive packed, then unpack */ MPI_Pack_size( counts[j], types[j], comms[i], &unpacksize ); unpackbuf = (char *)malloc( unpacksize ); if (!unpackbuf) { fprintf( stderr, "[%i] Aborting\n",rank );fflush(stderr); MPI_Abort( MPI_COMM_WORLD, 1 ); } MPI_Recv( unpackbuf, unpacksize, MPI_PACKED, partner, tag, comms[i], &status ); obuf = outbufs[j]; for (k=0; k<bytesize[j]; k++) obuf[k] = 0; position = 0; MPI_Get_count( &status, MPI_PACKED, &unpacksize ); MPI_Unpack( unpackbuf, unpacksize, &position, outbufs[j], counts[j], types[j], comms[i] ); free( unpackbuf ); /* Test correct */ #ifdef FOO /* Length is tricky; a correct code will have signaled an error in MPI_Unpack */ count = position; if (count != counts[j]) { fprintf( stderr, "Error in counts (got %d expected %d) with type %s (Unpack)\n", count, counts[j], names[j] ); err++; } #endif if (status.MPI_SOURCE != partner) { fprintf( stderr, "Error in source (got %d expected %d) with type %s (Unpack)\n", status.MPI_SOURCE, partner, names[j] ); err++; } if ((errloc = CheckData( inbufs[j], outbufs[j], bytesize[j] ))) { fprintf( stderr, "Error in data at byte %d with type %s (type %d on %d, Unpack)\n", errloc - 1, names[j], j, world_rank ); err++; } } } } if (err > 0) { fprintf( stderr, "%d errors on %d\n", err, rank ); } MPI_Allreduce( &err, &toterr, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD ); if (world_rank == 0) { if (toterr == 0) { printf( " No Errors\n" ); } else { printf (" Found %d errors\n", toterr ); } } FreeDatatypes( types, inbufs, outbufs, counts, bytesize, names, ntype ); FreeComms( comms, ncomm ); MPI_Barrier( MPI_COMM_WORLD ); MPI_Finalize(); return err; }
int main( int argc, char **argv ) { MPI_Comm comm; MPI_Request r[MAX_REQ]; MPI_Status s[MAX_REQ]; int msgsize, maxmsg, root, i, size, rank, err = 0, toterr; int max_msg_size = DEF_MAX_MSG; int *sbuf, *rbuf; MPI_Init( &argc, &argv ); comm = MPI_COMM_WORLD; MPI_Comm_size( comm, &size ); MPI_Comm_rank( comm, &rank ); if (size < 2) { printf( "This test requires at least 2 processors\n" ); MPI_Abort( comm, 1 ); } /* Check for a max message argument */ if (rank == 0) { if (argc > 1) { max_msg_size = atoi( argv[1] ); /* Correct if unrecognized argument */ if (max_msg_size <= 0) max_msg_size = DEF_MAX_MSG; } } MPI_Bcast( &max_msg_size, 1, MPI_INT, 0, MPI_COMM_WORLD ); /* First, try large blocking sends to root */ root = 0; msgsize = 128; maxmsg = max_msg_size; if (rank == root && verbose) printf( "Blocking sends: " ); while (msgsize < maxmsg) { if (rank == root) { if (verbose) { printf( "%d ", msgsize ); fflush( stdout ); } rbuf = (int *)malloc( msgsize * sizeof(int) ); if (!rbuf) { printf( "Could not allocate %d words\n", msgsize ); MPI_Abort( comm, 1 ); } for (i=0; i<size; i++) { if (i == rank) continue; SetupRdata( rbuf, msgsize ); MPI_Recv( rbuf, msgsize, MPI_INT, i, 2*i, comm, s ); err += CheckData( rbuf, msgsize, 2*i, s ); } free( rbuf ); } else { sbuf = (int *)malloc( msgsize * sizeof(int) ); if (!sbuf) { printf( "Could not allocate %d words\n", msgsize ); MPI_Abort( comm, 1 ); } SetupData( sbuf, msgsize, 2*rank ); MPI_Ssend( sbuf, msgsize, MPI_INT, root, 2*rank, comm ); free( sbuf ); } msgsize *= 4; } if (rank == 0 && verbose) { printf( "\n" ); fflush( stdout ); } /* Next, try unexpected messages with Isends */ msgsize = 128; maxmsg = max_msg_size; if (rank == root && verbose) printf( "Unexpected recvs: " ); while (msgsize < maxmsg) { if (rank == root) { if (verbose) { printf( "%d ", msgsize ); fflush( stdout ); } rbuf = (int *)malloc( msgsize * sizeof(int) ); if (!rbuf) { printf( "Could not allocate %d words\n", msgsize ); MPI_Abort( comm, 1 ); } MPI_Barrier( comm ); for (i=0; i<size; i++) { if (i == rank) continue; SetupRdata( rbuf, msgsize ); MPI_Recv( rbuf, msgsize, MPI_INT, i, 2*i, comm, s ); err += CheckData( rbuf, msgsize, 2*i, s ); } free( rbuf ); } else { sbuf = (int *)malloc( msgsize * sizeof(int) ); if (!sbuf) { printf( "Could not allocate %d words\n", msgsize ); MPI_Abort( comm, 1 ); } SetupData( sbuf, msgsize, 2*rank ); MPI_Isend( sbuf, msgsize, MPI_INT, root, 2*rank, comm, r ); MPI_Barrier( comm ); MPI_Wait( r, s ); free( sbuf ); } msgsize *= 4; } if (rank == 0 && verbose) { printf( "\n" ); fflush( stdout ); } /* Try large synchronous blocking sends to root */ root = 0; msgsize = 128; maxmsg = max_msg_size; if (rank == root && verbose) printf( "Synchronous sends: " ); while (msgsize < maxmsg) { if (rank == root) { if (verbose) { printf( "%d ", msgsize ); fflush( stdout ); } rbuf = (int *)malloc( msgsize * sizeof(int) ); if (!rbuf) { printf( "Could not allocate %d words\n", msgsize ); MPI_Abort( comm, 1 ); } for (i=0; i<size; i++) { if (i == rank) continue; SetupRdata( rbuf, msgsize ); MPI_Recv( rbuf, msgsize, MPI_INT, i, 2*i, comm, s ); err += CheckData( rbuf, msgsize, 2*i, s ); } free( rbuf ); } else { sbuf = (int *)malloc( msgsize * sizeof(int) ); if (!sbuf) { printf( "Could not allocate %d words\n", msgsize ); MPI_Abort( comm, 1 ); } SetupData( sbuf, msgsize, 2*rank ); MPI_Send( sbuf, msgsize, MPI_INT, root, 2*rank, comm ); free( sbuf ); } msgsize *= 4; } if (rank == 0 && verbose) { printf( "\n" ); fflush( stdout ); } /* Next, try expected messages with Rsend */ msgsize = 128; maxmsg = max_msg_size; if (rank == root && verbose) printf( "Expected recvs and Rsend: " ); while (msgsize < maxmsg) { if (rank == root) { if (verbose) { printf( "%d ", msgsize ); fflush( stdout ); } rbuf = (int *)malloc( msgsize * sizeof(int) ); if (!rbuf) { printf( "Could not allocate %d words\n", msgsize ); MPI_Abort( comm, 1 ); } for (i=0; i<size; i++) { if (i == rank) continue; SetupRdata( rbuf, msgsize ); MPI_Irecv( rbuf, msgsize, MPI_INT, i, 2*i, comm, r ); MPI_Send( MPI_BOTTOM, 0, MPI_INT, i, 2*i+1, comm ); MPI_Wait( r, s ); err += CheckData( rbuf, msgsize, 2*i, s ); } free( rbuf ); } else { sbuf = (int *)malloc( msgsize * sizeof(int) ); if (!sbuf) { printf( "Could not allocate %d words\n", msgsize ); MPI_Abort( comm, 1 ); } SetupData( sbuf, msgsize, 2*rank ); MPI_Recv( MPI_BOTTOM, 0, MPI_INT, root, 2*rank+1, comm, s ); MPI_Send( sbuf, msgsize, MPI_INT, root, 2*rank, comm ); free( sbuf ); } msgsize *= 4; } if (rank == 0 && verbose) { printf( "\n" ); fflush( stdout ); } MPI_Allreduce( &err, &toterr, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD ); if (rank == 0) { if (toterr == 0) printf( " No Errors\n" ); else printf( "!! found %d errors\n", toterr ); } if (toterr) { printf( "!! found %d errors on processor %d\n", err, rank ); } MPI_Finalize( ); return 0; }
void AuxGroupMember::SetFormation(u32 NewFormation) { ReplaceData(Data->Formation, NewFormation, 2); CheckData(); }
void AuxGroupMember::SetPosition(u32 NewPosition) { ReplaceData(Data->Position, NewPosition, 3); CheckData(); }
void AuxGroupMember::SetGameID(u32 NewGameID) { ReplaceData(Data->GameID, NewGameID, 1); CheckData(); }
void AuxGroupMember::SetName(char * NewName) { ReplaceString(Data->Name, NewName, 0); CheckData(); }
void AuxSkillAbility::SetCanBeUsedWhileIncapacitated(bool NewCanBeUsedWhileIncapacitated) { ReplaceData(Data->CanBeUsedWhileIncapacitated, NewCanBeUsedWhileIncapacitated, 6); CheckData(); }
void AuxFaction::SetName(const char * NewName) { ReplaceString(Data->Name, NewName, 0); CheckData(); }
BOOL CCalcFrameDlg::OnCommand(WPARAM wParam, LPARAM lParam) { UpdateData(TRUE); switch ( LOWORD(wParam) ) { case ID_32771: //标准型 { CMenu *pMenu = GetMenu()->GetSubMenu(0); if( pMenu != NULL ) { pMenu->CheckMenuItem(ID_32771,MF_CHECKED); pMenu->CheckMenuItem(ID_32772,MF_UNCHECKED); } OnBnClickedBtC(); if( m_enWindowStyle == en_Normal ) return TRUE; m_enWindowStyle = en_Normal; PostMessage(WM_SIZE); } break; case ID_32772: //科学型 { CMenu *pMenu = GetMenu()->GetSubMenu(0); if( pMenu != NULL ) { pMenu->CheckMenuItem(ID_32772,MF_CHECKED); pMenu->CheckMenuItem(ID_32771,MF_UNCHECKED); } OnBnClickedBtC(); if( m_enWindowStyle == en_Science ) return TRUE; m_enWindowStyle = en_Science; PostMessage(WM_SIZE); } break; case ID_32773: //最前显示 { m_bFront = !m_bFront; GetMenu()->GetSubMenu(0)->CheckMenuItem(ID_32773,m_bFront?MF_CHECKED:MF_UNCHECKED); SetWindowPos(m_bFront? &wndTopMost : &wndNoTopMost,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE); } break; case ID_32775: { //打开剪切板 if (OpenClipboard()==FALSE) return TRUE; if (EmptyClipboard()==FALSE) { CloseClipboard(); return TRUE; } //复制数据 HANDLE hData=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,m_strOutPut.GetLength()+1); if (hData==NULL) { CloseClipboard(); return TRUE; } LPTSTR szMemName=(LPTSTR)GlobalLock(hData); lstrcpy(szMemName,m_strOutPut); SetClipboardData(CF_TEXT,hData); GlobalUnlock(hData); CloseClipboard(); break; } case ID_32776: { //判断剪贴板的数据格式是否可以处理。 if (!IsClipboardFormatAvailable(CF_TEXT)) return TRUE; //打开剪贴板。 if (!OpenClipboard()) return TRUE; //获取UNICODE的数据。 HGLOBAL hMem = GetClipboardData(CF_TEXT); if (hMem != NULL) { LPTSTR lpStr = (LPTSTR)GlobalLock(hMem); if (lpStr != NULL) { for (int i=0;i<strlen(lpStr);i++) { BYTE bTemp = lpStr[i]-'0'; if(bTemp<0 || bTemp>9) { AfxMessageBox(TEXT("黏贴的字符不符合标准!"),MB_ICONSTOP); return TRUE; } } m_strOutPut = lpStr; //释放锁内存。 GlobalUnlock(hMem); } } //关闭剪贴板。 CloseClipboard(); } break; case ID_ABOUTBOX: //关于窗口 { CAboutDlg dlgAbout; dlgAbout.DoModal(); } break; case IDC_BT_0: case IDC_BT_1: case IDC_BT_2: case IDC_BT_3: case IDC_BT_4: case IDC_BT_5: case IDC_BT_6: case IDC_BT_7: case IDC_BT_8: case IDC_BT_9: { UpdateData(TRUE); if ( !m_bPressEnable ) break; CString str; str.Format(TEXT("%d"),LOWORD(wParam)-IDC_BT_0); //之前是用+-*/做的运算结果,那么显示的结果在这里清除 if ( !m_bPressNumber ) { m_strOutPut = str; m_bPressNumber = true; } else { if ( (m_strOutPut.GetAt(0) == '0') && (m_strOutPut.GetAt(1) != '.')) m_strOutPut = str; else m_strOutPut+=str; } m_bIsBaseCalc = false; } break; case IDC_BT_DIAN: { bool bInsertPoint = true; m_bIsBaseCalc = false; //查询输入的字符串中是否有小数点 for(int i=0;i<m_strOutPut.GetLength();i++) { if( m_strOutPut.GetAt(i) == '.') { bInsertPoint = false; break;; } } if( bInsertPoint ) m_strOutPut+=TEXT("."); } break; case IDC_BT_SAVE: //存储 { m_ListSave.AddString(m_strOutPut); GetDlgItem(IDC_STATIC_M)->ShowWindow(SW_SHOW); if( m_bShowSave == false ) { m_bShowSave = true; CRect rcClient; GetClientRect(&rcClient); RectifyControl(rcClient.Width(),rcClient.Height()); } } break; case IDC_BT_CE: { if( !m_bPressNumber ) break; m_strOutPut = TEXT("0"); } break; case IDC_BT_LEFT: //退位 { if( !m_bPressNumber ) break; m_strOutPut = m_strOutPut.Left(m_strOutPut.GetLength()-1); if ( m_strOutPut.GetLength() == 0 ) { m_strOutPut=TEXT("0"); } } break; case IDC_BT_FUSHU: //负数符号 { if( m_strOutPut.GetAt(0) == '-' ) m_strOutPut = m_strOutPut.Right(m_strOutPut.GetLength()-1); else m_strOutPut.Insert(0,'-'); } break; case IDC_BT_KAIFANG: { InsertRecord(en_Record_Sqrt); m_strOutPut.Format(TEXT("%.15lf"),sqrt(strtod(m_strOutPut,NULL))); //去除后面没用的0 CheckData(m_strOutPut); m_bPressEnable = false; } break; } UpdateData(FALSE); return CDialog::OnCommand(wParam, lParam); }
void AuxFaction::SetReaction(float NewReaction) { ReplaceData(Data->Reaction, NewReaction, 1); CheckData(); }
bool CCalcFrameDlg::GetCalc() { //过滤无运算操作 if( m_enCalcType == en_Null ) return false; UpdateData(TRUE); //这里没有用atof转换,因为此函数精度只能保证小数点后6位 //为了保证更多的精度,这里选择了strtod函数 double dNum1 = strtod(m_strResultOld,NULL); double dNum2 = strtod(m_strOutPut,NULL); double dResult = 0; //先将之前的输出结果保存起来 m_strResultOld = m_strOutPut; switch ( m_enCalcType ) { case en_Add: //加法运算 { dResult = dNum1+dNum2; } break; case en_Sub: //减法运算 { dResult = dNum1-dNum2; } break; case en_Mul: //乘法运算 { dResult = dNum1*dNum2; } break; case en_Div: //除法运算 { //除数不能为0 if(dNum2 == 0 ) { m_strOutPut = TEXT("结果未定义"); UpdateData(FALSE); return true; } dResult = dNum1/dNum2; } break; case en_Pow: //乘法运算 { dResult = pow(dNum1,dNum2); } case en_Yroot: //乘法运算 { dResult = pow(dNum1,1/dNum2); } break; } //这里并没有使用dobule的全部精度,因为cpu对浮点数计算不是很好, //就算是strtod这个函数,仍然存在精度丢失的情况,但是问题不大, //所以舍弃最后的一个精度 m_strOutPut.Format(TEXT("%.15lf"),dResult); //去除后面没用的0 CheckData(m_strOutPut); UpdateData(FALSE); return true; }
int XAxiCdma_SgIntrExample(XScuGic *IntcInstancePtr, XAxiCdma *InstancePtr, u16 DeviceId,u32 IntrId) #endif { XAxiCdma_Config *CfgPtr; int Status; u8 *SrcPtr; u8 *DstPtr; SrcPtr = (u8 *)TransmitBufferPtr; DstPtr = (u8 *)ReceiveBufferPtr; #ifdef __aarch64__ Xil_SetTlbAttributes(BD_SPACE_BASE, MARK_UNCACHEABLE); #endif /* Initialize the XAxiCdma device. */ CfgPtr = XAxiCdma_LookupConfig(DeviceId); if (!CfgPtr) { xdbg_printf(XDBG_DEBUG_ERROR, "Cannot find config structure for device %d\r\n", XPAR_AXICDMA_0_DEVICE_ID); return XST_FAILURE; } Status = XAxiCdma_CfgInitialize(InstancePtr, CfgPtr, CfgPtr->BaseAddress); if (Status != XST_SUCCESS) { xdbg_printf(XDBG_DEBUG_ERROR, "Initialization failed with %d\r\n", Status); return XST_FAILURE; } /* Setup the BD ring */ Status = SetupTransfer(InstancePtr); if (Status != XST_SUCCESS) { xdbg_printf(XDBG_DEBUG_ERROR, "Setup BD ring failed with %d\r\n", Status); return XST_FAILURE; } /* Setup the interrupt system */ Status = SetupIntrSystem(IntcInstancePtr, InstancePtr, IntrId); if (Status != XST_SUCCESS) { xdbg_printf(XDBG_DEBUG_ERROR, "Setup Intr system failed with %d\r\n", Status); return XST_FAILURE; } /* Enable completion and error interrupts */ XAxiCdma_IntrEnable(InstancePtr, XAXICDMA_XR_IRQ_ALL_MASK); /* Start the DMA transfer */ Status = DoTransfer(InstancePtr); if (Status != XST_SUCCESS) { xdbg_printf(XDBG_DEBUG_ERROR, "Do transfer failed with %d\r\n", Status); return XST_FAILURE; } /* Wait until the DMA transfer is done */ while ((Done < NUMBER_OF_BDS_TO_TRANSFER) && !Error) { /* Wait */ } if(Error) { xdbg_printf(XDBG_DEBUG_ERROR, "Transfer has error %x\r\n", (unsigned int)XAxiCdma_GetError(InstancePtr)); DisableIntrSystem(IntcInstancePtr, IntrId); return XST_FAILURE; } /* Transfer completes successfully, check data */ Status = CheckData(SrcPtr, DstPtr, MAX_PKT_LEN * NUMBER_OF_BDS_TO_TRANSFER); if (Status != XST_SUCCESS) { xdbg_printf(XDBG_DEBUG_ERROR, "Check data failed for sg " "transfer\r\n"); DisableIntrSystem(IntcInstancePtr, IntrId); return XST_FAILURE; } /* Test finishes successfully, clean up and return */ DisableIntrSystem(IntcInstancePtr, IntrId); return XST_SUCCESS; }
void AuxElement::SetMagnitude(u32 NewMagnitude) { ReplaceData(Data->Magnitude, NewMagnitude, 2); CheckData(); }
/** * The example to do the scatter gather transfer through polling. * * @param DeviceId is the Device Id of the XAxiCdma instance * * @return * - XST_SUCCESS if example finishes successfully * - XST_FAILURE if error occurs * * @note None * ******************************************************************************/ int XAxiCdma_SgPollExample(u16 DeviceId) { XAxiCdma_Config *CfgPtr; int Status; u8 *SrcPtr; u8 *DstPtr; SrcPtr = (u8 *)TransmitBufferPtr; DstPtr = (u8 *)ReceiveBufferPtr; #ifdef __aarch64__ Xil_SetTlbAttributes(BD_SPACE_BASE, MARK_UNCACHEABLE); #endif /* Initialize the XAxiCdma device. */ CfgPtr = XAxiCdma_LookupConfig(DeviceId); if (!CfgPtr) { xdbg_printf(XDBG_DEBUG_ERROR, "Cannot find config structure for device %d\r\n", XPAR_AXICDMA_0_DEVICE_ID); return XST_FAILURE; } Status = XAxiCdma_CfgInitialize(&AxiCdmaInstance, CfgPtr, CfgPtr->BaseAddress); if (Status != XST_SUCCESS) { xdbg_printf(XDBG_DEBUG_ERROR, "Initialization failed with %d\r\n", Status); return XST_FAILURE; } /* Setup the BD ring */ Status = SetupTransfer(&AxiCdmaInstance); if (Status != XST_SUCCESS) { xdbg_printf(XDBG_DEBUG_ERROR, "Setup BD ring failed with %d\r\n", Status); return XST_FAILURE; } Done = 0; Error = 0; /* Start the DMA transfer */ Status = DoTransfer(&AxiCdmaInstance); if (Status != XST_SUCCESS) { xdbg_printf(XDBG_DEBUG_ERROR, "Do transfer failed with %d\r\n", Status); return XST_FAILURE; } /* Wait until the DMA transfer is done or error occurs */ while ((CheckCompletion(&AxiCdmaInstance) < NUMBER_OF_BDS_TO_TRANSFER) && !Error) { /* Wait */ } if(Error) { int TimeOut = RESET_LOOP_COUNT; xdbg_printf(XDBG_DEBUG_ERROR, "Transfer has error %x\r\n", Error); /* Need to reset the hardware to restore to the correct state */ XAxiCdma_Reset(&AxiCdmaInstance); while (TimeOut) { if (XAxiCdma_ResetIsDone(&AxiCdmaInstance)) { break; } TimeOut -= 1; } /* Reset has failed, print a message to notify the user */ if (!TimeOut) { xdbg_printf(XDBG_DEBUG_ERROR, "Reset hardware failed with %d\r\n", Status); } return XST_FAILURE; } /* Transfer completed successfully, check data */ Status = CheckData(SrcPtr, DstPtr, MAX_PKT_LEN * NUMBER_OF_BDS_TO_TRANSFER); if (Status != XST_SUCCESS) { xdbg_printf(XDBG_DEBUG_ERROR, "Check data failed for sg " "transfer\r\n"); return XST_FAILURE; } /* Test finishes successfully, return successfully */ return XST_SUCCESS; }
void AuxElement::SetIsActive(bool NewIsActive) { ReplaceData(Data->IsActive, NewIsActive, 3); CheckData(); }
/** * * Main function * * This function is the main entry of the interrupt test. It does the following: * Set up the output terminal if UART16550 is in the hardware build * Initialize the DMA engine * Set up Tx and Rx channels * Set up the interrupt system for the Tx and Rx interrupts * Submit a transfer * Wait for the transfer to finish * Check transfer status * Disable Tx and Rx interrupts * Print test status and exit * * @param None * * @return * - XST_SUCCESS if example finishes successfully * - XST_FAILURE if example fails. * * @note None. * ******************************************************************************/ int main(void) { int Status; XAxiDma_Config *Config; int Tries = NUMBER_OF_TRANSFERS; int Index; u8 *TxBufferPtr; u8 *RxBufferPtr; u8 Value; TxBufferPtr = (u8 *)TX_BUFFER_BASE ; RxBufferPtr = (u8 *)RX_BUFFER_BASE; /* Initial setup for Uart16550 */ #ifdef XPAR_UARTNS550_0_BASEADDR Uart550_Setup(); #endif xil_printf("\r\n--- Entering main() --- \r\n"); Config = XAxiDma_LookupConfig(DMA_DEV_ID); if (!Config) { xil_printf("No config found for %d\r\n", DMA_DEV_ID); return XST_FAILURE; } /* Initialize DMA engine */ Status = XAxiDma_CfgInitialize(&AxiDma, Config); if (Status != XST_SUCCESS) { xil_printf("Initialization failed %d\r\n", Status); return XST_FAILURE; } if(XAxiDma_HasSg(&AxiDma)){ xil_printf("Device configured as SG mode \r\n"); return XST_FAILURE; } /* Set up Interrupt system */ Status = SetupIntrSystem(&Intc, &AxiDma, TX_INTR_ID, RX_INTR_ID); if (Status != XST_SUCCESS) { xil_printf("Failed intr setup\r\n"); return XST_FAILURE; } /* Disable all interrupts before setup */ XAxiDma_IntrDisable(&AxiDma, XAXIDMA_IRQ_ALL_MASK, XAXIDMA_DMA_TO_DEVICE); XAxiDma_IntrDisable(&AxiDma, XAXIDMA_IRQ_ALL_MASK, XAXIDMA_DEVICE_TO_DMA); /* Enable all interrupts */ XAxiDma_IntrEnable(&AxiDma, XAXIDMA_IRQ_ALL_MASK, XAXIDMA_DMA_TO_DEVICE); XAxiDma_IntrEnable(&AxiDma, XAXIDMA_IRQ_ALL_MASK, XAXIDMA_DEVICE_TO_DMA); /* Initialize flags before start transfer test */ TxDone = 0; RxDone = 0; Error = 0; Value = TEST_START_VALUE; for(Index = 0; Index < MAX_PKT_LEN; Index ++) { TxBufferPtr[Index] = Value; Value = (Value + 1) & 0xFF; } /* Flush the SrcBuffer before the DMA transfer, in case the Data Cache * is enabled */ Xil_DCacheFlushRange((u32)TxBufferPtr, MAX_PKT_LEN); #ifdef __aarch64__ Xil_DCacheFlushRange((UINTPTR)RxBufferPtr, MAX_PKT_LEN); #endif /* Send a packet */ for(Index = 0; Index < Tries; Index ++) { Status = XAxiDma_SimpleTransfer(&AxiDma,(u32) RxBufferPtr, MAX_PKT_LEN, XAXIDMA_DEVICE_TO_DMA); if (Status != XST_SUCCESS) { return XST_FAILURE; } Status = XAxiDma_SimpleTransfer(&AxiDma,(u32) TxBufferPtr, MAX_PKT_LEN, XAXIDMA_DMA_TO_DEVICE); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Wait TX done and RX done */ while (!TxDone && !RxDone && !Error) { /* NOP */ } if (Error) { xil_printf("Failed test transmit%s done, " "receive%s done\r\n", TxDone? "":" not", RxDone? "":" not"); goto Done; } /* * Test finished, check data */ Status = CheckData(MAX_PKT_LEN, 0xC); if (Status != XST_SUCCESS) { xil_printf("Data check failed\r\n"); goto Done; } } xil_printf("AXI DMA interrupt example test passed\r\n"); /* Disable TX and RX Ring interrupts and return success */ DisableIntrSystem(&Intc, TX_INTR_ID, RX_INTR_ID); Done: xil_printf("--- Exiting main() --- \r\n"); return XST_SUCCESS; }
void AuxElement::SetExpirationTime(u32 NewExpirationTime) { ReplaceData(Data->ExpirationTime, NewExpirationTime, 4); CheckData(); }
/* This program is from mpich/tsuite/pt2pt and should be changed there only. It needs gcomm and dtype from mpich/tsuite, and can be run with any number of processes > 1. This version uses sendrecv and sendrecv_replace (but only in the head-to-head mode). */ int main( int argc, char **argv ) { MPI_Datatype *types; void **inbufs, **outbufs; char **names; int *counts, *bytesize, ntype; MPI_Comm comms[20]; int ncomm = 20, rank, np, partner, tag, count; int i, j, k, err, world_rank, errloc; MPI_Status status; char *obuf, *ibuf; MPI_Init( &argc, &argv ); AllocateForData( &types, &inbufs, &outbufs, &counts, &bytesize, &names, &ntype ); GenerateData( types, inbufs, outbufs, counts, bytesize, names, &ntype ); MPI_Comm_rank( MPI_COMM_WORLD, &world_rank ); MakeComms( comms, 20, &ncomm, 0 ); /* Test over a wide range of datatypes and communicators */ err = 0; for (i=0; i<ncomm; i++) { MPI_Comm_rank( comms[i], &rank ); MPI_Comm_size( comms[i], &np ); if (np < 2) continue; tag = i; if (rank == 0) partner = np - 1; if (rank == np - 1) partner = 0; for (j=0; j<ntype; j++) { if (world_rank == 0) fprintf( stdout, "Testing type %s\n", names[j] ); if (rank == 0 || rank == np - 1) { obuf = outbufs[j]; for (k=0; k<bytesize[j]; k++) obuf[k] = 0; MPI_Sendrecv( inbufs[j], counts[j], types[j], partner, tag, outbufs[j], counts[j], types[j], partner, tag, comms[i], &status ); /* Test correct */ MPI_Get_count( &status, types[j], &count ); if (count != counts[j]) { fprintf( stderr, "Error in counts (got %d expected %d) with type %s\n", count, counts[j], names[j] ); err++; } if (status.MPI_SOURCE != partner) { fprintf( stderr, "Error in source (got %d expected %d) with type %s\n", status.MPI_SOURCE, partner, names[j] ); err++; } if ((errloc = CheckData( inbufs[j], outbufs[j], bytesize[j] ))) { char *p1, *p2; fprintf( stderr, "Error in data with type %s (type %d on %d) at byte %d\n", names[j], j, world_rank, errloc - 1 ); p1 = (char *)inbufs[j]; p2 = (char *)outbufs[j]; fprintf( stderr, "Got %x expected %x\n", p1[errloc-1], p2[errloc-1] ); err++; } /* Now do sendrecv_replace */ obuf = outbufs[j]; ibuf = inbufs[j]; for (k=0; k<bytesize[j]; k++) obuf[k] = ibuf[k]; /* This would be a better test if the data was different... */ MPI_Sendrecv_replace( obuf, counts[j], types[j], partner, tag, partner, tag, comms[i], &status ); /* Test correct */ MPI_Get_count( &status, types[j], &count ); if (count != counts[j]) { fprintf( stderr, "Error in counts (got %d expected %d) with type %s\n", count, counts[j], names[j] ); err++; } if (status.MPI_SOURCE != partner) { fprintf( stderr, "Error in source (got %d expected %d) with type %s\n", status.MPI_SOURCE, partner, names[j] ); err++; } if ((errloc = CheckData( inbufs[j], outbufs[j], bytesize[j] ))) { char *p1, *p2; fprintf( stderr, "Error in data with type %s (type %d on %d) at byte %d\n", names[j], j, world_rank, errloc - 1 ); p1 = (char *)inbufs[j]; p2 = (char *)outbufs[j]; fprintf( stderr, "Got %x expected %x\n", p1[errloc-1], p2[errloc-1] ); err++; } } } } if (err > 0) { fprintf( stderr, "%d errors on %d\n", err, rank ); } FreeDatatypes( types, inbufs, outbufs, counts, bytesize, names, ntype ); FreeComms( comms, ncomm ); MPI_Finalize(); return err; }
void AuxElement::SetSourceEntity(char *NewSourceEntity) { ReplaceString(Data->SourceEntity, NewSourceEntity, 0); CheckData(); }
// // Updating either the GUI with data in memory or vice versa. // void CPageSetup::UpdateData(BOOL save_from_window) { if (save_from_window) { // Update all the combo box selections. result_type = m_CResultType.GetCurSel(); test_type = m_CTestType.GetCurSel(); worker_cycling.step_type = worker_cycling.step_sel_box.GetCurSel(); target_cycling.step_type = target_cycling.step_sel_box.GetCurSel(); queue_cycling.step_type = queue_cycling.step_sel_box.GetCurSel(); CheckData(ERunTimeHours, &hours); CheckData(ERunTimeMinutes, &minutes); CheckData(ERunTimeSeconds, &seconds); CheckData(ERampTime, &ramp_time); CheckData(EWorkerStep, &(worker_cycling.step), TRUE); CheckData(EDiskStep, &(target_cycling.step), TRUE); CheckData(EQueueStep, &(queue_cycling.step), TRUE); CheckData(EWorkerStart, &(worker_cycling.start), TRUE); CheckData(EDiskStart, &(target_cycling.start), TRUE); CheckData(EQueueStart, &(queue_cycling.start), TRUE); CheckData(EQueueEnd, &(queue_cycling.end), TRUE); if (GetCheckedRadioButton(RDiskSpawnCPUs, RDiskSpawnUser) == RDiskSpawnCPUs) disk_worker_count = -1; else CheckData(EDiskWorkerCount, &disk_worker_count, FALSE); if (GetCheckedRadioButton(RNetSpawnCPUs, RNetSpawnUser) == RNetSpawnCPUs) net_worker_count = -1; else CheckData(ENetWorkerCount, &net_worker_count, FALSE); GetDlgItemText(ETestName, test_name); // Find all commas and replace with '-' test_name.Replace(',', '-'); } else { // Update all the combo box selections. m_CResultType.SetCurSel(result_type); m_CTestType.SetCurSel(test_type); worker_cycling.step_sel_box.SetCurSel(worker_cycling.step_type); target_cycling.step_sel_box.SetCurSel(target_cycling.step_type); queue_cycling.step_sel_box.SetCurSel(queue_cycling.step_type); // Enable/disable and label cycling controls. OnSelchangeCTestType(); SetStepTypeLabel(TWorkerStep, worker_cycling.step_type); SetStepTypeLabel(TDiskStep, target_cycling.step_type); SetStepTypeLabel(TQueueStep, queue_cycling.step_type); // Update the run time and other default information. SetDlgItemInt(ERunTimeHours, hours, FALSE); SetDlgItemInt(ERunTimeMinutes, minutes, FALSE); SetDlgItemInt(ERunTimeSeconds, seconds, FALSE); if (disk_worker_count == -1) { CheckRadioButton(RDiskSpawnCPUs, RDiskSpawnUser, RDiskSpawnCPUs); m_EDiskWorkerCount.EnableWindow(FALSE); } else { CheckRadioButton(RDiskSpawnCPUs, RDiskSpawnUser, RDiskSpawnUser); m_EDiskWorkerCount.EnableWindow(TRUE); SetDlgItemInt(EDiskWorkerCount, disk_worker_count, FALSE); } if (net_worker_count == -1) { CheckRadioButton(RNetSpawnCPUs, RNetSpawnUser, RNetSpawnCPUs); m_ENetWorkerCount.EnableWindow(FALSE); } else { CheckRadioButton(RNetSpawnCPUs, RNetSpawnUser, RNetSpawnUser); m_ENetWorkerCount.EnableWindow(TRUE); SetDlgItemInt(ENetWorkerCount, net_worker_count, FALSE); } SetDlgItemInt(ERampTime, ramp_time, FALSE); // Set the displayed value for the step size and start values. SetDlgItemInt(EWorkerStep, worker_cycling.step, FALSE); SetDlgItemInt(EDiskStep, target_cycling.step, FALSE); SetDlgItemInt(EQueueStep, queue_cycling.step, FALSE); SetDlgItemInt(EWorkerStart, worker_cycling.start, FALSE); SetDlgItemInt(EDiskStart, target_cycling.start, FALSE); SetDlgItemInt(EQueueStart, queue_cycling.start, FALSE); SetDlgItemInt(EQueueEnd, queue_cycling.end, FALSE); // Set the test name. SetDlgItemText(ETestName, test_name); UpdateWindow(); } }
void AuxElement::SetSourceObject(char *NewSourceObject) { ReplaceString(Data->SourceObject, NewSourceObject, 1); CheckData(); }
bool GeneticAlgorithm::CreateTimetable(int stop, float infeasibilitiesWeight, float didacticDissatisfactionWeight, float organizationalDissatisfactionWeight, int mutationGenSize, float crossoverProbability) { finished = false; if(!CheckData()) { std::cout << "Bledne dane wejsciowe!" << std::endl; return false; } float min = std::numeric_limits<float>::max(); char *** solution = new char **[teachers_count]; for (int i = 0; i < teachers_count; i++) { solution[i] = new char*[days]; for (int j = 0; j < days; j++) { solution[i][j] = new char[hours_per_day]; } } int it = 0; int seed = time(NULL); while(it < stop) { std::cout << "New population cycle " << it << std::endl; srand(seed++); int iteration = 0; Initialize(); for(int i = 0; i < population_size; ++i) { Filter(timetables[i]); } for(; it < stop; ++it) { std::cout << it << std::endl; float *initial_fitness = CalculateObjectiveFunction(timetables, population_size, infeasibilitiesWeight, didacticDissatisfactionWeight, organizationalDissatisfactionWeight); std::vector<char***> new_population = Reproduction(initial_fitness); Crossover(new_population, crossoverProbability, infeasibilitiesWeight, didacticDissatisfactionWeight, organizationalDissatisfactionWeight); float *new_fitness = CalculateObjectiveFunction(new_population.data(), new_population.size(), infeasibilitiesWeight, didacticDissatisfactionWeight, organizationalDissatisfactionWeight); Succession(initial_fitness, new_fitness, new_population); delete [] initial_fitness; delete [] new_fitness; for (int individual = 0; individual < population_size; individual++) { ApplyMutationOfOrder(individual,mutationGenSize); ApplyDayMutation(individual); Filter(timetables[individual]); } float * results = CalculateObjectiveFunction(timetables, population_size, infeasibilitiesWeight, didacticDissatisfactionWeight, organizationalDissatisfactionWeight); int idx = -1; for (int i = 0; i < population_size; i++) { if(results[i] < min) { min = results[i]; idx = i; } } if(idx > -1) { for (int i = 0; i < teachers_count; i++) { for (int j = 0; j < days; j++) { for (int k = 0; k < hours_per_day; k++) { solution[i][j][k] = timetables[idx][i][j][k]; } } } std::cout << "Actual minimum: " << min << std::endl; iteration = 0; } else iteration++; if(iteration > max_iterations) break; } } std::ofstream result; result.open("result.pout"); std::cout << "Final minimum: " << std::endl << min << std::endl; std::cout << "Final solution:" << std::endl; PrintTimetable(solution, std::cout); PrintTimetable(solution, result); // put minimum data into file result << "Minimum: " << min; result.close(); finished = true; return true; }
void AuxSkillAbility::SetRadius(u32 NewRadius) { ReplaceData(Data->Radius, NewRadius, 4); CheckData(); }