Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed every threading related. We assume the thread is faster than … #10

Open
wants to merge 1 commit into
base: topic-scalingPizDaintISAAC
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 4 additions & 150 deletions src/picongpu/include/plugins/isaac/isaac.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,11 +1319,10 @@ class IsaacVisualization
MPI_Gather( message_buffer, ISAAC_MAX_RECEIVE, MPI_CHAR, NULL, 0, MPI_CHAR, master, mpi_world);
}

#ifdef ISAAC_THREADING
pthread_create(&visualizationThread,NULL,visualizationFunction,image);
#else
visualizationFunction(image);
#endif
json_decref( myself->json_root );
myself->recreateJSON();
myself->metaNr++;

return metadata;
}
~IsaacVisualization()
Expand Down Expand Up @@ -1530,151 +1529,6 @@ class IsaacVisualization
ISAAC_STOP_TIME_MEASUREMENT( myself->copy_time, +=, copy, myself->getTicksUs() )
}

static void* visualizationFunction(void* dummy)
{
IceTImage* image = (IceTImage*)dummy;
//Message sending
if (myself->rank == myself->master)
{
json_object_set_new( myself->json_root, "type", json_string( "period" ) );
json_object_set_new( myself->json_root, "meta nr", json_integer( myself->metaNr ) );

json_t *matrix;
if ( myself->send_projection )
{
json_object_set_new( myself->json_root, "projection", matrix = json_array() );
ISAAC_JSON_ADD_MATRIX(matrix,myself->projection,16 * TController::pass_count)
}
if ( myself->send_look_at )
{
json_object_set_new( myself->json_root, "position", matrix = json_array() );
ISAAC_JSON_ADD_MATRIX(matrix,myself->look_at,3)
}
if ( myself->send_rotation )
{
json_object_set_new( myself->json_root, "rotation", matrix = json_array() );
ISAAC_JSON_ADD_MATRIX(matrix, myself->rotation,9)
}
if ( myself->send_distance )
json_object_set_new( myself->json_root, "distance", json_real( myself->distance ) );
if ( myself->send_transfer )
{
json_object_set_new( myself->json_root, "transfer array", matrix = json_array() );
for (size_t i = 0; i < boost::mpl::size< TSourceList >::type::value; i++)
{
json_t* transfer = json_array();
json_array_append_new( matrix, transfer );
for (size_t j = 0; j < TTransfer_size; j++)
{
json_t* color = json_array();
json_array_append_new( transfer, color );
json_array_append_new( color, json_integer( isaac_uint( myself->transfer_h.pointer[i][j].x * isaac_float(255) ) ) );
json_array_append_new( color, json_integer( isaac_uint( myself->transfer_h.pointer[i][j].y * isaac_float(255) ) ) );
json_array_append_new( color, json_integer( isaac_uint( myself->transfer_h.pointer[i][j].z * isaac_float(255) ) ) );
json_array_append_new( color, json_integer( isaac_uint( myself->transfer_h.pointer[i][j].w * isaac_float(255) ) ) );
}
}
json_object_set_new( myself->json_root, "transfer points", matrix = json_array() );
for (size_t i = 0; i < boost::mpl::size< TSourceList >::type::value; i++)
{
json_t* points = json_array();
json_array_append_new( matrix, points );
for(auto it = myself->transfer_h.description[i].begin(); it != myself->transfer_h.description[i].end(); it++)
{
json_t* p = json_object();
json_array_append_new( points, p);
json_object_set_new(p, "value", json_integer( it->first ) );
json_object_set_new(p, "r", json_real( it->second.x ) );
json_object_set_new(p, "g", json_real( it->second.y ) );
json_object_set_new(p, "b", json_real( it->second.z ) );
json_object_set_new(p, "a", json_real( it->second.w ) );
}
}
}
if ( myself->send_functions )
{
json_object_set_new( myself->json_root, "functions", matrix = json_array() );
for (size_t i = 0; i < boost::mpl::size< TSourceList >::type::value; i++)
{
json_t* f = json_object();
json_array_append_new( matrix, f );
json_object_set_new(f, "source", json_string( myself->functions[i].source.c_str() ) );
json_object_set_new(f, "error", json_integer( myself->functions[i].error_code ) );
}
}
if ( myself->send_weight )
{
json_object_set_new( myself->json_root, "weight", matrix = json_array() );
for (size_t i = 0; i < boost::mpl::size< TSourceList >::type::value; i++)
json_array_append_new( matrix, json_real( myself->source_weight.value[i] ) );
}
if ( myself->send_interpolation )
json_object_set_new( myself->json_root, "interpolation", json_boolean( myself->interpolation ) );
if ( myself->send_step )
json_object_set_new( myself->json_root, "step", json_real( myself->step ) );
if ( myself->send_iso_surface )
json_object_set_new( myself->json_root, "iso surface", json_boolean( myself->iso_surface ) );
if ( myself->send_minmax )
{
json_object_set_new( myself->json_root, "minmax", matrix = json_array() );
for (size_t i = 0; i < boost::mpl::size< TSourceList >::type::value; i++)
{
json_t* v = json_object();
json_array_append_new( matrix, v );
json_object_set_new(v, "min", json_real( myself->minmax_array.min[i] ) );
json_object_set_new(v, "max", json_real( myself->minmax_array.max[i] ) );
}
}
if ( myself->send_background_color )
{
json_object_set_new( myself->json_root, "background color", matrix = json_array() );
for (size_t i = 0; i < 3; i++)
json_array_append_new( matrix, json_real( myself->background_color[i] ) );
}
if ( myself->send_clipping )
{
json_object_set_new( myself->json_root, "clipping", matrix = json_array() );
for (size_t i = 0; i < myself->clipping.count; i++)
{
json_t* f = json_object();
json_array_append_new( matrix, f );
json_t* inner = json_array();
json_object_set_new(f, "position", inner );
json_array_append_new( inner, json_real( myself->clipping.elem[i].position.x ) );
json_array_append_new( inner, json_real( myself->clipping.elem[i].position.y ) );
json_array_append_new( inner, json_real( myself->clipping.elem[i].position.z ) );
inner = json_array();
json_object_set_new(f, "normal", inner );
json_array_append_new( inner, json_real( myself->clipping_saved_normals[i].x ) );
json_array_append_new( inner, json_real( myself->clipping_saved_normals[i].y ) );
json_array_append_new( inner, json_real( myself->clipping_saved_normals[i].z ) );
}
}
myself->controller.sendFeedback( myself->json_root, myself->send_controller );
char* buffer = json_dumps( myself->json_root, 0 );
myself->communicator->serverSend(buffer);
free(buffer);
}

json_decref( myself->json_root );
myself->recreateJSON();

//Sending video
ISAAC_START_TIME_MEASUREMENT( video_send, myself->getTicksUs() )
if (myself->communicator)
{
if (image[0].opaque_internals)
myself->communicator->serverSendFrame(myself->compositor.doCompositing(image),myself->compbuffer_size.x,myself->compbuffer_size.y,4);
else
{
myself->communicator->serverSend(NULL,false,true);
}
}
ISAAC_STOP_TIME_MEASUREMENT( myself->video_send_time, +=, video_send, myself->getTicksUs() )

myself->metaNr++;
return 0;
}
void recreateJSON()
{
json_root = json_object();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,79 +87,6 @@ class IsaacCommunicator
jpeg_quality = 100;
this->jpeg_quality = jpeg_quality;
}
void serverSendFrame(void* ptr,const isaac_uint width,const isaac_uint height,const isaac_uint depth)
{
//First the size
uint32_t count = width*height*depth;
#if ISAAC_JPEG == 1
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
jpeg_destination_mgr dest;
dest.init_destination = &isaac_init_destination;
dest.empty_output_buffer = &isaac_jpeg_empty_output_buffer;
dest.term_destination = &isaac_jpeg_term_destination;
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);
cinfo.dest = &dest;
std::vector<char> jpeg_buffer;
jpeg_buffer.resize( count );
cinfo.dest->next_output_byte = (JOCTET*)(jpeg_buffer.data());
cinfo.dest->free_in_buffer = count;
cinfo.image_width = width;
cinfo.image_height = height;
cinfo.input_components = depth;
cinfo.in_color_space = JCS_EXT_RGBX;
jpeg_set_defaults(&cinfo);
jpeg_set_quality(&cinfo, jpeg_quality, false);
jpeg_start_compress(&cinfo, TRUE);
while (cinfo.next_scanline < cinfo.image_height)
{
JSAMPROW row_pointer[1];
row_pointer[0] = & ((JSAMPROW)ptr)[cinfo.next_scanline * width * depth];
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
}
jpeg_finish_compress(&cinfo);
count -= cinfo.dest->free_in_buffer;
ptr = jpeg_buffer.data();
jpeg_destroy_compress(&cinfo);
#endif

