BASKER_INLINE BaskerMatrix<Int,Entry,Exe_Space>::~BaskerMatrix() { Finalize(); }//end ~BaskerMatrix
SQClass::~SQClass() { REMOVE_FROM_CHAIN(&_sharedstate->_gc_chain, this); Finalize(); }
bool LightingTechnique::Init() { if (!Technique::Init()) { return false; } if (!AddShader(GL_VERTEX_SHADER, "lighting.vs")) { return false; } if (!AddShader(GL_FRAGMENT_SHADER, "lighting.fs")) { return false; } if (!Finalize()) { return false; } m_WVPLocation = GetUniformLocation("gWVP"); m_WorldMatrixLocation = GetUniformLocation("gWorld"); m_samplerLocation = GetUniformLocation("gSampler"); m_eyeWorldPosLocation = GetUniformLocation("gEyeWorldPos"); m_dirLightLocation.Color = GetUniformLocation("gDirectionalLight.Base.Color"); m_dirLightLocation.AmbientIntensity = GetUniformLocation("gDirectionalLight.Base.AmbientIntensity"); m_dirLightLocation.Direction = GetUniformLocation("gDirectionalLight.Direction"); m_dirLightLocation.DiffuseIntensity = GetUniformLocation("gDirectionalLight.Base.DiffuseIntensity"); m_matSpecularIntensityLocation = GetUniformLocation("gMatSpecularIntensity"); m_matSpecularPowerLocation = GetUniformLocation("gSpecularPower"); m_numPointLightsLocation = GetUniformLocation("gNumPointLights"); for (unsigned int i = 0; i < ARRAY_SIZE_IN_ELEMENTS(m_pointLightsLocation); i++) { char Name[128]; memset(Name, 0, sizeof(Name)); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Base.Color", i); m_pointLightsLocation[i].Color = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Base.AmbientIntensity", i); m_pointLightsLocation[i].AmbientIntensity = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Position", i); m_pointLightsLocation[i].Position = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Base.DiffuseIntensity", i); m_pointLightsLocation[i].DiffuseIntensity = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Atten.Constant", i); m_pointLightsLocation[i].Atten.Constant = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Atten.Linear", i); m_pointLightsLocation[i].Atten.Linear = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Atten.Exp", i); m_pointLightsLocation[i].Atten.Exp = GetUniformLocation(Name); if (m_pointLightsLocation[i].Color == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].AmbientIntensity == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Position == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].DiffuseIntensity == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Atten.Constant == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Atten.Linear == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Atten.Exp == INVALID_UNIFORM_LOCATION) { return false; } } if (m_dirLightLocation.AmbientIntensity == INVALID_UNIFORM_LOCATION || m_WVPLocation == INVALID_UNIFORM_LOCATION || m_WorldMatrixLocation == INVALID_UNIFORM_LOCATION || m_samplerLocation == INVALID_UNIFORM_LOCATION || m_eyeWorldPosLocation == INVALID_UNIFORM_LOCATION || m_dirLightLocation.Color == INVALID_UNIFORM_LOCATION || m_dirLightLocation.DiffuseIntensity == INVALID_UNIFORM_LOCATION || m_dirLightLocation.Direction == INVALID_UNIFORM_LOCATION || m_matSpecularIntensityLocation == INVALID_UNIFORM_LOCATION || m_matSpecularPowerLocation == INVALID_UNIFORM_LOCATION || m_numPointLightsLocation == INVALID_UNIFORM_LOCATION) { return false; } return true; }
Engine::~Engine() { Finalize(); }
void unload(void) { Finalize(); }
void parseArg( int argc,char **argv ) { int i; int arg_i; /*char *alpha_arg = NULL;*/ if (isMasterProc()) { printf("\nWELCOME TO WH-TEST\n\n"); printf("G. Weiss and A. von Haeseler (2003) Testing substitution models\n"); printf("within a phylogenetic tree. Mol. Biol. Evol, 20(4):572-578\n\n"); #ifdef PARALLEL printf("You are running MPI parallel version with %d processes\n\n", mpi_size); #endif printf("Program was called with:\n"); for ( i = 0; i < argc; i++ ) printf ( "%s ",argv[i] ); printf ( "\n\n" ); } simulation = 1000; current_sim = 0; alpha = 100; datei_name[0] = 0; p_value_cutoff = 1.0; for (arg_i = 1; arg_i < argc; arg_i++) { if (strcmp(argv[arg_i], "-h") == 0) { usage(argv[0]); } else if (strcmp(argv[arg_i], "-s") == 0) { arg_i++; simulation = atoi ( argv[arg_i] ); } else if (strcmp(argv[arg_i], "-t") == 0) { arg_i++; p_value_cutoff = atof ( argv[arg_i] ); } else if (strcmp(argv[arg_i], "-a") == 0) { arg_i++; /*alpha_arg = argv[arg_i];*/ alpha = atof ( argv[arg_i] ); } else if (strcmp(argv[arg_i], "-seed") == 0) { arg_i++; random_seed = atoi ( argv[arg_i] ); } else if (strcmp(argv[arg_i], "-i") == 0) { arg_i++; check_times = atoi ( argv[arg_i] ); } else if (strcmp(argv[arg_i], "-v") == 0) { /*verbose_mode = 1;*/ } else if (strcmp(argv[arg_i], "-wsim") == 0) { write_sim_result = 1; } else if (strcmp(argv[arg_i], "-wdist") == 0) { write_dist_matrix = 1; } else if (strcmp(argv[arg_i], "-fdist") == 0) { fix_distance = 1; } else if (argv[arg_i][0] != '-') { strcpy ( datei_name, argv[arg_i] ); strcpy ( ausgabe_report, datei_name ); strcat ( ausgabe_report, ".whtest" ); strcpy ( ausgabe_sim_result, ausgabe_report ); strcat ( ausgabe_sim_result, ".sim" ); strcpy ( ausgabe_dist, ausgabe_report ); strcat ( ausgabe_dist, ".dist" ); } else { if (isMasterProc()) printf("Unrecognized %s option, run with '-h' for help\n", argv[arg_i]); Finalize(1); } } if (datei_name[0] == 0) { printf("ERROR: Missing input alignment file.\n\n"); usage(argv[0]); } if (simulation <= 0 || simulation > 10000) { if (isMasterProc()) fprintf ( stderr,"wrong #simulations: %d\nbetween 1 and 10000 please\n", simulation); Finalize( 1 ); } if (alpha < 0.01 || alpha > 100.0) { if (isMasterProc()) fprintf ( stderr,"wrong alpha: %f\nbetween 0.01 and 100 please\n", alpha); Finalize ( 1 ); } if (check_times < 0) { if (isMasterProc()) fprintf ( stderr,"wrong time interval: %d\npositive number please\n", check_times); Finalize(1); } if (isMasterProc()) { printf("Input file: %s\n", datei_name); printf("Number of simulations: %d\n", simulation); printf("Gamma shape alpha: %f\n", alpha); } }
void DOMStorageDBThread::DBOperation::PerformAndFinalize(DOMStorageDBThread* aThread) { Finalize(Perform(aThread)); }
bool LightingTechnique::Init() { if (!Technique::Init()) { return false; } if (!AddShader(GL_VERTEX_SHADER, "../tutorial45/shaders/lighting.vs")) { return false; } if (!AddShader(GL_FRAGMENT_SHADER, "../tutorial45/shaders/lighting.fs")) { return false; } if (!Finalize()) { return false; } m_shaderTypeLocation = GetUniformLocation("gShaderType"); m_WVPLocation = GetUniformLocation("gWVP"); m_WorldMatrixLocation = GetUniformLocation("gWorld"); m_colorTextureLocation = GetUniformLocation("gColorMap"); m_aoTextureLocation = GetUniformLocation("gAOMap"); m_eyeWorldPosLocation = GetUniformLocation("gEyeWorldPos"); m_dirLightLocation.Color = GetUniformLocation("gDirectionalLight.Base.Color"); m_dirLightLocation.AmbientIntensity = GetUniformLocation("gDirectionalLight.Base.AmbientIntensity"); m_dirLightLocation.Direction = GetUniformLocation("gDirectionalLight.Direction"); m_dirLightLocation.DiffuseIntensity = GetUniformLocation("gDirectionalLight.Base.DiffuseIntensity"); m_matSpecularIntensityLocation = GetUniformLocation("gMatSpecularIntensity"); m_matSpecularPowerLocation = GetUniformLocation("gSpecularPower"); m_numPointLightsLocation = GetUniformLocation("gNumPointLights"); m_numSpotLightsLocation = GetUniformLocation("gNumSpotLights"); m_screenSizeLocation = GetUniformLocation("gScreenSize"); if (m_shaderTypeLocation == INVALID_UNIFORM_LOCATION || m_dirLightLocation.AmbientIntensity == INVALID_UNIFORM_LOCATION || m_WVPLocation == INVALID_UNIFORM_LOCATION || m_WorldMatrixLocation == INVALID_UNIFORM_LOCATION || m_colorTextureLocation == INVALID_UNIFORM_LOCATION || m_aoTextureLocation == INVALID_UNIFORM_LOCATION || m_eyeWorldPosLocation == INVALID_UNIFORM_LOCATION || m_dirLightLocation.Color == INVALID_UNIFORM_LOCATION || m_dirLightLocation.DiffuseIntensity == INVALID_UNIFORM_LOCATION || m_dirLightLocation.Direction == INVALID_UNIFORM_LOCATION || m_matSpecularIntensityLocation == INVALID_UNIFORM_LOCATION || m_matSpecularPowerLocation == INVALID_UNIFORM_LOCATION || m_numPointLightsLocation == INVALID_UNIFORM_LOCATION || m_screenSizeLocation == INVALID_UNIFORM_LOCATION || m_numSpotLightsLocation == INVALID_UNIFORM_LOCATION) { // return false; } for (uint i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_pointLightsLocation) ; i++) { char Name[128]; memset(Name, 0, sizeof(Name)); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Base.Color", i); m_pointLightsLocation[i].Color = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Base.AmbientIntensity", i); m_pointLightsLocation[i].AmbientIntensity = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Position", i); m_pointLightsLocation[i].Position = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Base.DiffuseIntensity", i); m_pointLightsLocation[i].DiffuseIntensity = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Atten.Constant", i); m_pointLightsLocation[i].Atten.Constant = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Atten.Linear", i); m_pointLightsLocation[i].Atten.Linear = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Atten.Exp", i); m_pointLightsLocation[i].Atten.Exp = GetUniformLocation(Name); if (m_pointLightsLocation[i].Color == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].AmbientIntensity == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Position == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].DiffuseIntensity == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Atten.Constant == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Atten.Linear == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Atten.Exp == INVALID_UNIFORM_LOCATION) { return false; } } for (uint i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_spotLightsLocation) ; i++) { char Name[128]; memset(Name, 0, sizeof(Name)); SNPRINTF(Name, sizeof(Name), "gSpotLights[%d].Base.Base.Color", i); m_spotLightsLocation[i].Color = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gSpotLights[%d].Base.Base.AmbientIntensity", i); m_spotLightsLocation[i].AmbientIntensity = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gSpotLights[%d].Base.Position", i); m_spotLightsLocation[i].Position = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gSpotLights[%d].Direction", i); m_spotLightsLocation[i].Direction = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gSpotLights[%d].Cutoff", i); m_spotLightsLocation[i].Cutoff = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gSpotLights[%d].Base.Base.DiffuseIntensity", i); m_spotLightsLocation[i].DiffuseIntensity = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gSpotLights[%d].Base.Atten.Constant", i); m_spotLightsLocation[i].Atten.Constant = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gSpotLights[%d].Base.Atten.Linear", i); m_spotLightsLocation[i].Atten.Linear = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gSpotLights[%d].Base.Atten.Exp", i); m_spotLightsLocation[i].Atten.Exp = GetUniformLocation(Name); if (m_spotLightsLocation[i].Color == INVALID_UNIFORM_LOCATION || m_spotLightsLocation[i].AmbientIntensity == INVALID_UNIFORM_LOCATION || m_spotLightsLocation[i].Position == INVALID_UNIFORM_LOCATION || m_spotLightsLocation[i].Direction == INVALID_UNIFORM_LOCATION || m_spotLightsLocation[i].Cutoff == INVALID_UNIFORM_LOCATION || m_spotLightsLocation[i].DiffuseIntensity == INVALID_UNIFORM_LOCATION || m_spotLightsLocation[i].Atten.Constant == INVALID_UNIFORM_LOCATION || m_spotLightsLocation[i].Atten.Linear == INVALID_UNIFORM_LOCATION || m_spotLightsLocation[i].Atten.Exp == INVALID_UNIFORM_LOCATION) { return false; } } Enable(); glUniform1i(m_aoTextureLocation, AO_TEXTURE_UNIT_INDEX); glUniform1i(m_colorTextureLocation, COLOR_TEXTURE_UNIT_INDEX); return true; }
void ptSimpleRectInteraction::mouseAction(QMouseEvent* event) { switch (event->type()) { // left button press case QEvent::MouseButtonPress: { if (event->button() == Qt::LeftButton) { event->accept(); assert(m_RectItem == NULL); // map viewport coords to scene coords QPointF pos(FView->mapToScene(event->pos())); m_Rect->setTopLeft(pos); m_Rect->setBottomRight(pos); QPen pen(QColor(150, 150, 150)); m_RectItem = FView->scene()->addRect(*m_Rect, pen); FView->repaint(); m_NowDragging = 1; } break; } // left button release case QEvent::MouseButtonRelease: { if (event->button() == Qt::LeftButton) { event->accept(); Finalize(stSuccess); } break; } // mouse move case QEvent::MouseMove: { if (m_NowDragging) { event->accept(); // move rectangle if (m_CtrlPressed > 0) { m_DragDelta->setP2(event->pos()); qreal dx = m_DragDelta->dx() / FView->transform().m11(); qreal dy = m_DragDelta->dy() / FView->transform().m11(); m_Rect->moveTo(qBound(0.0, m_Rect->left() + dx, FView->scene()->sceneRect().width() - m_Rect->width()), qBound(0.0, m_Rect->top() + dy, FView->scene()->sceneRect().height() - m_Rect->height()) ); m_DragDelta->setP1(event->pos()); m_RectItem->setRect(*m_Rect); FView->repaint(); // change rectangle size } else { QPointF point = FView->mapToScene(event->pos()); m_Rect->setRight(qBound(0.0, point.x(), FView->scene()->sceneRect().right())); m_Rect->setBottom(qBound(0.0, point.y(), FView->scene()->sceneRect().bottom())); m_RectItem->setRect(m_Rect->normalized()); FView->repaint(); } } break; } default: { assert(!"Wrong event type"); break; } } //switch }
/////////////////////// // Main program entry /////////////////////// int main(int argc, char** argv) { unsigned int max_iters, Nx, Ny, Nz, blockX, blockY, blockZ; int rank, numberOfProcesses; if (argc == 8) { Nx = atoi(argv[1]); Ny = atoi(argv[2]); Nz = atoi(argv[3]); max_iters = atoi(argv[4]); blockX = atoi(argv[5]); blockY = atoi(argv[6]); blockZ = atoi(argv[7]); } else { printf("Usage: %s nx ny nz i block_x block_y block_z\n", argv[0]); exit(1); } InitializeMPI(&argc, &argv, &rank, &numberOfProcesses); AssignDevices(rank); ECCCheck(rank); // Define constants const _DOUBLE_ L = 1.0; const _DOUBLE_ h = L/(Nx+1); const _DOUBLE_ dt = h*h/6.0; const _DOUBLE_ beta = dt/(h*h); const _DOUBLE_ c0 = beta; const _DOUBLE_ c1 = (1-6*beta); // Copy constants to Constant Memory on the GPUs CopyToConstantMemory(c0, c1); // Decompose along the z-axis const int _Nz = Nz/numberOfProcesses; const int dt_size = sizeof(_DOUBLE_); // Host memory allocations _DOUBLE_ *u_new, *u_old; _DOUBLE_ *h_Uold; u_new = (_DOUBLE_*)malloc(sizeof(_DOUBLE_)*(Nx+2)*(Ny+2)*(Nz+2)); u_old = (_DOUBLE_*)malloc(sizeof(_DOUBLE_)*(Nx+2)*(Ny+2)*(Nz+2)); if (rank == 0) { h_Uold = (_DOUBLE_*)malloc(sizeof(_DOUBLE_)*(Nx+2)*(Ny+2)*(Nz+2)); } init(u_old, u_new, h, Nx, Ny, Nz); // Allocate and generate host subdomains _DOUBLE_ *h_s_Uolds, *h_s_Unews, *h_s_rbuf[numberOfProcesses]; _DOUBLE_ *left_send_buffer, *left_receive_buffer; _DOUBLE_ *right_send_buffer, *right_receive_buffer; h_s_Unews = (_DOUBLE_*)malloc(sizeof(_DOUBLE_)*(Nx+2)*(Ny+2)*(_Nz+2)); h_s_Uolds = (_DOUBLE_*)malloc(sizeof(_DOUBLE_)*(Nx+2)*(Ny+2)*(_Nz+2)); #if defined(DEBUG) || defined(_DEBUG) if (rank == 0) { for (int i = 0; i < numberOfProcesses; i++) { h_s_rbuf[i] = (_DOUBLE_*)malloc(sizeof(_DOUBLE_)*(Nx+2)*(Ny+2)*(_Nz+2)); checkCuda(cudaHostAlloc((void**)&h_s_rbuf[i], dt_size*(Nx+2)*(Ny+2)*(_Nz+2), cudaHostAllocPortable)); } } #endif right_send_buffer = (_DOUBLE_*)malloc(sizeof(_DOUBLE_)*(Nx+2)*(Ny+2)*(_GC_DEPTH)); left_send_buffer = (_DOUBLE_*)malloc(sizeof(_DOUBLE_)*(Nx+2)*(Ny+2)*(_GC_DEPTH)); right_receive_buffer = (_DOUBLE_*)malloc(sizeof(_DOUBLE_)*(Nx+2)*(Ny+2)*(_GC_DEPTH)); left_receive_buffer = (_DOUBLE_*)malloc(sizeof(_DOUBLE_)*(Nx+2)*(Ny+2)*(_GC_DEPTH)); checkCuda(cudaHostAlloc((void**)&h_s_Unews, dt_size*(Nx+2)*(Ny+2)*(_Nz+2), cudaHostAllocPortable)); checkCuda(cudaHostAlloc((void**)&h_s_Uolds, dt_size*(Nx+2)*(Ny+2)*(_Nz+2), cudaHostAllocPortable)); checkCuda(cudaHostAlloc((void**)&right_send_buffer, dt_size*(Nx+2)*(Ny+2)*(_GC_DEPTH), cudaHostAllocPortable)); checkCuda(cudaHostAlloc((void**)&left_send_buffer, dt_size*(Nx+2)*(Ny+2)*(_GC_DEPTH), cudaHostAllocPortable)); checkCuda(cudaHostAlloc((void**)&right_receive_buffer, dt_size*(Nx+2)*(Ny+2)*(_GC_DEPTH), cudaHostAllocPortable)); checkCuda(cudaHostAlloc((void**)&left_receive_buffer, dt_size*(Nx+2)*(Ny+2)*(_GC_DEPTH), cudaHostAllocPortable)); init_subdomain(h_s_Uolds, u_old, Nx, Ny, _Nz, rank); // GPU Memory Operations size_t pitch_bytes, pitch_gc_bytes; _DOUBLE_ *d_s_Unews, *d_s_Uolds; _DOUBLE_ *d_right_send_buffer, *d_left_send_buffer; _DOUBLE_ *d_right_receive_buffer, *d_left_receive_buffer; checkCuda(cudaMallocPitch((void**)&d_s_Uolds, &pitch_bytes, dt_size*(Nx+2), (Ny+2)*(_Nz+2))); checkCuda(cudaMallocPitch((void**)&d_s_Unews, &pitch_bytes, dt_size*(Nx+2), (Ny+2)*(_Nz+2))); checkCuda(cudaMallocPitch((void**)&d_left_send_buffer, &pitch_gc_bytes, dt_size*(Nx+2), (Ny+2)*(_GC_DEPTH))); checkCuda(cudaMallocPitch((void**)&d_left_receive_buffer, &pitch_gc_bytes, dt_size*(Nx+2), (Ny+2)*(_GC_DEPTH))); checkCuda(cudaMallocPitch((void**)&d_right_send_buffer, &pitch_gc_bytes, dt_size*(Nx+2), (Ny+2)*(_GC_DEPTH))); checkCuda(cudaMallocPitch((void**)&d_right_receive_buffer, &pitch_gc_bytes, dt_size*(Nx+2), (Ny+2)*(_GC_DEPTH))); // Copy subdomains from host to device and get walltime double HtD_timer = 0.; MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD)); HtD_timer -= MPI_Wtime(); MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD)); checkCuda(cudaMemcpy2D(d_s_Uolds, pitch_bytes, h_s_Uolds, dt_size*(Nx+2), dt_size*(Nx+2), ((Ny+2)*(_Nz+2)), cudaMemcpyDefault)); checkCuda(cudaMemcpy2D(d_s_Unews, pitch_bytes, h_s_Unews, dt_size*(Nx+2), dt_size*(Nx+2), ((Ny+2)*(_Nz+2)), cudaMemcpyDefault)); MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD)); HtD_timer += MPI_Wtime(); MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD)); int pitch = pitch_bytes/dt_size; int gc_pitch = pitch_gc_bytes/dt_size; // GPU kernel launch parameters dim3 threads_per_block(blockX, blockY, blockZ); unsigned int blocksInX = getBlock(Nx, blockX); unsigned int blocksInY = getBlock(Ny, blockY); unsigned int blocksInZ = getBlock(_Nz-2, k_loop); dim3 thread_blocks(blocksInX, blocksInY, blocksInZ); dim3 thread_blocks_halo(blocksInX, blocksInY); // MPI Status MPI_Status status[numberOfProcesses]; MPI_Request gather_send_request[numberOfProcesses]; MPI_Request right_send_request[numberOfProcesses], left_send_request[numberOfProcesses]; MPI_Request right_receive_request[numberOfProcesses], left_receive_request[numberOfProcesses]; double compute_timer = 0.; MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD)); compute_timer -= MPI_Wtime(); MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD)); for(unsigned int iterations = 0; iterations < max_iters; iterations++) { // Compute inner nodes ComputeInnerPoints(thread_blocks, threads_per_block, d_s_Unews, d_s_Uolds, pitch, Nx, Ny, _Nz); // Copy right boundary data to host if (rank < 1) { CopyBoundaryRegionToGhostCell(thread_blocks_halo, threads_per_block, d_s_Unews, d_right_send_buffer, Nx, Ny, _Nz, pitch, gc_pitch, 0); checkCuda(cudaMemcpy2D(right_send_buffer, dt_size*(Nx+2), d_right_send_buffer, pitch_gc_bytes, dt_size*(Nx+2), (Ny+2)*(_GC_DEPTH), cudaMemcpyDefault)); MPI_CHECK(MPI_Isend(right_send_buffer, (Nx+2)*(Ny+2)*(_GC_DEPTH), MPI_DOUBLE, 1, 0, MPI_COMM_WORLD, &right_send_request[rank])); } else { CopyBoundaryRegionToGhostCell(thread_blocks_halo, threads_per_block, d_s_Unews, d_left_send_buffer, Nx, Ny, _Nz, pitch, gc_pitch, 1); checkCuda(cudaMemcpy2D(left_send_buffer, dt_size*(Nx+2), d_left_send_buffer, pitch_gc_bytes, dt_size*(Nx+2), (Ny+2)*(_GC_DEPTH), cudaMemcpyDefault)); MPI_CHECK(MPI_Isend(left_send_buffer, (Nx+2)*(Ny+2)*(_GC_DEPTH), MPI_DOUBLE, 0, 1, MPI_COMM_WORLD, &left_send_request[rank])); } // Receive data from device 0 if (rank > 0) { MPI_CHECK(MPI_Irecv(left_receive_buffer, (Nx+2)*(Ny+2)*(_GC_DEPTH), MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &left_receive_request[rank])); } else { MPI_CHECK(MPI_Irecv(right_receive_buffer, (Nx+2)*(Ny+2)*(_GC_DEPTH), MPI_DOUBLE, 1, 1, MPI_COMM_WORLD, &right_receive_request[rank])); } if (rank > 0) { MPI_CHECK(MPI_Wait(&left_receive_request[rank], MPI_STATUS_IGNORE)); checkCuda(cudaMemcpy2D(d_left_receive_buffer, pitch_gc_bytes, left_receive_buffer, dt_size*(Nx+2), dt_size*(Nx+2), ((Ny+2)*(_GC_DEPTH)), cudaMemcpyDefault)); CopyGhostCellToBoundaryRegion(thread_blocks_halo, threads_per_block, d_s_Unews, d_left_receive_buffer, Nx, Ny, _Nz, pitch, gc_pitch, 1); } else { MPI_CHECK(MPI_Wait(&right_receive_request[rank], MPI_STATUS_IGNORE)); checkCuda(cudaMemcpy2D(d_right_receive_buffer, pitch_gc_bytes, right_receive_buffer, dt_size*(Nx+2), dt_size*(Nx+2), ((Ny+2)*(_GC_DEPTH)), cudaMemcpyDefault)); CopyGhostCellToBoundaryRegion(thread_blocks_halo, threads_per_block, d_s_Unews, d_right_receive_buffer, Nx, Ny, _Nz, pitch, gc_pitch, 0); } if (rank < 1) { MPI_CHECK(MPI_Wait(&right_send_request[rank], MPI_STATUS_IGNORE)); } else { MPI_CHECK(MPI_Wait(&left_send_request[rank], MPI_STATUS_IGNORE)); } // Swap pointers on the host checkCuda(cudaDeviceSynchronize()); swap(_DOUBLE_*, d_s_Unews, d_s_Uolds); } MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD)); compute_timer += MPI_Wtime(); MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD)); // Copy data from device to host double DtH_timer = 0; MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD)); DtH_timer -= MPI_Wtime(); MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD)); checkCuda(cudaMemcpy2D(h_s_Uolds, dt_size*(Nx+2), d_s_Uolds, pitch_bytes, dt_size*(Nx+2), (Ny+2)*(_Nz+2), cudaMemcpyDefault)); MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD)); DtH_timer += MPI_Wtime(); MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD)); // Gather results from subdomains MPI_CHECK(MPI_Isend(h_s_Uolds, (Nx+2)*(Ny+2)*(_Nz+2), MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &gather_send_request[rank])); if (rank == 0) { for (int i = 0; i < numberOfProcesses; i++) { MPI_CHECK(MPI_Recv(h_s_rbuf[i], (Nx+2)*(Ny+2)*(_Nz+2), MPI_DOUBLE, i, 0, MPI_COMM_WORLD, &status[rank])); merge_domains(h_s_rbuf[i], h_Uold, Nx, Ny, _Nz, i); } } // Calculate on host #if defined(DEBUG) || defined(_DEBUG) if (rank == 0) { cpu_heat3D(u_new, u_old, c0, c1, max_iters, Nx, Ny, Nz); } #endif if (rank == 0) { float gflops = CalcGflops(compute_timer, max_iters, Nx, Ny, Nz); PrintSummary("3D Heat (7-pt)", "Plane sweeping", compute_timer, HtD_timer, DtH_timer, gflops, max_iters, Nx); _DOUBLE_ t = max_iters * dt; CalcError(h_Uold, u_old, t, h, Nx, Ny, Nz); } Finalize(); // Free device memory checkCuda(cudaFree(d_s_Unews)); checkCuda(cudaFree(d_s_Uolds)); checkCuda(cudaFree(d_right_send_buffer)); checkCuda(cudaFree(d_left_send_buffer)); checkCuda(cudaFree(d_right_receive_buffer)); checkCuda(cudaFree(d_left_receive_buffer)); // Free host memory checkCuda(cudaFreeHost(h_s_Unews)); checkCuda(cudaFreeHost(h_s_Uolds)); #if defined(DEBUG) || defined(_DEBUG) if (rank == 0) { for (int i = 0; i < numberOfProcesses; i++) { checkCuda(cudaFreeHost(h_s_rbuf[i])); } free(h_Uold); } #endif checkCuda(cudaFreeHost(left_send_buffer)); checkCuda(cudaFreeHost(left_receive_buffer)); checkCuda(cudaFreeHost(right_send_buffer)); checkCuda(cudaFreeHost(right_receive_buffer)); checkCuda(cudaDeviceReset()); free(u_old); free(u_new); return 0; }
CWaveEncoder::~CWaveEncoder() { if ((mbIgnoreOutputFileNull) || (mpfOutputStream != NULL)) { Finalize(); } }
SerialCommunication::~SerialCommunication(void) { Finalize(); }
/// /// Destructor /// virtual ~DeliminatedReport() { Finalize(); }
/** * Should be called before executing a script */ void XBPython::Initialize() { CLog::Log(LOGINFO, "initializing python engine. "); CSingleLock lock(m_critSection); m_iDllScriptCounter++; if (!m_bInitialized) { // first we check if all necessary files are installed #ifndef _LINUX if(!FileExist("special://xbmc/system/python/DLLs/_socket.pyd") || !FileExist("special://xbmc/system/python/DLLs/_ssl.pyd") || !FileExist("special://xbmc/system/python/DLLs/bz2.pyd") || !FileExist("special://xbmc/system/python/DLLs/pyexpat.pyd") || !FileExist("special://xbmc/system/python/DLLs/select.pyd") || !FileExist("special://xbmc/system/python/DLLs/unicodedata.pyd")) { CLog::Log(LOGERROR, "Python: Missing files, unable to execute script"); Finalize(); return; } #endif // Info about interesting python envvars available // at http://docs.python.org/using/cmdline.html#environment-variables #if !defined(_WIN32) /* PYTHONOPTIMIZE is set off intentionally when using external Python. Reason for this is because we cannot be sure what version of Python was used to compile the various Python object files (i.e. .pyo, .pyc, etc.). */ // check if we are running as real xbmc.app or just binary if (!CUtil::GetFrameworksPath(true).IsEmpty()) { // using external python, it's build looking for xxx/lib/python2.6 // so point it to frameworks which is where python2.6 is located setenv("PYTHONHOME", _P("special://frameworks").c_str(), 1); setenv("PYTHONPATH", _P("special://frameworks").c_str(), 1); CLog::Log(LOGDEBUG, "PYTHONHOME -> %s", _P("special://frameworks").c_str()); CLog::Log(LOGDEBUG, "PYTHONPATH -> %s", _P("special://frameworks").c_str()); } setenv("PYTHONCASEOK", "1", 1); //This line should really be removed #elif defined(_WIN32) // because the third party build of python is compiled with vs2008 we need // a hack to set the PYTHONPATH // buf is corrupted after putenv and might need a strdup but it seems to // work this way CStdString buf; buf = "PYTHONPATH=" + _P("special://xbmc/system/python/DLLs") + ";" + _P("special://xbmc/system/python/Lib"); pgwin32_putenv(buf.c_str()); buf = "PYTHONOPTIMIZE=1"; pgwin32_putenv(buf.c_str()); buf = "PYTHONHOME=" + _P("special://xbmc/system/python"); pgwin32_putenv(buf.c_str()); buf = "OS=win32"; pgwin32_putenv(buf.c_str()); #endif if (PyEval_ThreadsInitialized()) PyEval_AcquireLock(); else PyEval_InitThreads(); Py_Initialize(); PyEval_ReleaseLock(); // If this is not the first time we initialize Python, the interpreter // lock already exists and we need to lock it as PyEval_InitThreads // would not do that in that case. PyEval_AcquireLock(); char* python_argv[1] = { (char*)"" } ; PySys_SetArgv(1, python_argv); InitXBMCTypes(); InitGUITypes(); InitPluginTypes(); InitAddonTypes(); if (!(m_mainThreadState = PyThreadState_Get())) CLog::Log(LOGERROR, "Python threadstate is NULL."); PyEval_ReleaseLock(); m_bInitialized = true; } }
CDeinterlacer_DXVA::~CDeinterlacer_DXVA() { Finalize(); }
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // Name : 解放処理 // Description : 描画クラスを解放する // Arguments : None. // Returns : None. //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ void CGraphics::Release() { Finalize(); delete this; }
dxThreadPoolThreadInfo::~dxThreadPoolThreadInfo() { Finalize(); }
//============================================================================== // Brief : デストラクタ // Return : : // Arg : void : なし //============================================================================== Graphic::~Graphic( void ) { // 終了処理 Finalize(); }
//============================================================================== // Brief : デストラクタ // Return : : // Arg : void : なし //============================================================================== CameraStateDebug::~CameraStateDebug( void ) { // 終了処理 Finalize(); }
void Interrupt(Unit &u) {Finalize(u);}
void LootRoll::PlayerRolled(PlayerInfo* pInfo, uint8 choice) { if(m_NeedRolls.find(pInfo->guid) != m_NeedRolls.end() || m_GreedRolls.find(pInfo->guid) != m_GreedRolls.end() || m_DisenchantRolls.find(pInfo->guid) != m_DisenchantRolls.end()) return; // dont allow cheaters ItemPrototype* proto = ItemPrototypeStorage.LookupEntry(_itemid); if(proto == NULL) return; // Shouldn't happen. mLootLock.Acquire(); int roll = RandomUInt(99)+1; // create packet WorldPacket data(SMSG_LOOT_ROLL, 34); data << _guid << _slotid << uint64(pInfo->guid); data << _itemid << _randomsuffixid << _randompropertyid; if(!pInfo->m_loggedInPlayer) choice = PASS; bool acceptableroll = true; switch(choice) { case NEED: { if(pInfo->m_loggedInPlayer->CanNeedItem(proto)) { m_NeedRolls.insert( std::make_pair(pInfo->guid, roll) ); data << uint8(roll) << uint8(NEED); } else { m_passRolls.insert( pInfo->guid ); data << uint8(128) << uint8(128); } }break; case GREED: { m_GreedRolls.insert( std::make_pair(pInfo->guid, roll) ); data << uint8(roll) << uint8(GREED); }break; case DISENCHANT: { if(acceptableroll) { if(proto->DisenchantReqSkill < 0) acceptableroll = false; else if(pInfo->m_Group) acceptableroll = pInfo->m_Group->HasAcceptableDisenchanters(proto->DisenchantReqSkill); else acceptableroll = (pInfo->m_loggedInPlayer->_HasSkillLine(333) && (pInfo->m_loggedInPlayer->_GetSkillLineCurrent(333) > uint32(proto->DisenchantReqSkill))); } if(acceptableroll) { m_DisenchantRolls.insert( std::make_pair(pInfo->guid, roll) ); data << uint8(roll) << uint8(DISENCHANT); } else { m_passRolls.insert( pInfo->guid ); data << uint8(128) << uint8(128); } }break; default: //pass { m_passRolls.insert( pInfo->guid ); data << uint8(128) << uint8(128); }break; } data << uint8(0); if(pInfo->m_Group) pInfo->m_Group->SendPacketToAll(&data); else if(pInfo->m_loggedInPlayer) pInfo->m_loggedInPlayer->GetSession()->SendPacket(&data); // check for early completion if(!--_remaining) { mLootLock.Release(); // so we can call the other lock in a sec. // kill event early //sEventMgr.RemoveEvents(this); Finalize(); return; } mLootLock.Release(); }
HRESULT CNktDvSpyMgr::Initialize(__in_z LPCWSTR szDatabasePathW, __in_z LPCWSTR szAgentPathW, __in DWORD dwFlags) { CNktAutoFastMutex cLock(&GetLockObject()); HRESULT hRes; NktInterlockedExchange(&nNextHookId, 0); //initialize shutdown locker hRes = cShutdownMtx.Initialize(); //set agent path if (SUCCEEDED(hRes)) { if (szAgentPathW != NULL && szAgentPathW[0] != 0) { if (cStrAgentPathW.Copy(szAgentPathW) != FALSE) hRes = CNktDvTools::FixFolderStr(cStrAgentPathW); else hRes = E_OUTOFMEMORY; } else { hRes = CNktDvTools::GetModulePath(cStrAgentPathW, NULL); } } //load database(s) if (SUCCEEDED(hRes)) { HANDLE hFileMap; cDvDB_32.Release(); hRes = CNktDvEngDatabase::CreateMapping(&hFileMap, (szDatabasePathW != NULL) ? szDatabasePathW : L"", 32); if (SUCCEEDED(hRes)) { hRes = CNktDvEngDatabase::Get(&cDvDB_32, hFileMap, 32); if (FAILED(hRes)) ::CloseHandle(hFileMap); } } #if defined _M_X64 if (SUCCEEDED(hRes)) { HANDLE hFileMap; cDvDB_64.Release(); hRes = CNktDvEngDatabase::CreateMapping(&hFileMap, (szDatabasePathW != NULL) ? szDatabasePathW : L"", 64); if (SUCCEEDED(hRes)) { hRes = CNktDvEngDatabase::Get(&cDvDB_64, hFileMap, 64); if (FAILED(hRes)) ::CloseHandle(hFileMap); } } #endif //_M_X64 //init process handle manager if (SUCCEEDED(hRes)) { cProcHndlMgr.Release(); hRes = CNktDvProcessHandlesMgr::Get(&cProcHndlMgr); } //initialize process list updater if (SUCCEEDED(hRes)) hRes = cProcList.Initialize(); //initialize transport manager if (SUCCEEDED(hRes)) { SIZE_T nProcCount = CNktDvTools::GetProcessorsCount(); hRes = cTransport.Initialize(NKT_DV_TRANSPORTENGINE_WORKERTHREADS_PER_CPU * nProcCount, NKT_DV_TRANSPORTENGINE_DISPATCHERTHREADS_PER_CPU * nProcCount); } //initialize internal worker if (SUCCEEDED(hRes)) { hRes = (sDelayedHook.cAvailableEvent.Create(TRUE, FALSE) != FALSE) ? S_OK : E_OUTOFMEMORY; if (SUCCEEDED(hRes)) { if (Start() != FALSE) SetThreadName("Dv-SpyManagerMain"); else hRes = E_OUTOFMEMORY; } } //done if (FAILED(hRes)) Finalize(); return hRes; }
DBResult::~DBResult() { if (!m_finalized) Finalize(); }
//============================================================================== // Brief : デストラクタ // Return : : // Arg : void : なし //============================================================================== PolygonSignboard::~PolygonSignboard( void ) { // 終了処理 Finalize(); }
SQInstance::~SQInstance() { REMOVE_FROM_CHAIN(&_sharedstate->_gc_chain, this); if(_class){ Finalize(); } //if _class is null it was already finalized by the GC }
//--------------------------------------------------------------------------------------- // シーン解放 //--------------------------------------------------------------------------------------- void CGameOverScene::Release() { Finalize(); delete this; }
int TestPlaneSource(int argc, char *argv[]) { vtkMultiProcessController *controller=Initialize(&argc,&argv); int worldRank=controller->GetLocalProcessId(); int worldSize=controller->GetNumberOfProcesses(); // configure std::string dataRoot; std::string tempDir; std::string baseline; BroadcastConfiguration(controller,argc,argv,dataRoot,tempDir,baseline); std::string logFileName; logFileName=NativePath(tempDir+"/SciberQuestToolKit-TestPlaneSource.log"); vtkSQLog::GetGlobalInstance()->SetFileName(logFileName.c_str()); vtkSQLog::GetGlobalInstance()->SetGlobalLevel(1); // plane const int nResolutions=4; int resolution[nResolutions][2]={ {1,1,}, {537,1,}, {1,537,}, {127,67}, }; const int nDecomps=2; int decomp[nDecomps]={ vtkSQPlaneSource::DECOMP_TYPE_STRIPS, vtkSQPlaneSource::DECOMP_TYPE_PATCHES }; const char *decompName[nDecomps]={ "Strips", "Patches"}; int ext[6]={-1,1,-1,1,0,0}; int aTestFailed=0; for (int i=0; i<nResolutions; ++i) { for (int j=0; j<nDecomps; ++j) { int *res=resolution[i]; vtkSQPlaneSource *p=vtkSQPlaneSource::New(); p->SetOrigin(ext[0],ext[2],ext[4]); p->SetPoint1(ext[1],ext[2],ext[4]); p->SetPoint2(ext[0],ext[3],ext[4]); p->SetXResolution(res[0]); p->SetYResolution(res[1]); p->SetDecompType(decomp[j]); // process id vtkProcessIdScalars *pid=vtkProcessIdScalars::New(); pid->SetInputConnection(0,p->GetOutputPort(0)); p->Delete(); // execute GetParallelExec(worldRank, worldSize, pid, 0.0); pid->Update(); vtkPolyData *output=dynamic_cast<vtkPolyData*>(pid->GetOutput()); // rename resolution dependent arrays std::ostringstream oss; oss << "Decomp-" << decompName[j] << "-" << res[0] << "x" << res[1]; vtkDataArray *ids=output->GetPointData()->GetArray("ProcessId"); if (ids) { ids->SetName(oss.str().c_str()); } oss.str(""); oss << "TCoords-" << decompName[j] << "-" << res[0] << "x" << res[1]; vtkDataArray *tcoord=output->GetPointData()->GetTCoords(); if (tcoord) { tcoord->SetName(oss.str().c_str()); } int testStatus = SerialRender( controller, output, false, tempDir, baseline, "SciberQuestToolKit-TestPlaneSource", 300,300, 63,63,128, 0,0,0, 0,1,0, 1.25); if (testStatus==vtkTesting::FAILED) { aTestFailed=1; } pid->Delete(); } } return Finalize(controller,aTestFailed); }
CIconMenu::~CIconMenu() { Finalize(); }
uint8 *HmacHash::ComputeHash(BigNumber* bn) { HMAC_Update(&m_ctx, bn->AsByteArray().get(), bn->GetNumBytes()); Finalize(); return (uint8*)m_digest; }
sbAlbumArtService::~sbAlbumArtService() { Finalize(); }