Beispiel #1
0
int main(int argc, char** argv){
	int rank, processors;
	const int root = 0;
	size_t compute_size = 1 << 10, size = 1 << 11;

	int* a = malloc(sizeof(int) * size);
	int* b = malloc(sizeof(int) * size);
	MPI_Init(&argc, &argv);
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);

	if( rank == root ){
		int i = 0;
		while(i < size){
			a[i] = i+1;
			b[i] = i+1;
			i++;
		}
		a[i] = 0; b[i] = 0;
	}

	MPI_Bcast(a, size, MPI_INT, root, MPI_COMM_WORLD);
	MPI_Bcast(b, size, MPI_INT, root, MPI_COMM_WORLD);
	
	vectoradd(a + (compute_size*rank), b + (compute_size*rank), compute_size - 1);

	if( rank == root ){
		display(a);
	}

	free(a);free(b);
	MPI_Finalize();
	return 0;
}
Beispiel #2
0
int main() 
{
	int i;


	for( i=0; i<TOTAL_SIZE;i++)
	{
		A[i]=1;
		B[i]=1;
	}
	
#pragma TPPMODEL vectorAdd
{
#ifdef vectorAdd_DEFINED
	abstract_vectorAdd(A,B,C,TOTAL_SIZE);
#else
	 {
	 		vectoradd();
	 	}
#endif
}



	verify();
	return 0;
}
Beispiel #3
0
int main(int argc, char** argv){
	int array1[9] = {1,2,3,4,5,10,546,15,819};
	int array2[9] = {7,8,9,45,65,20,81,59,4};
	vectoradd(array1, array2, 10);
	int* ptr = array1;
	int* end = array1 + 9;
	while( ptr < end )
		printf("%d ",*ptr++);
	printf("\n");
	return 0;
}
Beispiel #4
0
void
setupworld ( world_t *world )
{
	int i;
	entity_t *e;
	vector2d_t angle,dir,verts[2];
	
	world->time = SDL_GetTicks();
	
	if(!world->playerentity)
	{
		if(!spawnplayer( world ))
			return;
	}
	for(i=0;i<world->numentities;i++)
	{
		e = &world->entities[i];
		
		if(e->think && world->time > e->nextthink)
		{
			void (*think)(world_t *w, struct entity_s *e);
			think = e->think;
			e->think = NULL;
			think(world,e);
		}
		
		/* don't need to add transparent stuff to the world */
		if(!e->texture)
			continue;
		if(e->follow)
			setfollowangle(world,e,&angle);
		else
			vectorcopy(&angle,&e->angle);

		vectorrot90( &angle, &dir );
		vectorscale( &dir, e->texture->width/2, &dir );
		vectorsubtract( &e->pos, &dir, &verts[0]);
		vectoradd( &e->pos, &dir, &verts[1]);
		
		addsprite(world->raycaster,verts,e->texture->height,e->vpos,
				SURFACE_NONE,e->texture);
	}

	/* copy over player view pos to raycaster */
	world->raycaster->currentplatform = world->playerentity->currentplatform;
	vectorcopy(&world->raycaster->viewpos,&world->playerentity->pos);
	vectorcopy(&world->raycaster->viewdir,&world->playerentity->angle);
	world->raycaster->eyelevel = world->playerentity->vpos+VIEW_HEIGHT;
}
Beispiel #5
0
JobPointer executeJob(JobPointer currentJob){

  int JobType = currentJob->JobType;

   // large switch
   switch(JobType){
      case 0:
	 addsleep(currentJob->params);
	 break;
      case 1:
	 vectoradd(currentJob->params);
	 break;
      case 2:
	 printf("Executing - %d\n", omp_get_thread_num());
	 matrix_mul(currentJob->params);
	 break;
   }
  return currentJob;
}
Beispiel #6
0
int main() 
{
	int i;


	for( i=0; i<TOTAL_SIZE;i++)
	{
		A[i]=1;
		B[i]=1;
	}
	#pragma tppmodel vectorAdd
	{
		vectoradd();
	}


	verify();
	return 0;
}
Beispiel #7
0
void	ft_impact(t_draw_suite *val, t_ray *ray, t_tool *t)
{
	val->impact->o = vectoradd(ray->o,
	vectorscale(val->curobject->dist, ray->d));
	find_normal(val->impact, val->curobject);
	vectornorm(val->impact->d);
	init_color(t, val->curobject->color, val->final_color);
	val->curlight = t->l_lights;
	while (val->curlight)
	{
		val->lightray->o = vectorcopy(val->curlight->o);
		val->lightray->d = vectorsub(val->impact->o, val->lightray->o);
		vectornorm(val->lightray->d);
		if ((val->curobject2 = intersection(t->l_objects,
						val->lightray)) && val->curobject2 == val->curobject)
			ft_impact2(val);
		val->curlight = val->curlight->next;
	}
}
int conf_check(LSCANCONF *conf)
{
	if(conf)
	{
		int status = 1;

		puts("[*] Проверяем указанные параметры на валидность");

		if(!conf->hosts.length)
		{
			puts("[-] Не задано ни одного хоста");
			status = 0;
		}

		if((conf->count < CONF_MIN_COUNT) || (conf->count > CONF_MAX_COUNT))
		{
			puts("[-] Безумное количество потоков сканирования!");
			status = 0;
		}

		if((conf->packets < CONF_MIN_PACKETS) || (conf->packets > CONF_MAX_PACKETS))
		{
			puts("[-] Безумное количество пинговочных пакетов!");
			status = 0;
		}

		if((conf->maxhosts < CONF_MIN_MAXHOSTS) || (conf->maxhosts > CONF_MAX_MAXHOSTS))
		{
			puts("[-] Безумное количество одновременно пингуемых хостов!");
			status = 0;
		}

		if((conf->timeout < CONF_MIN_TIMEOUT) || (conf->timeout > CONF_MAX_TIMEOUT))
		{
			puts("[-] Безумный таймаут пинга!");
			status = 0;
		}

		if((conf->delay < CONF_MIN_DELAY) || (conf->delay > CONF_MAX_DELAY))
		{
			puts("[-] Безумная задержка между подключениями к хосту!");
			status = 0;
		}

		if((conf->iotimeout < CONF_MIN_IOTIMEOUT) || (conf->delay > CONF_MAX_IOTIMEOUT))
		{
			puts("[-] Безумный таймаут ввода-вывода!");
			status = 0;
		}

		if((conf->retrycount < CONF_MIN_RETRYCOUNT) || (conf->retrycount > CONF_MAX_RETRYCOUNT))
		{
			puts("[-] Безумное максимальное количество попыток соединения!");
			status = 0;
		}

		if((conf->faildelay < CONF_MIN_FAILDELAY) || (conf->faildelay > CONF_MAX_FAILDELAY))
		{
			puts("[-] Безумная задержка при сбое соединения!");
			status = 0;
		}

		if((conf->socks != 4) && (conf->socks != 5))
		{
			puts("[-] Безумный тип прокси!");
			status = 0;
		}

		if(!conf->usernames.length)
		{
			puts("[!] Не указано ни одного логина");
		}

		if(!conf->passwords.length)
		{
			puts("[!] Не указано ни одного пароля");
		}

		if(status)
		{
			if(!conf->ports.length)
			{
				PORTRANGE *pr;
				if((pr = malloc(sizeof(PORTRANGE))))
				{
					pr->start = pr->end = CONF_DEF_PORT;
					vectoradd(&(conf->ports), pr);
					//puts("[*] Не укзано ни одного порта, используем значение по умолчанию");
				}
			}
		}

		if(!status)
		{
			puts("[-] Указанные параметны не корректны");
		}
		else
		{
			puts("[*] Указанные параметры можно юзать");
		}

		puts("");


		return status;
	}
	return 0;
}
int conf_on_value(LSCANCONF *conf, char *sw, char *val)
{
	int status = 0;

	if(sw_test(sw, "h", "-host"))
	{
		HOSTRANGE *temp;
		if(!(temp = hostrangeparse(val)))
		{
			printf("[-] Некорректный хост/диапазон: %s\n", val);
			return 0;
		}
		vectoradd(&(conf->hosts), temp);
	}

	else if(sw_test(sw, "p", "-port"))
	{
		PORTRANGE *temp;
		if(!(temp = portrangeparse(val)))
		{
			printf("[-] Некорректный порт/диапазон: %s\n", val);
			return 0;
		}
		vectoradd(&(conf->ports), temp);
	}
	
	else if(sw_test(sw, "t", "-proxy"))
	{
		PROXY *temp;
		if(!(temp = proxyparse(val)))
		{
			printf("[-] Некорректный прокси: %s\n", val);
			return 0;
		}
		vectoradd(&(conf->proxies), temp);
	}

	else if(sw_test(sw, "hl", "-hostlist"))
	{
		FILE *stream;
		if((stream = fopen(val, "rt")))
		{
			char temp[256];
			while((fgets(temp, sizeof(temp), stream)))
			{
				char *p;
				HOSTRANGE *hr;
				if((p = strchr(temp, '\n')))
					*p = 0;
				if((hr = hostrangeparse(temp)))
					vectoradd(&(conf->hosts), hr);
			}
			fclose(stream);
		}
		else
		{
			printf("[-] Ошибка импорта \"%s\"\n", val);
		}
	}
	
	else if(sw_test(sw, "ul", "-usernamelist"))
	{
		if(!(vectoraddfile(&(conf->usernames), val)))
		{
			printf("[-] Ошибка импорта \"%s\"\n", val);
			return 0;
		}
	}
	
	else if(sw_test(sw, "pwl", "-passwordlist"))
	{
		if(!(vectoraddfile(&(conf->passwords), val)))
		{
			printf("[-] Ошибка импорта \"%s\"\n", val);
			return 0;
		}
	}
	
	else if(sw_test(sw, "u", "-username"))
	{
		vectoradd(&(conf->usernames), strdup(val));
	}
	
	else if(sw_test(sw, "pw", "-password"))
	{
		vectoradd(&(conf->passwords), strdup(val));
	}

	else if(sw_test(sw, "c", "-count"))
	{
		conf->count = atoi(val);
	}
	
	else if(sw_test(sw, "n", "-packets"))
	{
		conf->packets = atoi(val);
	}
	
	else if(sw_test(sw, "m", "-maxhosts"))
	{
		conf->maxhosts = atoi(val);
	}
	
	else if(sw_test(sw, "w", "-timeout"))
	{
		conf->timeout = atoi(val);
	}
	
	else if(sw_test(sw, "d", "-delay"))
	{
		conf->delay = atoi(val);
	}
	
	else if(sw_test(sw, "io", "-iotimeout"))
	{
		conf->iotimeout = atoi(val);
	}
	
	else if(sw_test(sw, "r", "-retrycount"))
	{
		conf->retrycount = atoi(val);
	}
	
	else if(sw_test(sw, "f", "-faildelay"))
	{
		conf->faildelay = atoi(val);
	}
	
	else if(sw_test(sw, "s", "-socks"))
	{
		conf->faildelay = atoi(val);
	}
	
	else if(sw_test(sw, "o", "-output"))
	{
		conf->output = val;
	}

	else
	{
		printf("[!] Проигнорировано: %s\n", val);
	}
	
	return 1;
}