using namespace boost::archive::iterators;
std::stringstream payload;
typedef
base64_from_binary
<
transform_width
<
const unsigned char *,
6,
8
>
>
base64_text; // compose all the above operations in to a new iterator

std::copy(
base64_text( (char*)ptr ),
base64_text( (char*)ptr + count),
boost::archive::iterators::ostream_iterator<char>(payload)
);

#if ISAAC_JPEG == 1
char header[] = "{\"payload\": \"data:image/jpeg;base64,";
#else
char header[] = "{\"payload\": \"data:image/raw-rgba;base64,";
#endif
char footer[] = "\"}";
int hl = strlen(header);
int pl = payload.str().length();
int fl = strlen(footer);
char* message = (char*)malloc(hl+pl+fl+1);
memcpy( message ,header,hl);
memcpy(&(message[hl ]),payload.str().c_str(),pl);
memcpy(&(message[hl+pl]),footer,fl+1); //with 0
serverSend( message, false, true );
free(message);
}
void serverDisconnect()
{
}
Expand Down
11 changes: 1 addition & 10 deletions src/picongpu/include/plugins/isaac/isaac/isaac_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,4 @@
for (isaac_int i = 0; i < count; i++) \
json_array_append_new( array, json_real( (matrix)[i] ) );

#ifdef ISAAC_THREADING
#define ISAAC_WAIT_VISUALIZATION \
if (visualizationThread) \
{ \
pthread_join(visualizationThread,NULL); \
visualizationThread = 0; \
}
#else
#define ISAAC_WAIT_VISUALIZATION {}
#endif
#define ISAAC_WAIT_VISUALIZATION {}