diff --git a/AccelerationClient/.classpath b/AccelerationClient/.classpath deleted file mode 100755 index aa57133..0000000 --- a/AccelerationClient/.classpath +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/AccelerationClient/.project b/AccelerationClient/.project deleted file mode 100755 index dd46d71..0000000 --- a/AccelerationClient/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - AccelerationClient - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/AccelerationClient/.settings/org.eclipse.jdt.core.prefs b/AccelerationClient/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index d5d624f..0000000 --- a/AccelerationClient/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,297 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=16 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=0 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=0 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=2 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.format_block_comments=true -org.eclipse.jdt.core.formatter.comment.format_header=true -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=true -org.eclipse.jdt.core.formatter.comment.format_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert -org.eclipse.jdt.core.formatter.comment.line_length=100 -org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true -org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true -org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.join_lines_in_comments=true -org.eclipse.jdt.core.formatter.join_wrapped_lines=true -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=100 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=3 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false -org.eclipse.jdt.core.formatter.tabulation.char=space -org.eclipse.jdt.core.formatter.tabulation.size=2 -org.eclipse.jdt.core.formatter.use_on_off_tags=false -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true -org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true -org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true -org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/AccelerationClient/.settings/org.eclipse.jdt.ui.prefs b/AccelerationClient/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 1a05a42..0000000 --- a/AccelerationClient/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,62 +0,0 @@ -eclipse.preferences.version=1 -editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_profile=_GoogleStyle -formatter_settings_version=12 -sp_cleanup.add_default_serial_version_id=true -sp_cleanup.add_generated_serial_version_id=false -sp_cleanup.add_missing_annotations=true -sp_cleanup.add_missing_deprecated_annotations=true -sp_cleanup.add_missing_methods=false -sp_cleanup.add_missing_nls_tags=false -sp_cleanup.add_missing_override_annotations=true -sp_cleanup.add_missing_override_annotations_interface_methods=true -sp_cleanup.add_serial_version_id=false -sp_cleanup.always_use_blocks=true -sp_cleanup.always_use_parentheses_in_expressions=false -sp_cleanup.always_use_this_for_non_static_field_access=false -sp_cleanup.always_use_this_for_non_static_method_access=false -sp_cleanup.convert_functional_interfaces=false -sp_cleanup.convert_to_enhanced_for_loop=false -sp_cleanup.correct_indentation=false -sp_cleanup.format_source_code=true -sp_cleanup.format_source_code_changes_only=false -sp_cleanup.insert_inferred_type_arguments=false -sp_cleanup.make_local_variable_final=true -sp_cleanup.make_parameters_final=false -sp_cleanup.make_private_fields_final=true -sp_cleanup.make_type_abstract_if_missing_method=false -sp_cleanup.make_variable_declarations_final=false -sp_cleanup.never_use_blocks=false -sp_cleanup.never_use_parentheses_in_expressions=true -sp_cleanup.on_save_use_additional_actions=false -sp_cleanup.organize_imports=true -sp_cleanup.qualify_static_field_accesses_with_declaring_class=false -sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_with_declaring_class=false -sp_cleanup.qualify_static_method_accesses_with_declaring_class=false -sp_cleanup.remove_private_constructors=true -sp_cleanup.remove_redundant_type_arguments=true -sp_cleanup.remove_trailing_whitespaces=false -sp_cleanup.remove_trailing_whitespaces_all=true -sp_cleanup.remove_trailing_whitespaces_ignore_empty=false -sp_cleanup.remove_unnecessary_casts=true -sp_cleanup.remove_unnecessary_nls_tags=false -sp_cleanup.remove_unused_imports=false -sp_cleanup.remove_unused_local_variables=false -sp_cleanup.remove_unused_private_fields=true -sp_cleanup.remove_unused_private_members=false -sp_cleanup.remove_unused_private_methods=true -sp_cleanup.remove_unused_private_types=true -sp_cleanup.sort_members=false -sp_cleanup.sort_members_all=false -sp_cleanup.use_anonymous_class_creation=false -sp_cleanup.use_blocks=false -sp_cleanup.use_blocks_only_for_return_and_throw=false -sp_cleanup.use_lambda=true -sp_cleanup.use_parentheses_in_expressions=false -sp_cleanup.use_this_for_non_static_field_access=false -sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true -sp_cleanup.use_this_for_non_static_method_access=false -sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true -sp_cleanup.use_type_arguments=false diff --git a/AccelerationClient/AndroidManifest.xml b/AccelerationClient/AndroidManifest.xml deleted file mode 100755 index bf7b175..0000000 --- a/AccelerationClient/AndroidManifest.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/AccelerationClient/files/template.st b/AccelerationClient/files/template.st deleted file mode 100755 index 89a22f2..0000000 --- a/AccelerationClient/files/template.st +++ /dev/null @@ -1,25 +0,0 @@ -$modifiers$ $returnType$ $methodName$ ($parameters$) { - Method toExecute; - Class[] paramTypes = {$parameterTypes$}; - Object[] paramValues = {$parameterNames$}; - $returnType$ result = null; - try { - toExecute = this.getClass().getDeclaredMethod("local$methodName$", paramTypes); - result = ($returnType$) dfe.execute(toExecute, paramValues, this); - } catch (SecurityException e) { - // Should never get here - e.printStackTrace(); - throw e; - } catch (NoSuchMethodException e) { - // Should never get here - e.printStackTrace(); - } catch (Throwable e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return result; - } - -$modifiers$ $returnType$ local$methodName$ ($parameters$) { - $originalCode$ -} \ No newline at end of file diff --git a/AccelerationClient/lib/antlr-2.7.7.jar b/AccelerationClient/lib/antlr-2.7.7.jar deleted file mode 100755 index 5e5f14b..0000000 Binary files a/AccelerationClient/lib/antlr-2.7.7.jar and /dev/null differ diff --git a/AccelerationClient/lib/javaparser-1.0.8.jar b/AccelerationClient/lib/javaparser-1.0.8.jar deleted file mode 100755 index 9bfe003..0000000 Binary files a/AccelerationClient/lib/javaparser-1.0.8.jar and /dev/null differ diff --git a/AccelerationClient/lib/stringtemplate-3.2.1.jar b/AccelerationClient/lib/stringtemplate-3.2.1.jar deleted file mode 100755 index 8a309cc..0000000 Binary files a/AccelerationClient/lib/stringtemplate-3.2.1.jar and /dev/null differ diff --git a/AccelerationClient/project.properties b/AccelerationClient/project.properties deleted file mode 100644 index 5c8b260..0000000 --- a/AccelerationClient/project.properties +++ /dev/null @@ -1,32 +0,0 @@ -############################################################################### -# Copyright (C) 2015, 2016 RAPID EU Project -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -############################################################################### -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -android.library=true -# Project target. -target=android-23 diff --git a/AccelerationClient/src/eu/project/rapid/ac/DFE.java b/AccelerationClient/src/eu/project/rapid/ac/DFE.java deleted file mode 100755 index f4f5030..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/DFE.java +++ /dev/null @@ -1,1517 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac; - -import java.io.BufferedInputStream; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.OutputStream; -import java.lang.reflect.Array; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.net.UnknownHostException; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.UnrecoverableKeyException; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Set; -import java.util.TreeSet; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import javax.net.ssl.HandshakeCompletedEvent; -import javax.net.ssl.HandshakeCompletedListener; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSocket; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManagerFactory; - -import android.app.ProgressDialog; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.net.ConnectivityManager; -import android.net.NetworkInfo; -import android.os.AsyncTask; -import android.os.Build; -import android.preference.PreferenceManager; -import android.util.Log; -import eu.project.rapid.ac.d2d.D2DClientService; -import eu.project.rapid.ac.d2d.PhoneSpecs; -import eu.project.rapid.ac.db.DBCache; -import eu.project.rapid.ac.profilers.DeviceProfiler; -import eu.project.rapid.ac.profilers.NetworkProfiler; -import eu.project.rapid.ac.profilers.Profiler; -import eu.project.rapid.ac.profilers.ProgramProfiler; -import eu.project.rapid.ac.utils.Constants; -import eu.project.rapid.ac.utils.Utils; -import eu.project.rapid.common.Clone; -import eu.project.rapid.common.Configuration; -import eu.project.rapid.common.RapidConstants; -import eu.project.rapid.common.RapidConstants.COMM_TYPE; -import eu.project.rapid.common.RapidMessages; -import eu.project.rapid.common.RapidMessages.AnimationMsg; -import eu.project.rapid.common.RapidUtils; -import eu.project.rapid.gvirtusfe.Frontend; - -/** - * The most important class of the framework for the client program - controls DSE, profilers, - * communicates with remote server. - * - */ - -public class DFE { - - private static final String TAG = "DFE"; - - public static boolean CONNECT_TO_PREVIOUS_VM = false; - - private Configuration config; - public static final int SDK_INT = Build.VERSION.SDK_INT; - - private static int mRegime; - public static final int REGIME_CLIENT = 1; - public static final int REGIME_SERVER = 2; - public static COMM_TYPE commType = COMM_TYPE.SSL; - private int userChoice = Constants.LOCATION_DYNAMIC_TIME_ENERGY; - private Method prepareDataMethod = null; - - private long mPureLocalDuration; - private long mPureRemoteDuration; - private long prepareDataDuration; - - // private Object result; - private String mAppName; - private Context mContext; - private PackageManager mPManager; - - public static boolean onLineClear = false; - public static boolean onLineSSL = false; - public static boolean dfeReady = false; - private int nrClones; - private DSE mDSE; - NetworkProfiler netProfiler; - - // private boolean profilersEnabled = true; - - // GVirtuS frontend is responsible for running the CUDA code. - private Frontend gVirtusFrontend; - private static Clone sClone; - private static Socket mSocket; - private static OutputStream mOutStream; - private static ObjectOutputStream mObjOutStream; - private static InputStream mInStream; - private static ObjectInputStream mObjInStream; - private final Object syncCreateCloseConnection = new Object(); - - private long myId = -1; - private String vmIp = ""; - private String vmmIp = ""; - private ArrayList vmmIPs; - // public LogRecord lastLogRecord; - private PhoneSpecs myPhoneSpecs; - private static final int vmNrVCPUs = 1; // FIXME: number of CPUs on the VM - private static final int vmMemSize = 512; // FIXME - private static final int vmNrGpuCores = 1200; // FIXME - - private Set d2dSetPhones = new TreeSet(); - private ScheduledThreadPoolExecutor d2dSetReaderThread; - - private ProgressDialog pd = null; - - /** - * Interface to be implemented by some class that wants to be updated about some events. - * - * @author sokol - */ - public interface DfeCallback { - public void vmConnectionStatusUpdate(); // Send updates about the VM connection status. - } - - /** - * Create DFE which decides where to execute remoteable methods and handles execution. - * - * @param clone The clone to connect with.
- * If null then the DFE will connect to the manager and will ask for the clone. - * @param appName Application name, usually the result of getPackageName(). - * @param pManager Package manager for finding apk file of the application. - * @param context - */ - public DFE(String appName, PackageManager pManager, Context context, Clone clone) { - - Log.d(TAG, "DFE Created"); - DFE.mRegime = REGIME_CLIENT; - this.mAppName = appName; - this.mPManager = pManager; - this.mContext = context; - sClone = clone; - this.myPhoneSpecs = PhoneSpecs.getPhoneSpecs(mContext); - - Log.i(TAG, "Current device: " + myPhoneSpecs); - - createRapidFoldersIfNotExist(); - readConfigurationFile(); - initializeCrypto(); - - // The prev id is useful to the DS so that it can release already allocated VMs. - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.mContext); - myId = prefs.getLong(Constants.MY_OLD_ID, -1); - vmIp = prefs.getString(Constants.PREV_VM_IP, ""); - vmmIp = prefs.getString(Constants.PREV_VMM_IP, ""); - - mDSE = new DSE(userChoice); - - netProfiler = new NetworkProfiler(mContext, config); - netProfiler.registerNetworkStateTrackers(); - - // Start the thread that will deal with the D2D communication - startD2DThread(); - - // Show a spinning dialog while connecting to the Manager and to the clone. - this.pd = ProgressDialog.show(mContext, "Working...", "Initial network tasks...", true, false); - (new InitialNetworkTasks()).execute(sClone); - } - - public DFE(String appName, PackageManager pManager, Context context) { - this(appName, pManager, context, null); - } - - /** - * To be used on server side, only local execution - */ - public DFE() { - mRegime = REGIME_SERVER; - } - - private void createRapidFoldersIfNotExist() { - File rapidDir = new File(Constants.RAPID_FOLDER); - if (!rapidDir.exists()) { - if (!rapidDir.mkdirs()) { - Log.w(TAG, "Could not create the Rapid folder: " + Constants.RAPID_FOLDER); - } - } - - File rapidTestDir = new File(Constants.TEST_LOGS_FOLDER); - if (!rapidTestDir.exists()) { - if (!rapidTestDir.mkdirs()) { - Log.w(TAG, "Could not create the Rapid folder: " + Constants.TEST_LOGS_FOLDER); - } - } - } - - private void readConfigurationFile() { - - try { - // Read the config file to read the IP and port of Manager - config = new Configuration(Constants.PHONE_CONFIG_FILE); - config.parseConfigFile(); - } catch (FileNotFoundException e) { - Log.e(TAG, "Config file not found: " + Constants.PHONE_CONFIG_FILE); - config = new Configuration(); - } - } - - - /** - * Create the necessary stuff for the SSL connection. - */ - private void initializeCrypto() { - try { - Log.i(TAG, "Started reading the cryptographic keys"); - - KeyStore trustStore = KeyStore.getInstance("BKS"); - trustStore.load(new FileInputStream(Constants.SSL_CA_TRUSTSTORE), - Constants.SSL_DEFAULT_PASSW.toCharArray()); - TrustManagerFactory trustManagerFactory = - TrustManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); - trustManagerFactory.init(trustStore); - - KeyStore keyStore = KeyStore.getInstance("BKS"); - keyStore.load(new FileInputStream(Constants.SSL_KEYSTORE), - Constants.SSL_DEFAULT_PASSW.toCharArray()); - KeyManagerFactory kmf = - KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); - kmf.init(keyStore, Constants.SSL_DEFAULT_PASSW.toCharArray()); - - PrivateKey myPrivateKey = (PrivateKey) keyStore.getKey(Constants.SSL_CERT_ALIAS, - Constants.SSL_DEFAULT_PASSW.toCharArray()); - Certificate cert = keyStore.getCertificate(Constants.SSL_CERT_ALIAS); - PublicKey myPublicKey = cert.getPublicKey(); - Log.i(TAG, "Certificate: " + cert.toString()); - Log.i(TAG, "PrivateKey algorithm: " + myPrivateKey.getAlgorithm()); - Log.i(TAG, "PublicKey algorithm: " + myPrivateKey.getAlgorithm()); - - SSLContext sslContext = SSLContext.getInstance("TLS"); - sslContext.init(null, trustManagerFactory.getTrustManagers(), null); - SSLSocketFactory sslFactory = sslContext.getSocketFactory(); - Log.i(TAG, "SSL Factory created"); - - config.setCryptoInitialized(true); - config.setPrivateKey(myPrivateKey); - config.setPublicKey(myPublicKey); - config.setSslFactory(sslFactory); - config.setSslContext(sslContext); - - } catch (KeyStoreException | NoSuchAlgorithmException | KeyManagementException - | UnrecoverableKeyException | CertificateException | IOException e) { - Log.e(TAG, "Could not initialize the crypto parameters - " + e); - } - } - - private class InitialNetworkTasks extends AsyncTask { - - private static final String TAG = "InitialNetworkTasks"; - - @Override - protected Void doInBackground(Clone... clone) { - - // Check if the primary animation server is reachable - boolean primaryAnimationServerReachable = RapidUtils.isPrimaryAnimationServerRunning( - config.getAnimationServerIp(), config.getAnimationServerPort()); - Log.i(TAG, "Primary animation server reachable: " + primaryAnimationServerReachable); - if (!primaryAnimationServerReachable) { - config.setAnimationServerIp(RapidConstants.DEFAULT_SECONDARY_ANIMATION_SERVER_IP); - config.setAnimationServerPort(RapidConstants.DEFAULT_SECONDARY_ANIMATION_SERVER_PORT); - } - - // Anyway, show the default image, where the AC tries to connects to DS, SLAM, etc. If this - // fails, then we will show the D2D initial image - RapidUtils.sendAnimationMsg(config, AnimationMsg.AC_INITIAL_IMG); - - if (clone[0] == null) { - publishProgress("Registering with the DS and the SLAM..."); - registerWithDsAndSlam(); - } else { - publishProgress("Using the clone given by the user: " + clone[0]); - sClone = clone[0]; - } - - config.setClone(sClone); - - RapidUtils.sendAnimationMsg(config, CONNECT_TO_PREVIOUS_VM ? AnimationMsg.AC_PREV_REGISTER_VM - : AnimationMsg.AC_NEW_REGISTER_VM); - if (commType == COMM_TYPE.CLEAR) { - publishProgress("Clear connection with the clone: " + sClone); - establishConnection(); - } else { // (commType == COMM_TYPE.SSL) - publishProgress("SSL connection with the clone: " + sClone); - if (!establishSslConnection()) { - Log.w(TAG, "Setting commType to CLEAR"); - commType = COMM_TYPE.CLEAR; - establishConnection(); - } - } - - // If the connection was successful then try to send the app to the clone - if (onLineClear || onLineSSL) { - RapidUtils.sendAnimationMsg(config, - CONNECT_TO_PREVIOUS_VM ? AnimationMsg.AC_PREV_CONN_VM : AnimationMsg.AC_NEW_CONN_VM); - - Log.i(TAG, "The communication type established with the clone is: " + commType); - - if (config.getGvirtusIp() == null) { - // If gvirtusIp is null, then gvirtus backend is running on the physical machine where - // the VM is running. - // Try to find a way here to get the ip address of the physical machine. - // config.setGvirtusIp(TODO: ip address of the physical machine where the VM is running); - } - - publishProgress("Registering application with the RAPID system..."); - RapidUtils.sendAnimationMsg(config, - CONNECT_TO_PREVIOUS_VM ? AnimationMsg.AC_PREV_APK_VM : AnimationMsg.AC_NEW_APK_VM); - sendApk(); - - // Find rtt to the server - // Measure the data rate when just connected - publishProgress("Sending/receiving data for 3 seconds to measure the ulRate and dlRate..."); - RapidUtils.sendAnimationMsg(config, - CONNECT_TO_PREVIOUS_VM ? AnimationMsg.AC_PREV_RTT_VM : AnimationMsg.AC_NEW_RTT_VM); - NetworkProfiler.rttPing(mInStream, mOutStream); - RapidUtils.sendAnimationMsg(config, CONNECT_TO_PREVIOUS_VM ? AnimationMsg.AC_PREV_DL_RATE_VM - : AnimationMsg.AC_NEW_DL_RATE_VM); - NetworkProfiler.measureDlRate(sClone.getIp(), config.getClonePortBandwidthTest()); - RapidUtils.sendAnimationMsg(config, CONNECT_TO_PREVIOUS_VM ? AnimationMsg.AC_PREV_UL_RATE_VM - : AnimationMsg.AC_NEW_UL_RATE_VM); - NetworkProfiler.measureUlRate(sClone.getIp(), config.getClonePortBandwidthTest()); - RapidUtils.sendAnimationMsg(config, CONNECT_TO_PREVIOUS_VM - ? AnimationMsg.AC_PREV_REGISTRATION_OK_VM : AnimationMsg.AC_NEW_REGISTRATION_OK_VM); - - try { - ((DfeCallback) mContext).vmConnectionStatusUpdate(); - } catch (ClassCastException e) { - Log.i(TAG, "This class doesn't implement callback methods."); - } - } else { - RapidUtils.sendAnimationMsg(config, AnimationMsg.AC_REGISTER_VM_ERROR); - } - - // if (config.getGvirtusIp() != null) { - // // Create a gvirtus frontend object that is responsible for executing the CUDA code. - // publishProgress("Connecting with GVirtuS backend..."); - // gVirtusFrontend = new Frontend(config.getGvirtusIp(), config.getGvirtusPort()); - // } - - return null; - } - - @Override - protected void onProgressUpdate(String... progress) { - Log.i(TAG, progress[0]); - if (pd != null) { - pd.setMessage(progress[0]); - } - } - - @Override - protected void onPostExecute(Void result) { - Log.i(TAG, "Finished initial network tasks"); - dfeReady = true; - if (pd != null) { - pd.dismiss(); - } - } - - @Override - protected void onPreExecute() { - Log.i(TAG, "Started initial network tasks"); - } - - private boolean registerWithDsAndSlam() { - Log.i(TAG, "Registering..."); - boolean registeredWithSlam = false; - - if (registerWithDs()) { - // register with SLAM - int vmmIndex = 0; - - if (vmmIPs != null) { - do { - registeredWithSlam = registerWithSlam(vmmIPs.get(vmmIndex)); - vmmIndex++; - } while (!registeredWithSlam && vmmIndex < vmmIPs.size()); - } - } - return registeredWithSlam; - } - - /** - * Read the config file to get the IP and port of the DS. The DS will return a list of available - * SLAMs, choose the best one from the list and connect to it to ask for a VM. - * - * @throws IOException - * @throws UnknownHostException - * @throws ClassNotFoundException - */ - @SuppressWarnings("unchecked") - private boolean registerWithDs() { - - Log.d(TAG, "Starting as phone with ID: " + myId); - RapidUtils.sendAnimationMsg(config, - CONNECT_TO_PREVIOUS_VM ? AnimationMsg.AC_PREV_VM_DS : AnimationMsg.AC_NEW_REGISTER_DS); - - Socket dsSocket = null; - ObjectOutputStream dsOut = null; - ObjectInputStream dsIn = null; - - Log.i(TAG, "Registering with DS " + config.getDSIp() + ":" + config.getDSPort()); - try { - dsSocket = new Socket(); - dsSocket.connect(new InetSocketAddress(config.getDSIp(), config.getDSPort()), 10 * 1000); - dsOut = new ObjectOutputStream(dsSocket.getOutputStream()); - dsIn = new ObjectInputStream(dsSocket.getInputStream()); - - // Send the name and id to the DS - if (CONNECT_TO_PREVIOUS_VM) { - // RapidUtils.sendAnimationMsg(config, AnimationMsg.AC_PREV_VM_DS); - Log.i(TAG, "AC_REGISTER_PREV_DS"); - // Send message format: command (java byte), userId (java long), qosFlag (java int) - dsOut.writeByte(RapidMessages.AC_REGISTER_PREV_DS); - dsOut.writeLong(myId); // send my user ID so that my previous VM can be released - } else { // Connect to a new VM - // RapidUtils.sendAnimationMsg(config, AnimationMsg.AC_NEW_REGISTER_DS); - Log.i(TAG, "AC_REGISTER_NEW_DS"); - dsOut.writeByte(RapidMessages.AC_REGISTER_NEW_DS); - - dsOut.writeLong(myId); // send my user ID so that my previous VM can be released - // FIXME: should not use static values here. - dsOut.writeInt(vmNrVCPUs); // send vcpuNum as int - dsOut.writeInt(vmMemSize); // send memSize as int - dsOut.writeInt(vmNrGpuCores); // send gpuCores as int - } - - dsOut.flush(); - - // Receive message format: status (java byte), userId (java long), SLAM ipAddress (java UTF) - byte status = dsIn.readByte(); - Log.i(TAG, "Return Status: " + (status == RapidMessages.OK ? "OK" : "ERROR")); - if (status == RapidMessages.OK) { - myId = dsIn.readLong(); - Log.i(TAG, "userId is: " + myId); - - // Read the list of VMMs, which will be sorted based on free resources - vmmIPs = (ArrayList) dsIn.readObject(); - - // Read the SLAM IP and port - String slamIp = dsIn.readUTF(); - int slamPort = dsIn.readInt(); - config.setSlamIp(slamIp); - config.setSlamPort(slamPort); - Log.i(TAG, "SLAM address is: " + slamIp + ":" + slamPort); - - return true; - } - } catch (Exception e) { - Log.e(TAG, "Error while connecting with the DS: " + e); - } finally { - RapidUtils.closeQuietly(dsOut); - RapidUtils.closeQuietly(dsIn); - RapidUtils.closeQuietly(dsSocket); - } - - return false; - } - - /** - * @throws IOException - * @throws UnknownHostException - * @throws ClassNotFoundException - */ - private boolean registerWithSlam(String vmmIp) { - - Socket slamSocket = null; - ObjectOutputStream oos = null; - ObjectInputStream ois = null; - - Log.i(TAG, "Registering with SLAM " + config.getSlamIp() + ":" + config.getSlamPort()); - try { - - slamSocket = new Socket(); - slamSocket.connect(new InetSocketAddress(config.getSlamIp(), config.getSlamPort()), - 10 * 1000); - - oos = new ObjectOutputStream(slamSocket.getOutputStream()); - ois = new ObjectInputStream(slamSocket.getInputStream()); - - RapidUtils.sendAnimationMsg(config, CONNECT_TO_PREVIOUS_VM - ? AnimationMsg.AC_PREV_REGISTER_SLAM : AnimationMsg.AC_NEW_REGISTER_SLAM); - - // Send the ID to the SLAM - oos.writeByte(RapidMessages.AC_REGISTER_SLAM); - oos.writeLong(myId); - oos.writeInt(RapidConstants.OS.ANDROID.ordinal()); - - // Send the vmmId and vmmPort to the SLAM so it can start the VM - oos.writeUTF(vmmIp); - oos.writeInt(config.getVmmPort()); - - // FIXME: should not use static values here. - oos.writeInt(vmNrVCPUs); // send vcpuNum as int - oos.writeInt(vmMemSize); // send memSize as int - oos.writeInt(vmNrGpuCores); // send gpuCores as int - - oos.flush(); - - int slamResponse = ois.readByte(); - if (slamResponse == RapidMessages.OK) { - Log.i(TAG, "SLAM OK, getting the VM details"); - vmIp = ois.readUTF(); - - sClone = new Clone("", vmIp); - sClone.setId((int) myId); - - Log.i(TAG, "Saving my ID and the vmIp: " + myId + ", " + vmIp); - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); - SharedPreferences.Editor editor = prefs.edit(); - - editor.putLong(Constants.MY_OLD_ID, myId); - editor.putString(Constants.PREV_VM_IP, vmIp); - - Log.i(TAG, "Saving the VMM IP: " + vmmIp); - editor.putString(Constants.PREV_VMM_IP, vmmIp); - editor.commit(); - - return true; - } else if (slamResponse == RapidMessages.ERROR) { - Log.e(TAG, "SLAM registration replied with ERROR, VM will be null"); - } else { - Log.e(TAG, "SLAM registration replied with uknown message " + slamResponse - + ", VM will be null"); - } - } catch (IOException e) { - Log.e(TAG, "IOException while talking to the SLAM: " + e); - } finally { - RapidUtils.closeQuietly(oos); - RapidUtils.closeQuietly(ois); - RapidUtils.closeQuietly(slamSocket); - } - - return false; - } - } - - public void onDestroy() { - Log.d(TAG, "onDestroy"); - dfeReady = false; - DeviceProfiler.onDestroy(); - netProfiler.onDestroy(); - DBCache.saveDbCache(); - closeConnection(); - // FIXME Should I also stop the D2D listening service here or should I leave it running? - RapidUtils.sendAnimationMsg(config, AnimationMsg.AC_INITIAL_IMG); - } - - private void startD2DThread() { - Log.i(TAG, "Starting the D2D listening service..."); - Intent d2dServiceIntent = new Intent(mContext, D2DClientService.class); - mContext.startService(d2dServiceIntent); - - // This thread will run with a certain frequency to read the D2D devices that are written by the - // D2DClientService on the sdcard. This is needed because another DFE may have written the - // devices on the file. - d2dSetReaderThread = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(5); - d2dSetReaderThread.scheduleWithFixedDelay(new D2DSetReader(), 0, - D2DClientService.FREQUENCY_READ_D2D_SET, TimeUnit.MILLISECONDS); - } - - private class D2DSetReader implements Runnable { - - @SuppressWarnings("unchecked") - @Override - public void run() { - try { - Log.i(TAG, "Reading the saved D2D phones..."); - d2dSetPhones = (Set) Utils.readObjectFromFile(Constants.FILE_D2D_PHONES); - - if (d2dSetPhones != null && d2dSetPhones.size() > 0) { - RapidUtils.sendAnimationMsg(config, AnimationMsg.AC_RECEIVED_D2D); - } else { - RapidUtils.sendAnimationMsg(config, AnimationMsg.AC_NO_MORE_D2D); - } - - Log.i(TAG, "List of D2D phones:"); - for (PhoneSpecs p : d2dSetPhones) { - Log.i(TAG, p.toString()); - } - } catch (IOException | ClassNotFoundException e) { - Log.e(TAG, "Error on D2DSetReader while trying to read the saved set of D2D phones: " + e); - } - } - } - - /** - * Set up streams for the socket connection, perform initial communication with the clone. - */ - private boolean establishConnection() { - synchronized (syncCreateCloseConnection) { - try { - long sTime = System.nanoTime(); - long startTxBytes = NetworkProfiler.getProcessTxBytes(); - long startRxBytes = NetworkProfiler.getProcessRxBytes(); - - Log.i(TAG, "Connecting in CLEAR with AS on: " + sClone.getIp() + ":" + sClone.getPort()); - mSocket = new Socket(); - mSocket.connect(new InetSocketAddress(sClone.getIp(), sClone.getPort()), 10 * 1000); - - mOutStream = mSocket.getOutputStream(); - mInStream = mSocket.getInputStream(); - mObjOutStream = new ObjectOutputStream(mOutStream); - mObjInStream = new ObjectInputStream(mInStream); - - long dur = System.nanoTime() - sTime; - long totalTxBytes = NetworkProfiler.getProcessTxBytes() - startTxBytes; - long totalRxBytes = NetworkProfiler.getProcessRxBytes() - startRxBytes; - - Log.d(TAG, "Socket and streams set-up time - " + dur / 1000000 + "ms"); - Log.d(TAG, "Total bytes sent: " + totalTxBytes); - Log.d(TAG, "Total bytes received: " + totalRxBytes); - return onLineClear = true; - - } catch (Exception e) { - e.printStackTrace(); - fallBackToLocalExecution("Connection setup with the clone failed: " + e); - } finally { - onLineSSL = false; - } - return onLineClear = false; - } - } - - /** - * Set up streams for the secure socket connection, perform initial communication with the server. - */ - private boolean establishSslConnection() { - - if (!config.isCryptoInitialized()) { - Log.e(TAG, - "The initialization of the cryptographic keys is not done correctly. Cannot perform ssl connection!"); - return false; - } - - synchronized (syncCreateCloseConnection) { - try { - // RapidUtils.sendAnimationMsg(config, RapidMessages.AC_CONNECT_VM); - - Long sTime = System.nanoTime(); - long startTxBytes = NetworkProfiler.getProcessTxBytes(); - long startRxBytes = NetworkProfiler.getProcessRxBytes(); - - Log.i(TAG, "Connecting in SSL with clone: " + sClone.getIp() + ":" + sClone.getSslPort()); - - mSocket = config.getSslFactory().createSocket(sClone.getIp(), sClone.getSslPort()); - // Log.i(TAG, "getEnableSessionCreation: " + ((SSLSocket) - // mSocket).getEnableSessionCreation()); - // ((SSLSocket) mSocket).setEnableSessionCreation(false); - - // sslContext.getClientSessionContext().getSession(null).invalidate(); - - ((SSLSocket) mSocket).addHandshakeCompletedListener(new SSLHandshakeCompletedListener()); - Log.i(TAG, "socket created"); - - // Log.i(TAG, "Enabled cipher suites: "); - // for (String s : ((SSLSocket) mSocket).getEnabledCipherSuites()) { - // Log.i(TAG, s); - // } - - mOutStream = mSocket.getOutputStream(); - mInStream = mSocket.getInputStream(); - mObjOutStream = new ObjectOutputStream(mOutStream); - mObjInStream = new ObjectInputStream(mInStream); - - long dur = System.nanoTime() - sTime; - long totalTxBytes = NetworkProfiler.getProcessTxBytes() - startTxBytes; - long totalRxBytes = NetworkProfiler.getProcessRxBytes() - startRxBytes; - - Log.d(TAG, "Socket and streams set-up time - " + dur / 1000000 + "ms"); - Log.d(TAG, "Total bytes sent: " + totalTxBytes); - Log.d(TAG, "Total bytes received: " + totalRxBytes); - return onLineSSL = true; - - } catch (UnknownHostException e) { - e.printStackTrace(); - fallBackToLocalExecution("UnknownHostException - Connection setup to server failed: " + e); - } catch (IOException e) { - e.printStackTrace(); - fallBackToLocalExecution("IOException - Connection setup to server failed: " + e); - } catch (Exception e) { - e.printStackTrace(); - fallBackToLocalExecution("Exception - Connection setup to server failed: " + e); - } finally { - onLineClear = false; - } - - return onLineSSL = false; - } - } - - private class SSLHandshakeCompletedListener implements HandshakeCompletedListener { - - @Override - public void handshakeCompleted(HandshakeCompletedEvent event) { - Log.i(TAG, "SSL handshake completed"); - - try { - // Log.i(TAG, "getCipherSuite: " + event.getCipherSuite()); - // Log.i(TAG, "algorithm: " + config.getPrivateKey().getAlgorithm()); - // Log.i(TAG, "modulusBitLength: " + ((RSAPrivateKey) - // config.getPrivateKey()).getModulus().bitLength()); - - // SSLSession session = event.getSession(); - // Log.i(TAG, "getProtocol: " + session.getProtocol()); - // Log.i(TAG, "getPeerHost: " + session.getPeerHost()); - // Log.i(TAG, "getId: " + RapidUtils.bytesToHex(session.getId())); - // Log.i(TAG, "getCreationTime: " + session.getCreationTime()); - - // java.security.cert.Certificate[] certs = event.getPeerCertificates(); - // for (int i = 0; i < certs.length; i++) - // { - // if (!(certs[i] instanceof java.security.cert.X509Certificate)) continue; - // java.security.cert.X509Certificate cert = (java.security.cert.X509Certificate) certs[i]; - // Log.i(TAG, "Cert #" + i + ": " + cert.getSubjectDN().getName()); - // } - } catch (Exception e) { - Log.e(TAG, "SSL handshake completed with errors: " + e); - } - } - - } - - private void closeConnection() { - new Thread(new Runnable() { - @Override - public void run() { - synchronized (syncCreateCloseConnection) { - // RapidUtils.sendAnimationMsg(config, RapidMessages.AC_DISCONNECT_VM); - RapidUtils.closeQuietly(mObjOutStream); - RapidUtils.closeQuietly(mObjInStream); - RapidUtils.closeQuietly(mSocket); - onLineClear = onLineSSL = false; - } - } - }).start(); - } - - private void fallBackToLocalExecution(String message) { - Log.e(TAG, message); - onLineClear = onLineSSL = false; - } - - /** - * @param appName The application name. - * @param methodName The current method that we want to offload from this application.
- * Different methods of the same application will have a different set of parameters. - * @return The execution location which can be one of: LOCAL, REMOTE.
- */ - private int findExecLocation(String appName, String methodName) { - - int execLocation = mDSE.findExecLocation(appName, methodName); - Log.i(TAG, "Execution location: " + execLocation); - - return execLocation; - } - - /** - * Ask the DSE to find the best offloading scheme based on user choice. Developer can use this - * method in order to prepare the data input based on the decision the framework will make about - * the execution location. - * - * @param methodName The name of the method that will be executed. - * @return - */ - private int findExecLocation(String methodName) { - return findExecLocation(mAppName, methodName); - } - - /** - * Wrapper of the execute method with no parameters for the executable method - * - * @param m - * @param o - * @return - * @throws Throwable - */ - public Object execute(Method m, Object o) throws Throwable { - return execute(m, (Object[]) null, o); - } - - /** - * Call DSE to decide where to execute the operation, start profilers, execute (either locally or - * remotely), collect profiling data and return execution results. - * - * @param m method to be executed - * @param pValues with parameter values - * @param o on object - * @return result of execution, or an exception if it happened - * @throws NoSuchMethodException - * @throws ClassNotFoundException - * @throws IllegalAccessException - * @throws SecurityException - * @throws IllegalArgumentException - */ - public Object execute(Method m, Object[] pValues, Object o) throws IllegalArgumentException, - SecurityException, IllegalAccessException, ClassNotFoundException, NoSuchMethodException { - - Object localResult, remoteResult, totalResult = null; - - int execLocation = findExecLocation(m.getName()); - - ExecutorService executor = Executors.newFixedThreadPool(2); - if (execLocation == Constants.LOCATION_HYBRID) { - Future futureLocalResult = - executor.submit(new TaskRunner(Constants.LOCATION_LOCAL, m, pValues, o)); - Future futureRemoteResult = - executor.submit(new TaskRunner(Constants.LOCATION_REMOTE, m, pValues, o)); - - try { - localResult = futureLocalResult.get(); - remoteResult = futureRemoteResult.get(); - - // Reduce the partial results - Method reduceMethod = o.getClass().getDeclaredMethod(m.getName() + "Reduce", - Array.newInstance(m.getReturnType(), 2).getClass()); - reduceMethod.setAccessible(true); - Object partialResults = Array.newInstance(m.getReturnType(), 2); - Array.set(partialResults, 0, localResult); - Array.set(partialResults, 1, remoteResult); - - totalResult = reduceMethod.invoke(o, new Object[] {partialResults}); - } catch (InterruptedException e) { - Log.e(TAG, "Error on FutureTask while trying to run the method hybrid: " + e); - } catch (ExecutionException e) { - Log.e(TAG, "Error on FutureTask while trying to run the method hybrid: " + e); - } catch (InvocationTargetException e) { - Log.e(TAG, "Error on FutureTask while trying to run the method hybrid: " + e); - } - } else { // ecexLocation LOCAL or REMOTE - Future futureTotalResult = - executor.submit(new TaskRunner(execLocation, m, pValues, o)); - - try { - totalResult = futureTotalResult.get(); - } catch (InterruptedException | ExecutionException e) { - Log.e(TAG, "Error on FutureTask while trying to run the method remotely or locally: " + e); - } - } - - executor.shutdown(); - - return totalResult; - } - - private class TaskRunner implements Callable { - int execLocation; - Method m; - Object[] pValues; - Object o; - Object result; - - public TaskRunner(int execLocation, Method m, Object[] pValues, Object o) { - this.execLocation = execLocation; - this.m = m; - this.pValues = pValues; - this.o = o; - } - - @Override - public Object call() { - - RapidUtils.sendAnimationMsg(config, AnimationMsg.AC_INITIAL_IMG); - RapidUtils.sendAnimationMsg(config, AnimationMsg.AC_PREPARE_DATA); - if (execLocation == Constants.LOCATION_LOCAL) { - try { - - // First try to see if we can offload this task to a more powerful device that is in D2D - // distance. - // Do this only if we are not connected to a clone, otherwise it becomes a mess. - if (!onLineClear && !onLineSSL) { - - // I'm sure this cast is correct since it has been us who wrote the object before. - try { - if (d2dSetPhones != null && d2dSetPhones.size() > 0) { - Iterator it = d2dSetPhones.iterator(); - // This is the best phone from the D2D ones since the set is sorted and this is the - // first element. - PhoneSpecs otherPhone = it.next(); - if (otherPhone.compareTo(myPhoneSpecs) > 0) { - RapidUtils.sendAnimationMsg(config, AnimationMsg.AC_OFFLOAD_D2D); - this.result = executeD2D(otherPhone); - } - } - } catch (IOException | ClassNotFoundException | SecurityException - | NoSuchMethodException e) { - Log.e(TAG, "Error while trying to run the method D2D: " + e); - } - } - - // If the D2D execution didn't take place or something happened that the execution was - // interrupted the result would still be null. - if (this.result == null) { - RapidUtils.sendAnimationMsg(config, AnimationMsg.AC_DECISION_LOCAL); - this.result = executeLocally(m, pValues, o); - } - - } catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException e) { - Log.e(TAG, "Error while running the method locally: " + e); - } - } else if (execLocation == Constants.LOCATION_REMOTE) { - try { - this.result = executeRemotely(m, pValues, o); - if (this.result instanceof InvocationTargetException) { - // The remote execution throwed an exception, try to run the method locally. - Log.w(TAG, "The result was InvocationTargetException. Running the method locally"); - this.result = executeLocally(m, pValues, o); - } - } catch (IllegalArgumentException | SecurityException | IllegalAccessException - | InvocationTargetException | ClassNotFoundException | NoSuchMethodException e) { - Log.e(TAG, "Error while trying to run the method remotely: " + e); - } - } - - return this.result; - } - - /** - * Execute the method locally - * - * @param m - * @param pValues - * @param o - * @return - * @throws IllegalArgumentException - * @throws IllegalAccessException - * @throws InvocationTargetException - */ - private Object executeLocally(Method m, Object[] pValues, Object o) - throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { - - Profiler profiler = null; - ProgramProfiler progProfiler = new ProgramProfiler(mAppName, m.getName()); - DeviceProfiler devProfiler = new DeviceProfiler(mContext); - NetworkProfiler netProfiler = null; - profiler = new Profiler(mRegime, progProfiler, netProfiler, devProfiler); - - // Start tracking execution statistics for the method - profiler.startExecutionInfoTracking(); - - // Make sure that the method is accessible - // RapidUtils.sendAnimationMsg(config, RapidMessages.AC_EXEC_LOCAL); - Object result = null; - Long startTime = System.nanoTime(); - m.setAccessible(true); - result = m.invoke(o, pValues); // Access it - mPureLocalDuration = System.nanoTime() - startTime; - Log.d(TAG, "LOCAL " + m.getName() + ": Actual Invocation duration - " - + mPureLocalDuration / 1000000 + "ms"); - - // Collect execution statistics - profiler.stopAndLogExecutionInfoTracking(prepareDataDuration, mPureLocalDuration); - - RapidUtils.sendAnimationMsg(config, AnimationMsg.AC_LOCAL_FINISHED); - - return result; - } - - /** - * Execute the method on a phone that is close to us so that we can connect on D2D mode. If we - * are here, it means that this phone is not connected to a clone, so we can define the clone to - * be this D2D device. - * - * @param otherPhone - * @return - * @throws IllegalArgumentException - * @throws IllegalAccessException - * @throws InvocationTargetException - * @throws IOException - * @throws ClassNotFoundException - * @throws NoSuchMethodException - * @throws SecurityException - */ - private Object executeD2D(PhoneSpecs otherPhone) - throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, - IOException, ClassNotFoundException, SecurityException, NoSuchMethodException { - - // otherPhone.setIp("192.168.43.1"); - Log.i(TAG, "Trying to execute the method using D2D on device: " + otherPhone); - sClone = new Clone("vb-D2D device", otherPhone.getIp(), config.getClonePort()); - establishConnection(); - sendApk(); - Object result = executeRemotely(m, pValues, o); - closeConnection(); - return result; - } - - /** - * Execute method remotely - * - * @param m - * @param pValues - * @param o - * @return - * @throws IllegalArgumentException - * @throws IllegalAccessException - * @throws InvocationTargetException - * @throws NoSuchMethodException - * @throws ClassNotFoundException - * @throws SecurityException - */ - private Object executeRemotely(Method m, Object[] pValues, Object o) - throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, - SecurityException, ClassNotFoundException, NoSuchMethodException { - Object result = null; - - RapidUtils.sendAnimationMsg(config, AnimationMsg.AC_DECISION_OFFLOAD_AS); - - // Maybe the developer has implemented the prepareDataOnClient() method that helps him prepare - // the data based on where the execution will take place then call it. - // Prepare the data by calling the prepareData(localFraction) implemented by the developer. - try { - long s = System.nanoTime(); - prepareDataMethod = o.getClass().getDeclaredMethod("prepareDataOnClient"); - prepareDataMethod.setAccessible(true); - prepareDataMethod.invoke(o); - prepareDataDuration = System.nanoTime() - s; - } catch (NoSuchMethodException e) { - Log.w(TAG, "The method prepareDataOnClient() does not exist"); - } - - ProgramProfiler progProfiler = new ProgramProfiler(mAppName, m.getName()); - DeviceProfiler devProfiler = new DeviceProfiler(mContext); - NetworkProfiler netProfiler = new NetworkProfiler(); - Profiler profiler = new Profiler(mRegime, progProfiler, netProfiler, devProfiler); - - // Start tracking execution statistics for the method - profiler.startExecutionInfoTracking(); - - try { - Long startTime = System.nanoTime(); - mOutStream.write(RapidMessages.AC_OFFLOAD_REQ_AS); - result = sendAndExecute(m, pValues, o, mObjInStream, mObjOutStream); - - Long duration = System.nanoTime() - startTime; - Log.d(TAG, "REMOTE " + m.getName() + ": Actual Send-Receive duration - " - + duration / 1000000 + "ms"); - // Collect execution statistics - profiler.stopAndLogExecutionInfoTracking(prepareDataDuration, mPureRemoteDuration); - - RapidUtils.sendAnimationMsg(config, AnimationMsg.AC_OFFLOADING_FINISHED); - } catch (Exception e) { - // No such host exists, execute locally - Log.e(TAG, "REMOTE ERROR: " + m.getName() + ": " + e); - e.printStackTrace(); - profiler.stopAndDiscardExecutionInfoTracking(); - result = executeLocally(m, pValues, o); - // ConnectionRepair repair = new ConnectionRepair(); - // repair.start(); - } - return result; - } - - /** - * Send the object (along with method and parameters) to the remote server for execution - * - * @param o - * @param m - * @param pValues - * @param objOut - * @throws IOException - */ - private void sendObject(Object o, Method m, Object[] pValues, ObjectOutputStream objOut) - throws IOException { - objOut.reset(); - Log.d(TAG, "Write Object and data"); - - // Send the number of clones needed to execute the method - objOut.writeInt(nrClones); - - // Send object for execution - objOut.writeObject(o); - - // Send the method to be executed - // Log.d(TAG, "Write Method - " + m.getName()); - objOut.writeObject(m.getName()); - - // Log.d(TAG, "Write method parameter types"); - objOut.writeObject(m.getParameterTypes()); - - // Log.d(TAG, "Write method parameter values"); - objOut.writeObject(pValues); - objOut.flush(); - } - - /** - * Send the object, the method to be executed and parameter values to the remote server for - * execution. - * - * @param m method to be executed - * @param pValues parameter values of the remoted method - * @param o the remoted object - * @param objIn ObjectInputStream which to read results from - * @param objOut ObjectOutputStream which to write the data to - * @return result of the remoted method or an exception that occurs during execution - * @throws IOException - * @throws ClassNotFoundException - * @throws NoSuchMethodException - * @throws InvocationTargetException - * @throws IllegalAccessException - * @throws SecurityException - * @throws IllegalArgumentException - */ - private Object sendAndExecute(Method m, Object[] pValues, Object o, ObjectInputStream objIn, - ObjectOutputStream objOut) - throws IOException, ClassNotFoundException, IllegalArgumentException, SecurityException, - IllegalAccessException, InvocationTargetException, NoSuchMethodException { - - // Send the object itself - sendObject(o, m, pValues, objOut); - - // TODO To be more precise, this message should be sent by the AS, but for simplicity I put it - // here. - RapidUtils.sendAnimationMsg(config, AnimationMsg.AS_RUN_METHOD); - - // Read the results from the server - Log.d(TAG, "Read Result"); - Object response = objIn.readObject(); - - // TODO To be more precise, this message should be sent by the AS, but for simplicity I put it - // here. - RapidUtils.sendAnimationMsg(config, AnimationMsg.AS_RESULT_AC); - - ResultContainer container = (ResultContainer) response; - Object result; - - Class[] pTypes = {Remoteable.class}; - try { - // Use the copyState method that must be defined for all Remoteable - // classes to copy the state of relevant fields to the local object - o.getClass().getMethod("copyState", pTypes).invoke(o, container.objState); - } catch (NullPointerException e) { - // Do nothing - exception happened remotely and hence there is - // no object state returned. - // The exception will be returned in the function result anyway. - Log.d(TAG, "Exception received from remote server - " + container.functionResult); - } - - result = container.functionResult; - mPureRemoteDuration = container.pureExecutionDuration; - - Log.d(TAG, "Finished remote execution"); - - return result; - } - } - - /** - * Send APK file to the remote server - * - * @param apkName file name of the APK file (full path) - * @param objOut ObjectOutputStream to write the file to - * @throws IOException - * @throws NameNotFoundException - */ - private void sendApk() { - - try { - Log.d(TAG, "Getting apk data"); - String apkName = mPManager.getApplicationInfo(mAppName, 0).sourceDir; - File apkFile = new File(apkName); - Log.d(TAG, "Apk name - " + apkName); - - mOutStream.write(RapidMessages.AC_REGISTER_AS); - // Send apkName and apkLength to clone. - // The clone will compare these information with what he has and tell - // if he doesn't have the apk or this one differs in size. - mObjOutStream.writeObject(mAppName); - mObjOutStream.writeInt((int) apkFile.length()); - mObjOutStream.flush(); - int response = mInStream.read(); - - if (response == RapidMessages.AS_APP_REQ_AC) { - // Send the APK file if needed - - FileInputStream fin = new FileInputStream(apkFile); - BufferedInputStream bis = new BufferedInputStream(fin); - - // Send the file - Log.d(TAG, "Sending apk"); - int BUFFER_SIZE = 8192; - byte[] tempArray = new byte[BUFFER_SIZE]; - int read = 0; - while ((read = bis.read(tempArray, 0, tempArray.length)) > -1) { - mObjOutStream.write(tempArray, 0, read); - // Log.d(TAG, "Sent " + totalRead + " of " + apkFile.length() + " bytes"); - } - mObjOutStream.flush(); - RapidUtils.closeQuietly(bis); - } - } catch (IOException e) { - fallBackToLocalExecution("IOException: " + e.getMessage()); - } catch (NameNotFoundException e) { - fallBackToLocalExecution("Application not found: " + e.getMessage()); - } catch (Exception e) { - fallBackToLocalExecution("Exception: " + e.getMessage()); - } - } - - - /** - * Take care of a broken connection - try restarting it when something breaks down immediately or - * alternatively listen to changing network conditions - */ - public class ConnectionRepair extends Thread { - /** - * Simple reestablish the connection - */ - @Override - public void run() { - // Try simply restarting the connection - Log.d(TAG, "Trying to reestablish connection to the server"); - synchronized (this) { - if (!onLineClear && !onLineSSL) { - // Show a spinning dialog while connecting to the Manager and to the clone. - // pd = ProgressDialog.show(mContext, "Working..", "Initial network tasks...", true, - // false); - (new InitialNetworkTasks()).execute(sClone); - - // establishConnection(); - } - } - - // If still offline, establish intent listeners that would try to - // restart the connection when the service comes back up - synchronized (this) { - if (!onLineClear && !onLineSSL) { - Log.d(TAG, "Reestablishing failed - register listeners for reconnecting"); - final ConnectivityManager connectivityManager = - (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE); - - BroadcastReceiver networkStateReceiver = new BroadcastReceiver() { - public void onReceive(Context context, Intent intent) { - context.unregisterReceiver(this); - NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo(); - if (netInfo != null) { - Log.d(TAG, "Network back up, try reestablishing the connection"); - // establishConnection(); - - pd = ProgressDialog.show(mContext, "Working..", "Initial network tasks...", true, - false); - (new InitialNetworkTasks()).execute(sClone); - } - } - }; - IntentFilter networkStateFilter = - new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); - mContext.registerReceiver(networkStateReceiver, networkStateFilter); - } - } - } - } - - public String getConnectionType() { - return NetworkProfiler.currentNetworkTypeName; - } - - public void setUserChoice(int userChoice) { - this.userChoice = userChoice; - mDSE.setUserChoice(userChoice); - } - - public int getUserChoice() { - return userChoice; - } - - public int getRegime() { - return mRegime; - } - - public void setNrClones(int nrClones) { - Log.i(TAG, "Changing nrClones to: " + nrClones); - this.nrClones = nrClones; - } - - public Frontend getGvirtusFrontend() { - return gVirtusFrontend; - } - - public void setGvirtusFrontend(Frontend gVirtusFrontend) { - this.gVirtusFrontend = gVirtusFrontend; - } - - public Configuration getConfig() { - return config; - } - - public Context getContext() { - return mContext; - } - - public void setDataRate(int dataRate) { - NetworkProfiler.setDataRate(dataRate); - } - - /** - * Used to measure the costs of connection with the clone when using different communication - * types. - * - * @param givenCommType CLEAR, SSL - * @param buffLogFile - * @throws IOException - */ - public void testConnection(COMM_TYPE givenCommType, BufferedWriter buffLogFile) - throws IOException { - - if (onLineClear || onLineSSL) { - closeConnection(); - } - commType = givenCommType; - - long startTime = System.nanoTime(); - - if (givenCommType == COMM_TYPE.SSL) { - establishSslConnection(); - } else { - establishConnection(); - } - - long totalTime = System.nanoTime() - startTime; - - if (buffLogFile != null) { - buffLogFile.write(totalTime + "\n"); - } - } - - /** - * Used to measure the costs of sending data of different size with different communication - * protocols. - * - * @param givenCommType CLEAR, SSL - * @param nrBytesToSend - * @param bytesToSend - * @param buffLogFile - * @return - * @throws IOException - */ - public long testSendBytes(int nrBytesToSend, byte[] bytesToSend, BufferedWriter buffLogFile) - throws IOException { - - long txTime = -1; - long txBytes = -1; - - switch (nrBytesToSend) { - case 1: - txBytes = NetworkProfiler.getProcessTxBytes(); - txTime = System.nanoTime(); - mOutStream.write(RapidMessages.PING); - mInStream.read(); - txTime = System.nanoTime() - txTime; - txBytes = NetworkProfiler.getProcessTxBytes() - txBytes; - break; - - case 4: - mOutStream.write(RapidMessages.SEND_INT); - // sleep(3*1000); - - txBytes = NetworkProfiler.getProcessTxBytes(); - txTime = System.nanoTime(); - mObjOutStream.writeInt((int) System.currentTimeMillis()); - mObjOutStream.flush(); - mInStream.read(); - txTime = System.nanoTime() - txTime; - txBytes = NetworkProfiler.getProcessTxBytes() - txBytes; - - // txTime = mObjInStream.readLong(); - - break; - - default: - mOutStream.write(RapidMessages.SEND_BYTES); - // sleep(3*1000); - - txBytes = NetworkProfiler.getProcessTxBytes(); - txTime = System.nanoTime(); - mObjOutStream.writeObject(bytesToSend); - mObjOutStream.flush(); - mInStream.read(); - txTime = System.nanoTime() - txTime; - txBytes = NetworkProfiler.getProcessTxBytes() - txBytes; - // txTime = mObjInStream.readLong(); - - break; - } - - if (buffLogFile != null) { - buffLogFile.write(txTime + "\n"); - buffLogFile.flush(); - } - - Log.i(TAG, "Sent " + nrBytesToSend + " bytes in " + txTime / 1000000000.0 + " seconds."); - - return txBytes; - } - - public long testReceiveBytes(int nrBytesToReceive, BufferedWriter buffLogFile) - throws IOException, ClassNotFoundException { - - long rxBytes = -1; - long rxTime = -1; - - switch (nrBytesToReceive) { - case 1: - mOutStream.write(RapidMessages.PING); - - rxBytes = NetworkProfiler.getProcessRxBytes(); - rxTime = System.nanoTime(); - mInStream.read(); - rxTime = System.nanoTime() - rxTime; - rxBytes = NetworkProfiler.getProcessRxBytes() - rxBytes; - break; - - case 4: - mOutStream.write(RapidMessages.RECEIVE_INT); - - rxBytes = NetworkProfiler.getProcessRxBytes(); - // rxTime = System.nanoTime(); - mObjInStream.readInt(); - mOutStream.write(1); - mOutStream.flush(); - rxTime = mObjInStream.readLong(); - - // sleep(8*1000); - // rxTime = System.nanoTime() - rxTime; - rxBytes = NetworkProfiler.getProcessRxBytes() - rxBytes; - - break; - - default: - mOutStream.write(RapidMessages.RECEIVE_BYTES); - mObjOutStream.writeInt(nrBytesToReceive); - mObjOutStream.flush(); - - rxBytes = NetworkProfiler.getProcessRxBytes(); - // rxTime = System.nanoTime(); - mObjInStream.readObject(); - mOutStream.write(1); - mOutStream.flush(); - rxTime = mObjInStream.readLong(); - - // sleep(8*1000); - // rxTime = System.nanoTime() - rxTime; - rxBytes = NetworkProfiler.getProcessRxBytes() - rxBytes; - - break; - } - - if (buffLogFile != null) { - buffLogFile.write(rxTime + "\n"); - buffLogFile.flush(); - } - - Log.i(TAG, "Received " + nrBytesToReceive + " bytes in " + rxTime / 1000000000.0 + " seconds."); - - return rxBytes; - } - - @SuppressWarnings("unused") - private void sleep(long millis) { - try { - Thread.sleep(millis); - } catch (InterruptedException e) { - } - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/DSE.java b/AccelerationClient/src/eu/project/rapid/ac/DSE.java deleted file mode 100755 index ed0d408..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/DSE.java +++ /dev/null @@ -1,314 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac; - -import java.util.Deque; - -import android.util.Log; -import eu.project.rapid.ac.db.DBCache; -import eu.project.rapid.ac.db.DBEntry; -import eu.project.rapid.ac.profilers.NetworkProfiler; -import eu.project.rapid.ac.utils.Constants; - -/** - * DSE decides whether to execute the requested method locally or remotely. - */ -public class DSE { - - private static final String TAG = "DSE"; - private static final boolean VERBOSE_LOG = false; - - // To be used in case of no previous remote execution. - // If the ulRate and dlRate are bigger than these values then we offload - private static final int MIN_UL_RATE_OFFLOAD_1_TIME = 256 * 1000; // b/s - private static final int MIN_DL_RATE_OFFLOAD_1_TIME = 256 * 1000; // b/s - - private int userChoice; - - // private int programOrientedDecNr = 1; - - DSE(int userChoice) { - this.userChoice = userChoice; - } - - /** - * Decide whether to execute remotely, locally, or hybrid - * - * @return The type of execution: LOCAL, REMOTE, HYBRID - */ - public int findExecLocation(String appName, String methodName) { - - if (!DFE.onLineClear && !DFE.onLineSSL || userChoice == Constants.LOCATION_LOCAL) { - // if (userChoice == Constants.LOCATION_LOCAL) { - return Constants.LOCATION_LOCAL; - } else if (userChoice == Constants.LOCATION_REMOTE) { - return Constants.LOCATION_REMOTE; - } else if (userChoice == Constants.LOCATION_HYBRID) { - return Constants.LOCATION_HYBRID; - } else { // if (userChoice == RapidConstants.LOCATION_DYNAMIC) { - int ulRate = NetworkProfiler.lastUlRate.getBw(); - int dlRate = NetworkProfiler.lastDlRate.getBw(); - - if (shouldOffloadDBCache(appName, methodName, ulRate, dlRate)) { - Log.d(TAG, "Execute Remotely - True"); - return Constants.LOCATION_REMOTE; - } else { - Log.d(TAG, "Execute Remotely - False"); - return Constants.LOCATION_LOCAL; - } - } - } - - /** - * @param appName - * @param methodName - * @param currUlRate - * @param currDlRate - * @return True if the method should be executed remotely
- * False otherwise. - */ - private boolean shouldOffloadDBCache(String appName, String methodName, int currUlRate, - int currDlRate) { - - DBCache dbCache = DBCache.getDbCache(); - - Log.i(TAG, - "Trying to decide using DB cache where to execute the method: appName=" + appName - + ", methodName=" + methodName + ", currUlRate=" + currUlRate + ", currDlRate=" - + currDlRate); - Log.i(TAG, String.format("DB cache has %d entries and %d measurements", dbCache.size(), - dbCache.nrElements())); - - // Variables needed for the local executions - int nrLocalExec = 0; - long meanDurLocal = 0, meanEnergyLocal = 0; - - // Variables needed for the remote executions - int nrRemoteExec = 0; - long meanDurRemote1 = 0, meanEnergyRemote1 = 0; - long meanDurRemote2 = 0, meanEnergyRemote2 = 0; - long meanDurRemote = 0, meanEnergyRemote = 0; - - // Check if the method has been executed LOCALLY in previous runs - // long t0 = System.currentTimeMillis(); - Deque localResults = dbCache.getAllEntriesFilteredOn(appName, methodName, "LOCAL"); - nrLocalExec = localResults.size(); - - // Check if the method has been executed REMOTELY in previous runs - Deque remoteResults = dbCache.getAllEntriesFilteredOn(appName, methodName, "REMOTE", - NetworkProfiler.currentNetworkTypeName, NetworkProfiler.currentNetworkSubtypeName); - nrRemoteExec = remoteResults.size(); - // - // long dur = System.currentTimeMillis() - t0; - // Log.i(TAG, "DB access time for local and remote queries: " + dur + " ms"); - - // DECISION 1 - // If the number of previous remote executions is zero and the current connection is good - // then offload the method to see how it goes. - if (nrRemoteExec == 0) { - if (currUlRate > MIN_UL_RATE_OFFLOAD_1_TIME && currDlRate > MIN_DL_RATE_OFFLOAD_1_TIME) { - Log.i(TAG, "Decision 1: No previous remote executions. Good connectivity."); - return true; - } else { - Log.i(TAG, "Decision 1: No previous remote executions. Bad connectivity."); - return false; - } - } - - // Local part - // Calculate the meanDurLocal and meanEnergyLocal from the previous runs. - // Give more weight to recent measurements. - if (VERBOSE_LOG) { - Log.i(TAG, "------------ The local executions of the method:"); - } - - long localDuration, localEnergy; - long[] localTimestamps = new long[nrLocalExec]; - int i = 0; - for (DBEntry e : localResults) { - meanDurLocal += e.getExecDuration(); - meanEnergyLocal += e.getExecEnergy(); - localTimestamps[i] = e.getTimestamp(); - - i++; - if (i > 1) { - meanDurLocal /= 2; - meanEnergyLocal /= 2; - } - - if (VERBOSE_LOG) { - Log.i(TAG, "duration: " + localDuration + " energy: " + localEnergy + " timestamp: " - + e.getTimestamp()); - } - } - Log.i(TAG, "nrLocalExec: " + nrLocalExec); - Log.i(TAG, "meanDurLocal: " + meanDurLocal + "ns (" + meanDurLocal / 1000000000.0 + "s)"); - Log.i(TAG, "meanEnergyLocal: " + meanEnergyLocal); - - // Remote part - long[] remoteDurations = new long[nrRemoteExec]; - long[] remoteEnergies = new long[nrRemoteExec]; - int[] remoteUlRates = new int[nrRemoteExec]; - int[] remoteDlRates = new int[nrRemoteExec]; - long[] remoteTimestamps = new long[nrRemoteExec]; - i = 0; - if (VERBOSE_LOG) { - Log.i(TAG, "------------ The remote executions of the method:"); - } - for (DBEntry e : remoteResults) { - remoteDurations[i] = e.getExecDuration(); - remoteEnergies[i] = e.getExecEnergy(); - remoteUlRates[i] = e.getUlRate(); - remoteDlRates[i] = e.getDlRate(); - remoteTimestamps[i] = e.getTimestamp(); - - if (VERBOSE_LOG) { - Log.i(TAG, - "duration: " + remoteDurations[i] + " energy: " + remoteEnergies[i] + " ulRate: " - + remoteUlRates[i] + " dlRate: " + remoteDlRates[i] + " timestamp: " - + remoteTimestamps[i]); - } - - i++; - } - Log.i(TAG, "nrRemoteExec: " + nrRemoteExec); - - // DECISION 2 - int NR_TIMES_SWITCH_SIDES = 10; - int count = 0; - String prevExecLocation = null; - for (DBEntry e : dbCache.getAllEntriesFilteredOn(methodName)) { - if (count < NR_TIMES_SWITCH_SIDES - && (prevExecLocation == null || e.getExecLocation().equals(prevExecLocation))) { - prevExecLocation = e.getExecLocation(); - count++; - } else { - break; - } - } - - if (count == NR_TIMES_SWITCH_SIDES) { - if (prevExecLocation.equals("REMOTE")) { - Log.i(TAG, "Decision 2: Too many remote executions in a row."); - return false; - } else if (prevExecLocation.equals("LOCAL")) { - Log.i(TAG, "Decision 2: Too many local executions in a row."); - if (currUlRate > MIN_UL_RATE_OFFLOAD_1_TIME && currDlRate > MIN_DL_RATE_OFFLOAD_1_TIME) { - Log.i(TAG, "Decision 2->1: No previous remote executions. Good connectivity."); - return true; - } else { - Log.i(TAG, "Decision 2->1: No previous remote executions. Bad connectivity."); - return false; - } - } else { - Log.e(TAG, "Decision 2: This shouldn't happen, check the implementation."); - } - } - - // DECISION 3 - // Calculate two different mean values for the offloaded execution: - // 1. The first are the same as for the local execution, gives more weight to recent runs - // 2. The second are calculated as the average of the three closest values to the currentUlRate - // and currDlRate - int minDistIndex1 = 0, minDistIndex2 = 0, minDistIndex3 = 0; - double minDist1 = Double.POSITIVE_INFINITY, minDist2 = Double.POSITIVE_INFINITY, - minDist3 = Double.POSITIVE_INFINITY; - for (i = 0; i < nrRemoteExec; i++) { - // Calculate the first meanDuration and meanEnergy - // The first formula is the same as for the local executions, - // gives more importance to the last measurements. - meanDurRemote1 += remoteDurations[i]; - meanEnergyRemote1 += remoteEnergies[i]; - if (i > 0) { - meanDurRemote1 /= 2; - meanEnergyRemote1 /= 2; - } - - // Keep the indexes of the three measurements that have - // the smallest distance dist(ulRate, dlRate, currUlRate, currDlRate) - // minDist1 < minDist2 < minDist3 - double newDist = dist(remoteUlRates[i], remoteDlRates[i], currUlRate, currDlRate); - if (newDist < minDist1) { - minDist3 = minDist2; - minDistIndex3 = minDistIndex2; - - minDist2 = minDist1; - minDistIndex2 = minDistIndex1; - - minDist1 = newDist; - minDistIndex1 = i; - } else if (newDist < minDist2) { - minDist3 = minDist2; - minDistIndex3 = minDistIndex2; - - minDist2 = newDist; - minDistIndex2 = i; - } else if (newDist < minDist3) { - minDist3 = newDist; - minDistIndex3 = i; - } - } - - // Give more weight to the closest point - meanDurRemote2 = (((remoteDurations[minDistIndex3] + remoteDurations[minDistIndex2]) / 2) - + remoteDurations[minDistIndex1]) / 2; - meanEnergyRemote2 = (((remoteEnergies[minDistIndex3] + remoteEnergies[minDistIndex2]) / 2) - + remoteEnergies[minDistIndex1]) / 2; - - meanDurRemote = (meanDurRemote1 + meanDurRemote2) / 2; - meanEnergyRemote = (meanEnergyRemote1 + meanEnergyRemote2) / 2; - - // Log.d(TAG, "meanDurRemote1: " + meanDurRemote1 + " meanDurRemote2: " + meanDurRemote2); - Log.d(TAG, "meanDurRemote: " + meanDurRemote + "ns (" + meanDurRemote / 1000000000.0 + "s)"); - // Log.d(TAG, - // "meanEnergyRemote1: " + meanEnergyRemote1 + " meanEnergyRemote2: " + meanEnergyRemote2); - Log.d(TAG, " meanEnergyRemote: " + meanEnergyRemote); - - Log.i(TAG, "Decision 3."); - if (userChoice == Constants.LOCATION_DYNAMIC_TIME) { - Log.d(TAG, "Making a choice for fast execution"); - return meanDurRemote <= meanDurLocal; - } else if (userChoice == Constants.LOCATION_DYNAMIC_ENERGY) { - Log.d(TAG, "Making a choice for low energy"); - return meanEnergyRemote <= meanEnergyLocal; - } else { - Log.d(TAG, "Making a choice for low energy and fast execution"); - return (meanDurRemote <= meanDurLocal) && (meanEnergyRemote <= meanEnergyLocal); - } - } - - private double dist(int ul1, int dl1, int ul2, int dl2) { - return Math.sqrt((ul2 - ul1) * (ul2 - ul1) + (dl2 - dl1) * (dl2 - dl1)); - } - - public void setUserChoice(int userChoice) { - this.userChoice = userChoice; - } - - public int getUserChoice() { - return this.userChoice; - } - - @SuppressWarnings("unused") - private void sleep(int millis) { - try { - Thread.sleep(millis); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/QoS.java b/AccelerationClient/src/eu/project/rapid/ac/QoS.java deleted file mode 100644 index b8e1160..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/QoS.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac; - -public @interface QoS { - String[]terms() default ""; - String[]operators() default ""; - String[]thresholds() default ""; -} \ No newline at end of file diff --git a/AccelerationClient/src/eu/project/rapid/ac/RapidSettingsActivity.java b/AccelerationClient/src/eu/project/rapid/ac/RapidSettingsActivity.java deleted file mode 100644 index 2a6c4ee..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/RapidSettingsActivity.java +++ /dev/null @@ -1,13 +0,0 @@ -package eu.project.rapid.ac; - -/** - * This activity will have the appropriate buttons to control the settings of the - * AccelerationClient.
- * It will be be used to start and stop the D2DClientService, for example, and for much more. - * - * @author sokol - * - */ -public class RapidSettingsActivity { - -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/Remote.java b/AccelerationClient/src/eu/project/rapid/ac/Remote.java deleted file mode 100644 index 94c001a..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/Remote.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac; - -public @interface Remote { - boolean computeIntensive() default true; // true if the task is computation intensive - boolean dataIntensive() default false; // true if the task is data intensive - boolean networkIntensive() default false; // true if the task is network intensive - boolean gpuComputation() default false; // true if the task will perform GPU computation - boolean nativeCode() default false; // true if the task will execute native code - boolean parallelizable() default false; // true if the task is parallelizable -} \ No newline at end of file diff --git a/AccelerationClient/src/eu/project/rapid/ac/Remoteable.java b/AccelerationClient/src/eu/project/rapid/ac/Remoteable.java deleted file mode 100755 index 2c4b3ae..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/Remoteable.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac; - -import java.io.File; -import java.io.Serializable; -import java.util.LinkedList; - -import android.util.Log; - -public abstract class Remoteable implements Serializable { - - private static final long serialVersionUID = 1L; - - public abstract void copyState(Remoteable state); - - /** - * Load all provided shared libraries - used when an exception is thrown on the server-side, - * meaning that the necessary libraries have not been loaded. x86 version of the libraries - * included in the APK of the remote application are then loaded and the operation is re-executed. - * - * @param libFiles - */ - public void loadLibraries(LinkedList libFiles) { - for (File libFile : libFiles) { - Log.d("Remoteable", - "Loading library: " + libFile.getName() + " (" + libFile.getAbsolutePath() + ")"); - System.load(libFile.getAbsolutePath()); - } - } - - /** - * Override this method if you want to prepare the data before executing the method. - * - * This can be useful in case the class contains data that are not serializable but are needed by - * the method when offloaded. Use this method to convert the data to some serializable form before - * the method is offloaded. - * - * Do not explicitly call this method. It will be automatically called by the framework before - * offloading. - */ - public void prepareDataOnClient() {}; - - /** - * Override this method if you want to prepare the data before executing the method on the VM. - * - * This can be useful in case the class contains data that are not serializable and were - * serialized using the method prepareDataOnClient. - * - * Do not explicitly call this method. It will be automatically called by the framework before - * running the method on the VM. - */ - public void prepareDataOnServer() {}; -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/ResultContainer.java b/AccelerationClient/src/eu/project/rapid/ac/ResultContainer.java deleted file mode 100755 index 990897c..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/ResultContainer.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac; - -import java.io.Serializable; - -/** - * Container of remote execution data - to send back results of the executed - * operation, the state of the object and actual execution time - * - */ -public class ResultContainer implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 6289277906217259082L; - - public Object objState; - public Object functionResult; - public Long getObjectDuration; - public Long pureExecutionDuration; - - /** - * Wrapper of results returned by remote server - state of the object the - * call was executed on and function result itself - * - * @param state - * state of the remoted object - * @param result - * result of the function executed on the object - */ - public ResultContainer(Object state, Object result, Long getObjectDuration, Long duration) { - objState = state; - functionResult = result; - this.getObjectDuration = getObjectDuration; - pureExecutionDuration = duration; - } - - /** - * Used when an exception happens, to return the exception as a result of - * remote invocation - * - * @param result - */ - public ResultContainer(Object result, Long getObjectDuration) { - objState = null; - functionResult = result; - this.getObjectDuration = getObjectDuration; - pureExecutionDuration = null; - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/d2d/D2DClientService.java b/AccelerationClient/src/eu/project/rapid/ac/d2d/D2DClientService.java deleted file mode 100644 index e90d574..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/d2d/D2DClientService.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac.d2d; - -import java.io.IOException; -import java.net.DatagramPacket; -import java.net.MulticastSocket; -import java.util.Iterator; -import java.util.Set; -import java.util.TreeSet; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import android.app.IntentService; -import android.content.Context; -import android.content.Intent; -import android.net.wifi.WifiManager; -import android.os.Build; -import android.util.Log; -import eu.project.rapid.ac.d2d.D2DMessage.MsgType; -import eu.project.rapid.ac.utils.Constants; -import eu.project.rapid.ac.utils.Utils; - -/** - * This thread will be started by clients that run the DFE so that these clients can get the HELLO - * messages sent by the devices that act as D2D Acceleration Server. - * - * @author sokol - * - */ -public class D2DClientService extends IntentService { - - private static final String TAG = D2DClientService.class.getName(); - ScheduledThreadPoolExecutor setWriterThread = - (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(5); - private D2DSetWriter setWriterRunnable; - public static final int FREQUENCY_WRITE_D2D_SET = 5 * 60 * 1013; // Every 5 minutes save the set - public static final int FREQUENCY_READ_D2D_SET = 1 * 60 * 1011; // Every 1 minute read the set - // from the file - private MulticastSocket receiveSocket; - private Set setD2dPhones = new TreeSet(); // Sorted by specs - - public D2DClientService() { - super(D2DClientService.class.getName()); - } - - @Override - protected void onHandleIntent(Intent intent) { - if (setWriterRunnable == null) { - setWriterRunnable = new D2DSetWriter(); - } - setWriterThread.scheduleWithFixedDelay(setWriterRunnable, FREQUENCY_WRITE_D2D_SET, - FREQUENCY_WRITE_D2D_SET, TimeUnit.MILLISECONDS); - - try { - Log.i(TAG, "Thread started"); - writeSetOnFile(); - - WifiManager.MulticastLock lock = null; - WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); - Log.i(TAG, "Trying to acquire multicast lock..."); - if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { - if (lock == null) { - Log.i(TAG, "lock was null, creating..."); - lock = wifi.createMulticastLock("WiFi_Lock"); - } - lock.setReferenceCounted(true); - lock.acquire(); - Log.i(TAG, "Lock acquired!"); - } - - receiveSocket = new MulticastSocket(Constants.D2D_BROADCAST_PORT); - receiveSocket.setBroadcast(true); - Log.i(TAG, "Started listening on multicast socket."); - - try { - // This will be interrupted when the OS kills the service - while (true) { - Log.i(TAG, "Waiting for broadcasted data..."); - byte[] data = new byte[1024]; - DatagramPacket packet = new DatagramPacket(data, data.length); - receiveSocket.receive(packet); - Log.d(TAG, "Received a new broadcast packet from: " + packet.getAddress()); - processPacket(packet); - } - } catch (IOException e) { - Log.d(TAG, "The socket was closed."); - } - - Log.i(TAG, "Stopped receiving data!"); - } catch (IOException e) { - // We expect this to happen when more than one DFE on the same phone will try to create - // this service and the port will be busy. This way only one service will be listening for D2D - // messages. This service will be responsible for writing the received messages on a file so - // that the DFEs of all applications could read them. - Log.d(TAG, - "Could not create D2D multicast socket, maybe the service is already started by another DFE: " - + e); - // e.printStackTrace(); - } - } - - /** - * Process the packet received by another device in a D2D scenario. Create a D2Dmessage and if - * this is a HELLO message then store the specifics of the other device into the Map. If a new - * device is added to the map and more than 5 minutes have passed since the last time we saved the - * devices on the file, then save the set in the filesystem so that other DFEs can read it. - * - * @param packet - */ - private void processPacket(DatagramPacket packet) { - try { - D2DMessage msg = new D2DMessage(packet.getData()); - Log.d(TAG, "Received: <== " + msg); - if (msg.getMsgType() == MsgType.HELLO) { - PhoneSpecs otherPhone = msg.getPhoneSpecs(); - if (setD2dPhones.contains(otherPhone)) { - setD2dPhones.remove(otherPhone); - } - otherPhone.setTimestamp(System.currentTimeMillis()); - otherPhone.setIp(packet.getAddress().getHostAddress()); - setD2dPhones.add(otherPhone); - // FIXME writing the set here is too heavy but I want this just for the demo. Later fix this - // with a smarter alternative. - writeSetOnFile(); - } - } catch (IOException | ClassNotFoundException e) { - Log.e(TAG, "Error while processing the packet: " + e); - } - } - - private class D2DSetWriter implements Runnable { - @Override - public void run() { - // Write the set in the filesystem so that other DFEs can use the D2D phones when needed. - Iterator it = setD2dPhones.iterator(); - // First clean the set from devices that have not been pinging recently - while (it.hasNext()) { - // If the last time we have seen this device is 5 pings before, then remove it. - if ((System.currentTimeMillis() - it.next().getTimestamp()) > 5 - * Constants.D2D_BROADCAST_INTERVAL) { - it.remove(); - } - } - writeSetOnFile(); - } - } - - private void writeSetOnFile() { - - try { - Log.i(TAG, "Writing set of D2D devices on the sdcard file"); - // This method is blocking, waiting for the lock on the file to be available. - Utils.writeObjectToFile(Constants.FILE_D2D_PHONES, setD2dPhones); - Log.i(TAG, "Finished writing set of D2D devices on the sdcard file"); - } catch (IOException e) { - Log.e(TAG, "Error while writing set of D2D devices on the sdcard file: " + e); - } - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/d2d/D2DMessage.java b/AccelerationClient/src/eu/project/rapid/ac/d2d/D2DMessage.java deleted file mode 100644 index 774824a..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/d2d/D2DMessage.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac.d2d; - -import java.io.IOException; -import java.io.Serializable; -import java.io.StreamCorruptedException; - -import android.content.Context; -import eu.project.rapid.ac.utils.Utils; - -/** - * The message that will be broadcasted by the devices that run the Acceleration Server and are - * willing to participate in D2D offloading service. - */ -public class D2DMessage implements Serializable { - private static final long serialVersionUID = -8833550140715953630L; - - private MsgType msgType; - private PhoneSpecs phoneSpecs; - - public enum MsgType { - HELLO; - } - - /** - * Message that will be sent usually in broadcast by the device running the AccelerationServer - * - * @param msgType - */ - public D2DMessage(Context context, MsgType msgType) { - this.msgType = msgType; - this.phoneSpecs = PhoneSpecs.getPhoneSpecs(context); - } - - /** - * Constructor that will be usually used by the device running the AccelerationClient - * - * @param byteArray - * @throws ClassNotFoundException - * @throws IOException - * @throws StreamCorruptedException - */ - public D2DMessage(byte[] byteArray) - throws StreamCorruptedException, IOException, ClassNotFoundException { - D2DMessage otherDevice = (D2DMessage) Utils.byteArrayToObject(byteArray); - this.msgType = otherDevice.getMsgType(); - this.phoneSpecs = otherDevice.getPhoneSpecs(); - } - - /** - * @return the msgType - */ - public MsgType getMsgType() { - return msgType; - } - - /** - * @param msgType the msgType to set - */ - public void setMsgType(MsgType msgType) { - this.msgType = msgType; - } - - public PhoneSpecs getPhoneSpecs() { - return phoneSpecs; - } - - public void setPhoneSpecs(PhoneSpecs phoneSpecs) { - this.phoneSpecs = phoneSpecs; - } - - @Override - public String toString() { - return "[" + this.msgType.toString() + this.phoneSpecs + "]"; - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/d2d/PhoneSpecs.java b/AccelerationClient/src/eu/project/rapid/ac/d2d/PhoneSpecs.java deleted file mode 100644 index 860a6eb..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/d2d/PhoneSpecs.java +++ /dev/null @@ -1,226 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac.d2d; - -import java.io.Serializable; - -import android.content.Context; -import android.util.Log; -import eu.project.rapid.ac.utils.Utils; - -/** - * This object contains the specifics of a phone. In a D2D communication scenario, we will receive - * the specifics from the nearby phones and will sort them based on CPU, memory, GPU.
- * - * @author sokol - * - */ -public class PhoneSpecs implements Serializable, Comparable { - private static final long serialVersionUID = -4918806738265004873L; - - private static final String TAG = "PhoneSpecs"; - - private String phoneId; - private long timestamp; // TimeStamp to be used by the clients as a mean to measure the freshness - // of this phone - private String ip; - private int nrCPUs; // number of CPU cores - private int cpuFreqKHz; // CPU frequency in KHz - private int ramMB; // Memory in MB - private boolean hasGpu; - - private static PhoneSpecs phoneSpecs; - - /** - * @param context Context of the application calling this method. - */ - private PhoneSpecs(Context context) throws NullPointerException { - if (context == null) { - throw new NullPointerException("Context cannot be null"); - } - - // FIXME: On Android 6 we can't just read the ID directly, we need to ask for runtime - // permission. - phoneId = Utils.getDeviceIdHashHex(context); - nrCPUs = Utils.getDeviceNrCPUs(); - cpuFreqKHz = Utils.getDeviceCPUFreq(); - try { - ip = Utils.getIpAddress().getHostAddress(); - } catch (Exception e) { - Log.w(TAG, - "Error while getting the IP (most probably we are not connected to WiFi network): " + e); - } - } - - public static PhoneSpecs getPhoneSpecs(Context context) { - if (phoneSpecs == null) { - phoneSpecs = new PhoneSpecs(context); - } - - return phoneSpecs; - } - - /** - * @return the phoneId - */ - public String getPhoneId() { - return phoneId; - } - - /** - * @param phoneId the phoneId to set - */ - public void setPhoneId(String phoneId) { - this.phoneId = phoneId; - } - - /** - * @return the timestamp - */ - public long getTimestamp() { - return timestamp; - } - - /** - * @param timestamp the timestamp to set - */ - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - /** - * @return the ip - */ - public String getIp() { - return ip; - } - - /** - * @param ip the ip to set - */ - public void setIp(String ip) { - this.ip = ip; - } - - /** - * @return the nrCPUs - */ - public int getNrCPUs() { - return nrCPUs; - } - - /** - * @param nrCPUs the nrCPUs to set - */ - public void setNrCPUs(int nrCPUs) { - this.nrCPUs = nrCPUs; - } - - /** - * @return the cpuFreqKHz - */ - public int getCpuPowerKHz() { - return cpuFreqKHz; - } - - /** - * @param cpuFreqKHz the cpuFreqKHz to set - */ - public void setCpuPowerKHz(int cpuPowerKHz) { - this.cpuFreqKHz = cpuPowerKHz; - } - - /** - * @return the ramMB - */ - public int getRamMB() { - return ramMB; - } - - /** - * @param ramMB the ramMB to set - */ - public void setRamMB(int ramMB) { - this.ramMB = ramMB; - } - - /** - * @return the hasGpu - */ - public boolean isHasGpu() { - return hasGpu; - } - - /** - * @param hasGpu the hasGpu to set - */ - public void setHasGpu(boolean hasGpu) { - this.hasGpu = hasGpu; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = prime + ((phoneId == null) ? 0 : phoneId.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - - final PhoneSpecs other = (PhoneSpecs) obj; - if (phoneId == other.phoneId) { - return true; - } - - return false; - } - - - @Override - public int compareTo(PhoneSpecs otherPhone) { - if (otherPhone == null) { - return 1; - } - - if (this.phoneId == otherPhone.phoneId) { - return 0; - } - - if (this.nrCPUs > otherPhone.nrCPUs || this.cpuFreqKHz > otherPhone.cpuFreqKHz) { - return 1; - } else if (this.cpuFreqKHz < otherPhone.cpuFreqKHz) { - return -1; - } else { - return this.ramMB - otherPhone.ramMB; - } - } - - @Override - public String toString() { - return "ID=" + this.phoneId + ", nrCPUs=" + this.nrCPUs + ", CPU=" + this.cpuFreqKHz + " KHz" - + ", RAM=" + this.ramMB + " MB" + ", GPU=" + this.hasGpu + ", IP=" + this.ip; - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/db/DBCache.java b/AccelerationClient/src/eu/project/rapid/ac/db/DBCache.java deleted file mode 100644 index 4004928..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/db/DBCache.java +++ /dev/null @@ -1,188 +0,0 @@ -package eu.project.rapid.ac.db; - -import java.io.IOException; -import java.util.Deque; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; - -import android.util.Log; -import eu.project.rapid.ac.utils.Constants; -import eu.project.rapid.ac.utils.Utils; - -/** - * While RAPID is running there is no need to access the database. We use this class to keep the - * needed information so that the offloading decision is faster. When the app is closed the entries - * of this cached DB are saved. - * - * @author sokol - * - */ -public class DBCache { - - private static final String TAG = "DBCache"; - - private static int nrElements; - private static DBCache dbCache; - private static Map> dbMap; // appName is the key - - @SuppressWarnings("unchecked") - private DBCache() { - try { - Log.i(TAG, "Reading the dbCache from file: " + Constants.FILE_DB_CACHE); - dbMap = (Map>) Utils.readObjectFromFile(Constants.FILE_DB_CACHE); - } catch (ClassNotFoundException | IOException e) { - Log.w(TAG, "Could not read the dbCache from file: " + e); - } - - if (dbMap == null) { - dbMap = new HashMap<>(); - } - }; - - public static DBCache getDbCache() { - if (dbCache == null) { - Log.i(TAG, "Creating the dbCache object"); - dbCache = new DBCache(); - } - - return dbCache; - } - - public void insertEntry(DBEntry entry) { - String key = entry.getMethodName(); - if (!dbMap.containsKey(key)) { - dbMap.put(key, new LinkedList()); - } - - while (dbMap.get(key).size() >= Constants.MAX_METHOD_EXEC_HISTORY) { - dbMap.get(key).removeLast(); - nrElements--; - } - - dbMap.get(key).addFirst(entry); - nrElements++; - } - - /** - * To be used to retrieve all entries. - * - * @param methodName - * @return - */ - public Deque getAllEntriesFilteredOn(String methodName) { - if (dbMap.containsKey(methodName)) { - return dbMap.get(methodName); - } else { - return new LinkedList<>(); - } - } - - /** - * To be used for retrieving the entries of LOCAL execution. The elements are sorted in - * incremental order based on timestamp. - * - * @param methodName - * @param appName - * @param execLocation - * @return - */ - public Deque getAllEntriesFilteredOn(String appName, String methodName, - String execLocation) { - - assert dbMap != null; - - Deque tempList = new LinkedList<>(); - if (dbMap.containsKey(methodName)) { - for (DBEntry e : dbMap.get(methodName)) { - // Log.i(TAG, "Checking entry: " + e.getAppName() + ", " + e.getMethodName() + ", " - // + e.getExecLocation() + ", " + e.getTimestamp()); - if (e.getAppName().equals(appName) && e.getExecLocation().equals(execLocation)) { - tempList.addLast(e); - } - } - } - - return tempList; - } - - /** - * To be used for retrieving the entries of REMOTE execution. The elements are sorted in - * incremental order based on timestamp. - * - * @param methodName - * @param appName - * @param execLocation - * @param networkType - * @param networkSubtype - * @return - */ - public Deque getAllEntriesFilteredOn(String appName, String methodName, - String execLocation, String networkType, String networkSubtype) { - - assert dbMap != null; - - Deque tempList = new LinkedList<>(); - if (dbMap.containsKey(methodName)) { - for (DBEntry e : dbMap.get(methodName)) { - if (e.getAppName().equals(appName) && e.getExecLocation().equals(execLocation) - && e.getNetworkType().equals(networkType) - && e.getNetworkSubType().equals(networkSubtype)) { - tempList.addLast(e); - } - } - } - - return tempList; - } - - public void clearDbCache() { - dbMap.clear(); - nrElements = 0; - } - - /** - * To be called by the DFE when the (Rapid) application is closed. - */ - public static void saveDbCache() { - try { - Utils.writeObjectToFile(Constants.FILE_DB_CACHE, dbMap); - } catch (IOException e) { - Log.e(TAG, "Could not save the dbCache on the file: " + e); - } - } - - /** - * Returns the number of entries in the DB cache, i.e. the number of different methods insterted - * in the DB. - * - * @return - */ - public int size() { - if (dbMap == null) { - return 0; - } - - return dbMap.size(); - } - - /** - * Returns the number of total elements in the DB cache, i.e.: nrMethods * measurementsPerMethod. - * - * @return - */ - public int nrElements() { - return nrElements; - } - - public int getByteSize() { - int bytes = -1; - try { - bytes = Utils.objectToByteArray(dbMap).length; - } catch (IOException e) { - Log.e(TAG, "Error while converting the DB cache map to byte array: " + e); - } - - return bytes; - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/db/DBEntry.java b/AccelerationClient/src/eu/project/rapid/ac/db/DBEntry.java deleted file mode 100644 index 0343464..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/db/DBEntry.java +++ /dev/null @@ -1,175 +0,0 @@ -package eu.project.rapid.ac.db; - -import java.io.Serializable; - -public class DBEntry implements Serializable { - - private static final long serialVersionUID = 1L; - - private String appName; - private String methodName; - private String execLocation; - private String networkType; - private String networkSubType; - private int ulRate; - private int dlRate; - private long execDuration; - private long execEnergy; - private long timestamp; - - public DBEntry(String appName, String methodName, String execLocation, String networkType, - String networkSubType, int ulRate, int dlRate, long execDuration, long execEnergy) { - - this.appName = appName; - this.methodName = methodName; - this.execLocation = execLocation; - this.networkType = networkType; - this.networkSubType = networkSubType; - this.ulRate = ulRate; - this.dlRate = dlRate; - this.execDuration = execDuration; - this.execEnergy = execEnergy; - this.timestamp = System.currentTimeMillis(); - } - - /** - * @return the appName - */ - public String getAppName() { - return appName; - } - - /** - * @param appName the appName to set - */ - public void setAppName(String appName) { - this.appName = appName; - } - - /** - * @return the methodName - */ - public String getMethodName() { - return methodName; - } - - /** - * @param methodName the methodName to set - */ - public void setMethodName(String methodName) { - this.methodName = methodName; - } - - /** - * @return the execLocation - */ - public String getExecLocation() { - return execLocation; - } - - /** - * @param execLocation the execLocation to set - */ - public void setExecLocation(String execLocation) { - this.execLocation = execLocation; - } - - /** - * @return the networkType - */ - public String getNetworkType() { - return networkType; - } - - /** - * @param networkType the networkType to set - */ - public void setNetworkType(String networkType) { - this.networkType = networkType; - } - - /** - * @return the networkSubType - */ - public String getNetworkSubType() { - return networkSubType; - } - - /** - * @param networkSubType the networkSubType to set - */ - public void setNetworkSubType(String networkSubType) { - this.networkSubType = networkSubType; - } - - /** - * @return the ulRate - */ - public int getUlRate() { - return ulRate; - } - - /** - * @param ulRate the ulRate to set - */ - public void setUlRate(int ulRate) { - this.ulRate = ulRate; - } - - /** - * @return the dlRate - */ - public int getDlRate() { - return dlRate; - } - - /** - * @param dlRate the dlRate to set - */ - public void setDlRate(int dlRate) { - this.dlRate = dlRate; - } - - /** - * @return the execDuration - */ - public long getExecDuration() { - return execDuration; - } - - /** - * @param execDuration the execDuration to set - */ - public void setExecDuration(long execDuration) { - this.execDuration = execDuration; - } - - /** - * @return the execEnergy - */ - public long getExecEnergy() { - return execEnergy; - } - - /** - * @param execEnergy the execEnergy to set - */ - public void setExecEnergy(long execEnergy) { - this.execEnergy = execEnergy; - } - - /** - * @return the timestamp - */ - public long getTimestamp() { - return timestamp; - } - - /** - * @param timestamp the timestamp to set - */ - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/profilers/DeviceProfiler.java b/AccelerationClient/src/eu/project/rapid/ac/profilers/DeviceProfiler.java deleted file mode 100755 index 5e08ac6..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/profilers/DeviceProfiler.java +++ /dev/null @@ -1,438 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac.profilers; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.util.ArrayList; -import java.util.StringTokenizer; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.BatteryManager; -import android.provider.Settings; -import android.util.Log; - -/** - * Device state profiler - currently only tracks battery state, listening to ACTION_BATTERY_CHANGED - * intent to update the battery level and allows to track change in voltage between two points in a - * program (where battery voltage readings are taken from /sys/class/power_supply, based on Android - * OS source) - */ -public class DeviceProfiler { - - private static final String TAG = "DeviceProfiler"; - - public static int batteryLevel; - public static boolean batteryTrackingOn = false; - private static Object batteryTrackingSyncObject = new Object(); - - private Long mStartBatteryVoltage; - public Long batteryVoltageDelta; - - private static Context context; - - /** - * Variables for CPU Usage - */ - private int PID; - private boolean stopReadingFiles; - private ArrayList pidCpuUsage; - private ArrayList systemCpuUsage; - private long uTime; - private long sTime; - private long pidTime; - private long diffPidTime; - private long prevPidTime; - private long userMode; - private long niceMode; - private long systemMode; - private long idleTask; - private long ioWait; - private long irq; - private long softirq; - private long runningTime; - private long prevrunningTime; - private long diffRunningTime; - private final String pidStatFile; - private final String statFile; - private long diffIdleTask; - private long prevIdleTask; - private ArrayList idleSystem; - private ArrayList screenBrightness; - - private static BroadcastReceiver batteryLevelReceiver; - - /** - * Variables for CPU frequency
- * Obtained reading the files:
- * /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
- * /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
- * /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq - */ - private int currentFreq; // The current frequency in KHz - private ArrayList frequence; - private final String curFreqFile = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"; - - public DeviceProfiler(Context context) { - DeviceProfiler.context = context; - batteryVoltageDelta = null; - - pidCpuUsage = new ArrayList(); - systemCpuUsage = new ArrayList(); - idleSystem = new ArrayList(); - frequence = new ArrayList(); - screenBrightness = new ArrayList(); - - PID = android.os.Process.myPid(); - - pidStatFile = "/proc/" + PID + "/stat"; - statFile = "/proc/stat"; - - synchronized (this) { - stopReadingFiles = false; - } - } - - /** - * Start device information tracking from a certain point in a program (currently only battery - * voltage) - */ - public void startDeviceProfiling() { - mStartBatteryVoltage = SysClassBattery.getCurrentVoltage(); - calculatePidCpuUsage(); - calculateScreenBrightness(); - } - - public static void onDestroy() { - if (batteryLevelReceiver != null) { - DeviceProfiler.context.unregisterReceiver(batteryLevelReceiver); - } - synchronized (batteryTrackingSyncObject) { - batteryTrackingOn = false; - } - } - - /** - * Stop device information tracking and store the data in the object - */ - public void stopAndCollectDeviceProfiling() { - batteryVoltageDelta = SysClassBattery.getCurrentVoltage() - mStartBatteryVoltage; - - synchronized (this) { - // Log.i(TAG, "Flag to stopReadingFiles set to true"); - stopReadingFiles = true; - } - } - - /** - * Computes the battery level by registering a receiver to the intent triggered by a battery - * status/level change. - */ - public static void trackBatteryLevel() { - if (batteryTrackingOn == false) { - batteryLevelReceiver = new BroadcastReceiver() { - public void onReceive(Context context, Intent intent) { - // context.unregisterReceiver(this); - int rawlevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); - int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); - int level = -1; - if (rawlevel >= 0 && scale > 0) { - level = (rawlevel * 100) / scale; - } - Log.d(TAG, - "Battery level - " + level + ", voltage - " + SysClassBattery.getCurrentVoltage()); - batteryLevel = level; - } - }; - IntentFilter batteryLevelFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); - context.registerReceiver(batteryLevelReceiver, batteryLevelFilter); - synchronized (batteryTrackingSyncObject) { - batteryTrackingOn = true; - } - } - } - - /** - * Class exposing battery information, based on battery service and Android OS implementation - */ - private static class SysClassBattery { - private final static String SYS_CLASS_POWER = "/sys/class/power_supply"; - private final static String BATTERY = "/battery"; - private final static String VOLTAGE = "/batt_vol"; - private final static String VOLTAGE_ALT = "/voltage_now"; - - /** - * Read current battery voltage from /sys/class/power_supply/battery/batt_vol or - * /sys/class/power_supply/battery/voltage_now - try both files since it is done in the battery - * service of Android, so must be model/version dependent - */ - public static Long getCurrentVoltage() { - StringBuilder sb = new StringBuilder(); - sb.append(SYS_CLASS_POWER).append(BATTERY).append(VOLTAGE); - Long result = readLong(sb.toString()); - if (result != -1) - return result; - else { - sb = new StringBuilder(); - sb.append(SYS_CLASS_POWER).append(BATTERY).append(VOLTAGE_ALT); - result = readLong(sb.toString()); - return result; - } - - } - - private static RandomAccessFile getFile(String filename) throws IOException { - File f = new File(filename); - return new RandomAccessFile(f, "r"); - } - - private static long readLong(String file) { - RandomAccessFile raf = null; - try { - raf = getFile(file); - return Long.valueOf(raf.readLine()); - } catch (Exception e) { - // Log.d(TAG, "Could not read voltage: " + e); - return -1; - } finally { - if (raf != null) { - try { - raf.close(); - } catch (IOException e) { - } - } - } - } - } - - /** - * Calculate the CPU usage of process every second
- * These values are registered in the array pidCpuUsage[] - */ - private void calculatePidCpuUsage() { - Thread t = new Thread("PidCpuUsage") { - public void run() { - - boolean firstTime = true; - - while (!stopReadingFiles) { - - try { - calculateProcessExecutionTime(); - calculateSystemExecutionTime(); - - try { - getCurrentCpuFreq(); - } catch (Exception e) { - // Do nothing. We know that in remote side this will throw an exception. - } - - /** - * To prevent errors from the first run don't consider it - */ - if (!firstTime) { - pidCpuUsage.add(diffPidTime); - systemCpuUsage.add(diffRunningTime); - frequence.add(currentFreq); - idleSystem.add(diffIdleTask); - - Log.i("DeviceProfiler", "PidCpuTime: " + diffPidTime); - Log.i("DeviceProfiler", "Frequence: " + currentFreq); - } - - prevPidTime = pidTime; - prevrunningTime = runningTime; - prevIdleTask = idleTask; - - firstTime = false; - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - } catch (FileNotFoundException e1) { - Log.e(TAG, "Stopping device profiling: FileNotFoundException - " + e1); - stopReadingFiles = true; - } catch (IOException e1) { - Log.e(TAG, "Stopping device profiling: IOException - " + e1); - stopReadingFiles = true; - } - } - } - }; - t.start(); - } - - /** - * Open the file /proc/$PID/stat and read utime and stime
- * utime: execution of process in user mode (in jiffies)
- * stime: execution of process in kernel mode (in jiffies)
- * These are 14th and 15th variables respectively in the file
- * The sum pidTime = utime + stime gives the total running time of process
- * diffPidTime is the running time of process during the last second
- * - * @throws IOException - */ - private void calculateProcessExecutionTime() throws FileNotFoundException, IOException { - BufferedReader brPidStat = null; - - try { - brPidStat = new BufferedReader(new FileReader(pidStatFile)); - - String strLine = brPidStat.readLine(); - StringTokenizer st = new StringTokenizer(strLine); - - for (int i = 1; i < 14; i++) - st.nextToken(); - - uTime = Long.parseLong(st.nextToken()); - sTime = Long.parseLong(st.nextToken()); - pidTime = uTime + sTime; - diffPidTime = pidTime - prevPidTime; - } finally { - try { - if (brPidStat != null) - brPidStat.close(); - } catch (IOException e) { - } - } - } - - /** - * Open the file "/proc/stat" and read information about system execution
- * userMode: normal processes executing in user mode (in jiffies)
- * niceMode: niced processes executing in user mode (in jiffies)
- * systemMode: processes executing in kernel mode (in jiffies)
- * idleTask: twiddling thumbs (in jiffies)
- * runningTime: total time of execution (in jiffies)
- * ioWait: waiting for I/O to complete (in jiffies)
- * irq: servicing interrupts (in jiffies)
- * softirq: servicing softirq (in jiffies)
- * diffRunningTime: time of execution during the last second (in jiffies)
- * - * @throws IOException - */ - private void calculateSystemExecutionTime() throws FileNotFoundException, IOException { - BufferedReader brStat = null; - - try { - brStat = new BufferedReader(new FileReader(statFile)); - - String strLine = brStat.readLine(); - StringTokenizer st = new StringTokenizer(strLine); - st.nextToken(); - - userMode = Long.parseLong(st.nextToken()); - niceMode = Long.parseLong(st.nextToken()); - systemMode = Long.parseLong(st.nextToken()); - idleTask = Long.parseLong(st.nextToken()); - ioWait = Long.parseLong(st.nextToken()); - irq = Long.parseLong(st.nextToken()); - softirq = Long.parseLong(st.nextToken()); - - // runningTime = userMode + niceMode + systemMode + idleTask + ioWait + irq + softirq; - idleTask += ioWait; - runningTime = userMode + niceMode + systemMode + irq + softirq; - diffRunningTime = runningTime - prevrunningTime; - diffIdleTask = idleTask - prevIdleTask; - } finally { - try { - if (brStat != null) - brStat.close(); - } catch (IOException e) { - } - } - } - - private void getCurrentCpuFreq() throws FileNotFoundException, IOException { - BufferedReader brFreq = null; - - try { - brFreq = new BufferedReader(new FileReader(curFreqFile)); - - String strLine = brFreq.readLine(); - currentFreq = Integer.parseInt(strLine); - } finally { - try { - if (brFreq != null) - brFreq.close(); - } catch (IOException e) { - } - } - } - - /** - * For now the implementation is very dummy: is assumed that the screen is always ON during the - * execution. - * - * TODO: better implementation of this method, account also the fact that the screen can go off. - * - */ - - private void calculateScreenBrightness() { - Thread t = new Thread("ScreenBrightness") { - public void run() { - - while (!stopReadingFiles) { - - int brightness = Settings.System.getInt(context.getContentResolver(), - Settings.System.SCREEN_BRIGHTNESS, -1); - - screenBrightness.add(brightness); - - // Log.i(TAG, "Screen brightness: " + brightness); - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - } - } - }; - t.start(); - } - - public int getSeconds() { - return pidCpuUsage.size(); - } - - public long getSystemCpuUsage(int i) { - return systemCpuUsage.get(i); - } - - public long getPidCpuUsage(int i) { - return pidCpuUsage.get(i); - } - - public int getFrequence(int i) { - return frequence.get(i); - } - - public long getIdleSystem(int i) { - return idleSystem.get(i); - } - - public int getScreenBrightness(int i) { - return screenBrightness.get(i); - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/profilers/LocationProfiler.java b/AccelerationClient/src/eu/project/rapid/ac/profilers/LocationProfiler.java deleted file mode 100644 index 41aed35..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/profilers/LocationProfiler.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac.profilers; - -import android.location.Location; -import android.location.LocationListener; -import android.os.Bundle; -import android.util.Log; - -public class LocationProfiler implements LocationListener { - - private static final String TAG = "LocationProfiler"; - - @Override - public void onLocationChanged(Location location) { - - Log.i(TAG, "User location changed: (" + location.getLatitude() + "," + location.getLongitude()); - - } - - @Override - public void onProviderDisabled(String provider) { - // TODO Auto-generated method stub - - } - - @Override - public void onProviderEnabled(String provider) { - // TODO Auto-generated method stub - - } - - @Override - public void onStatusChanged(String provider, int status, Bundle extras) { - // TODO Auto-generated method stub - - } - -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/profilers/LogRecord.java b/AccelerationClient/src/eu/project/rapid/ac/profilers/LogRecord.java deleted file mode 100755 index e66530b..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/profilers/LogRecord.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac.profilers; - -/** - * Log record of the profiler. - * - * Structure of a log record: - * - * Method Name, Execution Location, PrepareDataDuration (nanoseconds), Execution Duration (nanoseconds), Execution - * Duration (excl. overheads),Thread CPU time,Instruction Count,Method - * Invocation Count,Thread Allocation Size,Garbage Collector invocation count - * (thread),Garbage Collector invocation count (global),Current Network - * Type,Current Network Subtype,Current RTT,Current UlRate, Current DlRate, Bytes - * Received(RX),Bytes Transmitted(TX),Battery Voltage Change,Timestamp - * - */ -public class LogRecord { - public String appName; - public String methodName; - public String execLocation; - public long prepareDataDuration; - public long execDuration; - public long pureDuration; - public long energyConsumption; - public double cpuEnergy; - public double screenEnergy; - public double wifiEnergy; - public double threeGEnergy; - - public Long threadCpuTime; - public int instructionCount; - public int methodCount; - public int threadAllocSize; - public int threadGcInvocationCount; - public int globalGcInvocationCount; - - public String networkType; - public String networkSubtype; - public int rtt; - public int ulRate = -1; - public int dlRate = -1; - public long rxBytes = -1; - public long txBytes = -1; - - public long batteryVoltageChange; - public long logRecordTime; - - public static final String LOG_HEADERS = "#MethodName,ExecLocation,PrepareDataDuration,ExecDuration,PureDuration," + - "EnergyConsumption,CpuEnergy,ScreenEnergy,WifiEnergy,3GEnergy," + - "ThreadCpuTime,InstructionCount,MethodCount,ThreadAllocSize,ThreadGcInvocCount,GlobalGcInvocCount," + - "NetType,NetSubtype,RTT,UlRate,DlRate,RxBytes,TxBytes," + - "BatteryVoltChange,LogRecordTime"; - - /** - * Collect readings of the different profilers together from the different - * running profilers - * - * @param progProfiler - * instace of ProgramProfiler - * @param netProfiler - * instance of NetworkProfiler - * @param devProfiler - * instance of DeviceProfiler - */ - public LogRecord(ProgramProfiler progProfiler, NetworkProfiler netProfiler, - DeviceProfiler devProfiler) { - appName = progProfiler.appName; - methodName = progProfiler.methodName; - execDuration = progProfiler.execTime; - threadCpuTime = progProfiler.threadCpuTime; - - instructionCount = progProfiler.instructionCount; - methodCount = progProfiler.methodInvocationCount; - - threadAllocSize = progProfiler.threadAllocSize; - threadGcInvocationCount = progProfiler.gcThreadInvocationCount; - globalGcInvocationCount = progProfiler.gcGlobalInvocationCount; - - networkType = NetworkProfiler.currentNetworkTypeName; - networkSubtype = NetworkProfiler.currentNetworkSubtypeName; - rtt = NetworkProfiler.rtt; - - if (NetworkProfiler.lastUlRate != null) - ulRate = NetworkProfiler.lastUlRate.getBw(); - - if (NetworkProfiler.lastDlRate != null) - dlRate = NetworkProfiler.lastDlRate.getBw(); - - if (netProfiler != null) { - rxBytes = netProfiler.rxBytes; - txBytes = netProfiler.txBytes; - } else { - rxBytes = -1; - txBytes = -1; - } - - batteryVoltageChange = devProfiler.batteryVoltageDelta; - } - - /** - * Convert the log record to string for storing - */ - public String toString() { - - logRecordTime = System.currentTimeMillis(); - String progProfilerRecord = methodName + "," + execLocation + "," + prepareDataDuration + "," - + execDuration + "," + pureDuration + "," + energyConsumption + "," + - cpuEnergy + "," + screenEnergy + "," + wifiEnergy + "," + threeGEnergy - + "," + threadCpuTime + "," - + instructionCount + "," + methodCount + "," + threadAllocSize - + "," + threadGcInvocationCount + "," + globalGcInvocationCount; - - String netProfilerRecord = " , , , , , , "; - - if (execLocation == "REMOTE") - netProfilerRecord = networkType + ", " + networkSubtype + "," + rtt - + "," + ulRate + "," + dlRate + "," + rxBytes + "," + txBytes; - - String devProfilerRecord = "" + batteryVoltageChange; - - return progProfilerRecord + "," + netProfilerRecord + "," - + devProfilerRecord + "," + logRecordTime; - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/profilers/NetworkBWRecord.java b/AccelerationClient/src/eu/project/rapid/ac/profilers/NetworkBWRecord.java deleted file mode 100644 index 0205792..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/profilers/NetworkBWRecord.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac.profilers; - -public class NetworkBWRecord { - - private int bw; - private long timestamp; - - public NetworkBWRecord() { - this(-1, -1); - } - - /** - * - * @param ulRate - * @param dlRate - * @param timestamp - * @param location - */ - public NetworkBWRecord(int bw, long timestamp) { - this.bw = bw; - this.timestamp = timestamp; - } - - /** - * @return the bw - */ - public int getBw() { - return bw; - } - - /** - * @param bw the bw to set - */ - public void setBw(int bw) { - this.bw = bw; - } - - /** - * @return the timestamp - */ - public long getTimestamp() { - return timestamp; - } - /** - * @param timestamp the timestamp to set - */ - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/profilers/NetworkProfiler.java b/AccelerationClient/src/eu/project/rapid/ac/profilers/NetworkProfiler.java deleted file mode 100755 index 9d02955..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/profilers/NetworkProfiler.java +++ /dev/null @@ -1,755 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac.profilers; - -import java.io.DataInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.Socket; -import java.net.SocketException; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.net.ConnectivityManager; -import android.net.NetworkInfo; -import android.net.TrafficStats; -import android.net.wifi.WifiInfo; -import android.net.wifi.WifiManager; -import android.telephony.PhoneStateListener; -import android.telephony.TelephonyManager; -import android.util.Log; -import eu.project.rapid.common.Configuration; -import eu.project.rapid.common.RapidMessages; -import eu.project.rapid.common.RapidUtils; - -/** - * Network information profiler - * - */ -// @TargetApi(8) -public class NetworkProfiler { - private static final String TAG = "NetworkProfiler"; - - private static final int rttInfinite = 100000000; - private static final int rttPings = 5; - public static int rtt = rttInfinite; - - // Keep the upload/download data rate history between the phone and the clone - // Data rate in b/s - private static final int bwWindowMaxLength = 20; - private static List ulRateHistory = new LinkedList(); - private static List dlRateHistory = new LinkedList(); - public static NetworkBWRecord lastUlRate = null; - public static NetworkBWRecord lastDlRate = null; - - public static String currentNetworkTypeName; - public static String currentNetworkSubtypeName; - private static byte[] buffer; - private static final int BUFFER_SIZE = 10 * 1024; - private static final int delayRefreshUlRate = 3 * 60 * 1000; // measure the rtt and rates every 30 - // minutes - private static final int delayRefreshDlRate = delayRefreshUlRate + 10000; // measure the rtt and - // rates every 30 - // minutes - // private static Handler uploadRateHandler; - // private static Handler downloadRateHandler; - // private static Runnable uploadRunnable; - // private static Runnable downloadRunnable; - - private static Context context; - private static Configuration config; - private static NetworkInfo netInfo; - private static PhoneStateListener listener; - private static TelephonyManager telephonyManager; - private static ConnectivityManager connectivityManager; - private WifiManager wifiManager; - private static BroadcastReceiver networkStateReceiver; - - private boolean stopEstimatingEnergy; - private ArrayList wifiTxPackets; - private ArrayList wifiRxPackets; - private ArrayList wifiTxBytes; // uplink data rate - private ArrayList threeGActiveState; - public static final byte THREEG_IN_IDLE_STATE = 0; - public static final byte THREEG_IN_FACH_STATE = 1; - public static final byte THREEG_IN_DCH_STATE = 2; - - // For measuring the nr of bytes sent and received - private final static int uid = android.os.Process.myUid(); - private long duration; - // Needed by Profiler - public long rxBytes; - public long txBytes; - - /** - * Constructor used to create a network profiler instance during method execution - */ - public NetworkProfiler() { - stopEstimatingEnergy = false; - wifiTxPackets = new ArrayList(); - wifiRxPackets = new ArrayList(); - wifiTxBytes = new ArrayList(); - threeGActiveState = new ArrayList(); - } - - /** - * Constructor used to create the network profiler instance of the DFE - * - * @param context - */ - public NetworkProfiler(Context context, Configuration config) { - - NetworkProfiler.context = context; - NetworkProfiler.config = config; - buffer = new byte[BUFFER_SIZE]; - - telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); - connectivityManager = - (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); - if (wifiManager == null) { - throw new NullPointerException("WiFi manager is null"); - } - - /* - * // FIXME: Crashes on Android 4+ due to networkonmainthread exception. // Fix this - * implementing with alarm manager. - * - * uploadRunnable = new UploadRateMeasurer(); uploadRateHandler = new Handler(); TimerTask - * uploadRateTask = new TimerTask() { - * - * @Override public void run() { uploadRateHandler.post(uploadRunnable); } }; Timer - * uploadRateTimer = new Timer(); uploadRateTimer.schedule(uploadRateTask, delayRefreshUlRate, - * delayRefreshUlRate); - * - * downloadRunnable = new DownloadRateMeasurer(); downloadRateHandler = new Handler(); TimerTask - * downloadRateTask = new TimerTask() { - * - * @Override public void run() { downloadRateHandler.post(downloadRunnable); } }; Timer - * downloadRateTimer = new Timer(); downloadRateTimer.schedule(downloadRateTask, - * delayRefreshDlRate, delayRefreshDlRate); - */ - } - - private static void addNewUlRateEstimate(long bytes, long nanoTime) { - - Log.d(TAG, "Sent " + bytes + " bytes in " + nanoTime + "ns"); - int ulRate = (int) ((((double) 8 * bytes) / nanoTime) * 1000000000); - Log.i(TAG, "Estimated upload bandwidth: " + ulRate + " b/s (" + ulRate / 1000 + " Kbps)"); - - // Rule 1: if the number of bytes sent was bigger than 10KB and the ulRate is small then keep - // it, otherwise throw it - // Rule 2: if the number of bytes sent was bigger than 50KB then keep the calculated ulRate - if (bytes < 10 * 1000) { - return; - } else if (bytes < 50 * 1000 && ulRate > 250 * 1000) { - return; - } - - if (ulRateHistory.size() >= bwWindowMaxLength) { - ulRateHistory.remove(0); - } - - lastUlRate = new NetworkBWRecord(ulRate, System.currentTimeMillis()); - ulRateHistory.add(lastUlRate); - - // uploadRateHandler.removeCallbacks(uploadRunnable); - // uploadRateHandler.postDelayed(uploadRunnable, delayRefreshUlRate); - } - - private static void addNewDlRateEstimate(long bytes, long nanoTime) { - - Log.d(TAG, "Received " + bytes + " bytes in " + nanoTime + "ns"); - int dlRate = (int) ((((double) 8 * bytes) / nanoTime) * 1000000000); - Log.i(TAG, "Estimated download bandwidth: " + dlRate + " b/s (" + dlRate / 1000 + " Kbps)"); - - // Rule 1: if the number of bytes sent was bigger than 10KB and the ulRate is small then keep - // it, otherwise throw it - // Rule 2: if the number of bytes sent was bigger than 50KB then keep the calculated ulRate - if (bytes < 10 * 1000) { - return; - } else if (bytes < 50 * 1000 && dlRate > 250 * 1000) { - return; - } - - if (dlRateHistory.size() >= bwWindowMaxLength) - dlRateHistory.remove(0); - - lastDlRate = new NetworkBWRecord(dlRate, System.currentTimeMillis()); - dlRateHistory.add(lastDlRate); - - // downloadRateHandler.removeCallbacks(downloadRunnable); - // downloadRateHandler.postDelayed(downloadRunnable, delayRefreshDlRate); - } - - /** - * Doing a few pings on a given connection to measure how big the RTT is between the client and - * the remote machine - * - * @param in - * @param out - * @return - */ - public static int rttPing(InputStream in, OutputStream out) { - Log.d(TAG, "Pinging"); - int tRtt = 0; - int response; - try { - for (int i = 0; i < rttPings; i++) { - Long start = System.nanoTime(); - Log.d(TAG, "Send Ping"); - out.write(eu.project.rapid.common.RapidMessages.PING); - - Log.d(TAG, "Read Response"); - response = in.read(); - if (response == RapidMessages.PONG) - tRtt = (int) (tRtt + (System.nanoTime() - start) / 2); - else { - Log.d(TAG, "Bad Response to Ping - " + response); - tRtt = rttInfinite; - } - - } - rtt = tRtt / rttPings; - Log.d(TAG, "Ping - " + rtt / 1000000 + "ms"); - - } catch (IOException e) { - Log.e(TAG, "Error while measuring RTT: " + e); - tRtt = rttInfinite; - } - return rtt; - } - - /** - * Start counting transmitted data at a certain point for the current process (RX/TX bytes from - * /sys/class/net/proc/uid_stat) - */ - public void startTransmittedDataCounting() { - - rxBytes = getProcessRxBytes(); - txBytes = getProcessTxBytes(); - duration = System.nanoTime(); - - if (telephonyManager != null) { - if (currentNetworkTypeName.equals("WIFI")) { - calculateWifiRxTxPackets(); - } else { - calculate3GStates(); - } - } - } - - /** - * Stop counting transmitted data and store it in the profiler object - */ - public void stopAndCollectTransmittedData() { - - synchronized (this) { - stopEstimatingEnergy = true; - } - - // Need this for energy estimation - if (telephonyManager != null) { - calculatePacketRate(); - calculateUplinkDataRate(); - } - - rxBytes = getProcessRxBytes() - rxBytes; - txBytes = getProcessTxBytes() - txBytes; - duration = System.nanoTime() - duration; - - addNewDlRateEstimate(rxBytes, duration); - addNewUlRateEstimate(txBytes, duration); - - Log.d(TAG, "UID: " + uid + " RX bytes: " + rxBytes + " TX bytes: " + txBytes + " duration: " - + duration + " ns"); - } - - /** - * @return RX bytes - */ - public static Long getProcessRxBytes() { - return TrafficStats.getUidRxBytes(uid); - } - - /** - * @return TX bytes - */ - public static Long getProcessTxBytes() { - return TrafficStats.getUidTxBytes(uid); - } - - /** - * @return Number of packets transmitted - */ - public static Long getProcessTxPackets() { - return TrafficStats.getUidTxPackets(uid); - } - - /** - * @return Number of packets received - */ - public static Long getProcessRxPackets() { - return TrafficStats.getUidRxPackets(uid); - } - - /** - * Intent based network state tracking - helps to monitor changing conditions without the - * overheads of polling and only updating when needed (i.e. when something actually has changes) - */ - public void registerNetworkStateTrackers() { - networkStateReceiver = new BroadcastReceiver() { - public void onReceive(Context context, Intent intent) { - // context.unregisterReceiver(this); - - netInfo = connectivityManager.getActiveNetworkInfo(); - if (netInfo == null) { - Log.d(TAG, "No Connectivity"); - currentNetworkTypeName = ""; - currentNetworkSubtypeName = ""; - } else { - Log.d(TAG, "Connected to network type " + netInfo.getTypeName() + " subtype " - + netInfo.getSubtypeName()); - currentNetworkTypeName = netInfo.getTypeName(); - currentNetworkSubtypeName = netInfo.getSubtypeName(); - } - } - }; - - Log.d(TAG, "Register Connectivity State Tracker"); - IntentFilter networkStateFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); - context.registerReceiver(networkStateReceiver, networkStateFilter); - - listener = new PhoneStateListener() { - @Override - public void onDataConnectionStateChanged(int state, int networkType) { - if (state == TelephonyManager.DATA_CONNECTED) { - if (networkType == TelephonyManager.NETWORK_TYPE_EDGE) - Log.d(TAG, "Connected to EDGE network"); - else if (networkType == TelephonyManager.NETWORK_TYPE_GPRS) - Log.d(TAG, "Connected to GPRS network"); - else if (networkType == TelephonyManager.NETWORK_TYPE_UMTS) - Log.d(TAG, "Connected to UMTS network"); - else - Log.d(TAG, "Connected to other network - " + networkType); - } else if (state == TelephonyManager.DATA_DISCONNECTED) { - Log.d(TAG, "Data connection lost"); - } else if (state == TelephonyManager.DATA_SUSPENDED) { - Log.d(TAG, "Data connection suspended"); - } - - } - }; - - Log.d(TAG, "Register Telephony Data Connection State Tracker"); - telephonyManager.listen(listener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); - } - - /** - * Class to be used for measuring the data rate and RTT every 30 minutes. - * - */ - private class RTTMeasurer implements Runnable { - private static final String TAG = "RTTMeasurer"; - - @Override - public void run() { - Log.i(TAG, "Measuring the RTT"); - NetworkProfiler.measureRtt(); - // uploadRateHandler.postDelayed(this, delayRefreshUlRate); - } - } - - /** - * Class to be used for measuring the data rate and RTT every 30 minutes. - * - */ - private class UploadRateMeasurer implements Runnable { - private static final String TAG = "UploadRateMeasurer"; - - @Override - public void run() { - Log.i(TAG, "Measuring the upload rate"); - NetworkProfiler.measureUlRate(config.getClone().getIp(), config.getClonePortBandwidthTest()); - // uploadRateHandler.postDelayed(this, delayRefreshUlRate); - } - } - - /** - * Class to be used for measuring the data rate and RTT every 30 minutes. - * - */ - private class DownloadRateMeasurer implements Runnable { - private static final String TAG = "DownloadRateMeasurer"; - - @Override - public void run() { - Log.i(TAG, "Measuring the download rate"); - NetworkProfiler.measureDlRate(config.getClone().getIp(), config.getClonePortBandwidthTest()); - // downloadRateHandler.postDelayed(this, delayRefreshDlRate); - } - } - - /** - * Get the number of packets Tx and Rx every second and update the arrays.
- */ - private void calculateWifiRxTxPackets() { - Thread t = new Thread() { - public void run() { - - while (!stopEstimatingEnergy) { - - wifiRxPackets.add(NetworkProfiler.getProcessRxPackets()); - wifiTxPackets.add(NetworkProfiler.getProcessTxPackets()); - wifiTxBytes.add(NetworkProfiler.getProcessTxBytes()); - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - } - } - }; - t.start(); - } - - private void calculatePacketRate() { - for (int i = 0; i < wifiRxPackets.size() - 1; i++) - wifiRxPackets.set(i, wifiRxPackets.get(i + 1) - wifiRxPackets.get(i)); - - for (int i = 0; i < wifiTxPackets.size() - 1; i++) - wifiTxPackets.set(i, wifiTxPackets.get(i + 1) - wifiTxPackets.get(i)); - } - - private void calculateUplinkDataRate() { - for (int i = 0; i < wifiTxBytes.size() - 1; i++) { - wifiTxBytes.set(i, wifiTxBytes.get(i + 1) - wifiTxBytes.get(i)); - } - } - - - byte timeoutDchFach = 6; // Inactivity timer for transition from DCH -> FACH - byte timeoutFachIdle = 4; // Inactivity timer for transition from FACH -> IDLE - int uplinkThreshold = 151; - int downlikThreshold = 119; - byte threegState = THREEG_IN_IDLE_STATE; - boolean fromIdleState = true; - boolean fromDchState = false; - private long prevRxBytes, prevTxBytes; - - private void calculate3GStates() { - Thread t = new Thread() { - public void run() { - - while (!stopEstimatingEnergy) { - - switch (threegState) { - case THREEG_IN_IDLE_STATE: - threegIdleState(); - break; - case THREEG_IN_FACH_STATE: - threegFachState(); - break; - case THREEG_IN_DCH_STATE: - threegDchState(); - break; - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - } - } - }; - t.start(); - } - - private void threegIdleState() { - int dataActivity = telephonyManager.getDataActivity(); - - if (dataActivity == TelephonyManager.DATA_ACTIVITY_IN - || dataActivity == TelephonyManager.DATA_ACTIVITY_OUT - || dataActivity == TelephonyManager.DATA_ACTIVITY_INOUT) { - // 3G is in the FACH state because is sending or receiving data - Log.d(TAG, "3G in FACH state from IDLE"); - threegState = THREEG_IN_FACH_STATE; - fromIdleState = true; - threegFachState(); - return; - } - - Log.d(TAG, "3G in IDLE state"); - // 3G is in the IDLE state - threeGActiveState.add(THREEG_IN_IDLE_STATE); - } - - private void threegFachState() { - if (fromIdleState || fromDchState) { - // The FACH state is just entered from IDLE or DCH, we should stay here at least 1 second - // to measure the size of the buffer and in case to transit in DCH in the next second - fromIdleState = false; - fromDchState = false; - prevRxBytes = NetworkProfiler.getProcessRxBytes(); - prevTxBytes = NetworkProfiler.getProcessTxBytes(); - } else { // 3G was in FACH - if (timeoutFachIdle == 0) { - Log.d(TAG, "3G in IDLE state from FACH"); - timeoutFachIdle = 4; - threegState = THREEG_IN_IDLE_STATE; - threegIdleState(); - return; - } else if (telephonyManager.getDataActivity() == TelephonyManager.DATA_ACTIVITY_NONE) { - Log.d(TAG, "3G in FACH state with no data activity"); - timeoutFachIdle--; - } else - timeoutFachIdle = 4; - - if ((NetworkProfiler.getProcessRxBytes() - prevRxBytes) > downlikThreshold - || (NetworkProfiler.getProcessTxBytes() - prevTxBytes) > uplinkThreshold) { - Log.d(TAG, "3G in DCH state from FACH"); - timeoutFachIdle = 4; - threegState = THREEG_IN_DCH_STATE; - threegDchState(); - return; - } - } - - Log.d(TAG, "3G in FACH state"); - threeGActiveState.add(THREEG_IN_FACH_STATE); - } - - private void threegDchState() { - if (timeoutDchFach == 0) { - Log.d(TAG, "3G in FACH state from DCH"); - timeoutDchFach = 6; - threegState = THREEG_IN_FACH_STATE; - fromDchState = true; - threegFachState(); - return; - } else if (telephonyManager.getDataActivity() == TelephonyManager.DATA_ACTIVITY_NONE) { - Log.d(TAG, "3G in DCH state with no data activity"); - timeoutDchFach--; - } else - timeoutDchFach = 6; - - Log.d(TAG, "3G in DCH state"); - threeGActiveState.add(THREEG_IN_DCH_STATE); - } - - public int getWiFiRxPacketRate(int i) { - return wifiRxPackets.get(i).intValue(); - } - - public int getWiFiTxPacketRate(int i) { - return wifiTxPackets.get(i).intValue(); - } - - public boolean noConnectivity() { - return (connectivityManager.getActiveNetworkInfo()) == null; - } - - public int getLinkSpeed() { - if (wifiManager == null) { - wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); - } - WifiInfo wifiInfo = wifiManager.getConnectionInfo(); - return wifiInfo.getLinkSpeed(); - } - - public byte get3GActiveState(int i) { - if (threeGActiveState == null || threeGActiveState.size() <= i) { - return 0; - } - return threeGActiveState.get(i); - } - - public long getUplinkDataRate(int i) { - return wifiTxBytes.get(i); - } - - /** - * Someone sets the data rate manually (maybe for testing) - * - * @param dataRate - */ - public static void setDataRate(int dataRate) { - lastDlRate = new NetworkBWRecord(dataRate, System.currentTimeMillis()); - dlRateHistory.add(lastDlRate); - - lastUlRate = new NetworkBWRecord(dataRate, System.currentTimeMillis()); - ulRateHistory.add(lastUlRate); - } - - public void onDestroy() { - context.unregisterReceiver(networkStateReceiver); - - // if (uploadRateHandler != null) { - // uploadRateHandler.removeCallbacks(uploadRunnable); - // } - // - // if (downloadRateHandler != null) { - // downloadRateHandler.removeCallbacks(downloadRunnable); - // } - } - - public static void measureRtt() { - // TODO - - } - - public static NetworkBWRecord measureDlRate(String serverIp, int serverPort) { - - OutputStream os = null; - InputStream is = null; - DataInputStream dis = null; - - long time = 0; - long rxBytes = 0; - - try { - final Socket clientSocket = new Socket(serverIp, serverPort); - os = clientSocket.getOutputStream(); - is = clientSocket.getInputStream(); - dis = new DataInputStream(is); - - os.write(RapidMessages.DOWNLOAD_FILE); - - new Thread(new Runnable() { - @Override - public void run() { - long t0 = System.nanoTime(); - long elapsed = 0; - while (elapsed < 3000) { - try { - Thread.sleep(3000 - elapsed); - } catch (InterruptedException e1) { - } finally { - elapsed = (System.nanoTime() - t0) / 1000000; - } - } - RapidUtils.closeQuietly(clientSocket); - } - }).start(); - - time = System.nanoTime(); - // rxBytes = NetworkProfiler.getProcessRxBytes(); - while (true) { - rxBytes += is.read(buffer); - os.write(1); - } - - } catch (UnknownHostException e) { - Log.w(TAG, "Exception while measuring download rate: " + e); - } catch (SocketException e) { - Log.w(TAG, "Exception while measuring download rate: " + e); - } catch (IOException e) { - Log.w(TAG, "Exception while measuring download rate: " + e); - } finally { - - time = System.nanoTime() - time; - // rxBytes = NetworkProfiler.getProcessRxBytes() - rxBytes; - - if (os != null) { - - // If the streams are null it means that no measurement was performed - addNewDlRateEstimate(rxBytes, time); - - RapidUtils.closeQuietly(os); - RapidUtils.closeQuietly(is); - RapidUtils.closeQuietly(dis); - } - } - return lastDlRate; - } - - public static NetworkBWRecord measureUlRate(String serverIp, int serverPort) { - - OutputStream os = null; - InputStream is = null; - DataInputStream dis = null; - - long txTime = 0; - long txBytes = 0; - - Socket clientSocket = null; - try { - clientSocket = new Socket(serverIp, serverPort); - os = clientSocket.getOutputStream(); - is = clientSocket.getInputStream(); - dis = new DataInputStream(is); - - os.write(RapidMessages.UPLOAD_FILE); - - while (true) { - os.write(buffer); - is.read(); - } - - } catch (UnknownHostException e) { - Log.w(TAG, "Exception while measuring upload rate: " + e); - } catch (SocketException e) { - Log.w(TAG, "Exception while measuring upload rate: " + e); - } catch (IOException e) { - Log.w(TAG, "Exception while measuring upload rate: " + e); - } finally { - RapidUtils.closeQuietly(os); - RapidUtils.closeQuietly(is); - RapidUtils.closeQuietly(dis); - RapidUtils.closeQuietly(clientSocket); - - try { - clientSocket = new Socket(config.getClone().getIp(), config.getClonePortBandwidthTest()); - os = clientSocket.getOutputStream(); - is = clientSocket.getInputStream(); - dis = new DataInputStream(is); - - os.write(RapidMessages.UPLOAD_FILE_RESULT); - txBytes = dis.readLong(); - txTime = dis.readLong(); - - addNewUlRateEstimate(txBytes, txTime); - - } catch (UnknownHostException e) { - Log.w(TAG, "Exception while measuring upload rate: " + e); - } catch (IOException e) { - Log.w(TAG, "Exception while measuring upload rate: " + e); - } catch (Exception e) { - Log.w(TAG, "Exception while measuring upload rate: " + e); - } finally { - RapidUtils.closeQuietly(os); - RapidUtils.closeQuietly(is); - RapidUtils.closeQuietly(dis); - RapidUtils.closeQuietly(clientSocket); - } - } - return lastUlRate; - } - - private void sleep(long millis) { - try { - Thread.sleep(millis); - } catch (InterruptedException e) { - } - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/profilers/Profiler.java b/AccelerationClient/src/eu/project/rapid/ac/profilers/Profiler.java deleted file mode 100755 index b949bbb..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/profilers/Profiler.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac.profilers; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; - -import android.util.Log; -import eu.project.rapid.ac.db.DBCache; -import eu.project.rapid.ac.db.DBEntry; -import eu.project.rapid.ac.profilers.phone.Phone; -import eu.project.rapid.ac.profilers.phone.PhoneFactory; -import eu.project.rapid.ac.utils.Constants; - - -public class Profiler { - - private static final String TAG = "Profiler"; - - Phone phone; - - private ProgramProfiler progProfiler; - private NetworkProfiler netProfiler; - private DeviceProfiler devProfiler; - private int mRegime; - public static final int REGIME_CLIENT = 1; - public static final int REGIME_SERVER = 2; - - private static FileWriter logFileWriter; - - private String mLocation; - - private LogRecord lastLogRecord; - - public Profiler(int regime, ProgramProfiler progProfiler, NetworkProfiler netProfiler, - DeviceProfiler devProfiler) { - this.progProfiler = progProfiler; - this.netProfiler = netProfiler; - this.devProfiler = devProfiler; - this.mRegime = regime; - - if (mRegime == REGIME_CLIENT) { - // this.devProfiler.trackBatteryLevel(); - } - } - - public void startExecutionInfoTracking() { - - if (netProfiler != null) { - netProfiler.startTransmittedDataCounting(); - mLocation = "REMOTE"; - } else { - mLocation = "LOCAL"; - } - Log.d(TAG, mLocation + " " + progProfiler.methodName); - progProfiler.startExecutionInfoTracking(); - - if (mRegime == REGIME_CLIENT) { - devProfiler.startDeviceProfiling(); - } - } - - private void stopProfilers() { - - if (mRegime == REGIME_CLIENT) { - devProfiler.stopAndCollectDeviceProfiling(); - } - - progProfiler.stopAndCollectExecutionInfoTracking(); - - if (netProfiler != null) { - netProfiler.stopAndCollectTransmittedData(); - } - } - - /** - * Stop running profilers and discard current information - * - */ - public void stopAndDiscardExecutionInfoTracking() { - stopProfilers(); - } - - /** - * Stop running profilers and log current information - * - */ - public void stopAndLogExecutionInfoTracking(long prepareDataDuration, Long pureExecTime) { - - stopProfilers(); - - lastLogRecord = new LogRecord(progProfiler, netProfiler, devProfiler); - lastLogRecord.prepareDataDuration = prepareDataDuration; - lastLogRecord.pureDuration = pureExecTime; - lastLogRecord.execLocation = mLocation; - - if (mRegime == REGIME_CLIENT) { - phone = PhoneFactory.getPhone(devProfiler, netProfiler, progProfiler); - phone.estimateEnergyConsumption(); - lastLogRecord.energyConsumption = phone.getTotalEstimatedEnergy(); - lastLogRecord.cpuEnergy = phone.getEstimatedCpuEnergy(); - lastLogRecord.screenEnergy = phone.getEstimatedScreenEnergy(); - lastLogRecord.wifiEnergy = phone.getEstimatedWiFiEnergy(); - lastLogRecord.threeGEnergy = phone.getEstimated3GEnergy(); - - Log.d(TAG, "Log record - " + lastLogRecord.toString()); - - try { - synchronized (this) { - if (logFileWriter == null) { - File logFile = new File(Constants.LOG_FILE_NAME); - // Try creating new, if doesn't exist - boolean logFileCreated = logFile.createNewFile(); - logFileWriter = new FileWriter(logFile, true); - if (logFileCreated) { - logFileWriter.append(LogRecord.LOG_HEADERS + "\n"); - } - } - - logFileWriter.append(lastLogRecord.toString() + "\n"); - logFileWriter.flush(); - } - } catch (IOException e) { - Log.w(TAG, "Not able to create the logFile " + Constants.LOG_FILE_NAME + ": " + e); - } - - updateDbCache(); - } - } - - private void updateDbCache() { - DBCache dbCache = DBCache.getDbCache(); - // public DBEntry(String appName, String methodName, String execLocation, String networkType, - // String networkSubType, int ulRate, int dlRate, long execDuration, long execEnergy) - DBEntry dbEntry = - new DBEntry(lastLogRecord.appName, lastLogRecord.methodName, lastLogRecord.execLocation, - lastLogRecord.networkType, lastLogRecord.networkSubtype, lastLogRecord.ulRate, - lastLogRecord.dlRate, lastLogRecord.execDuration, lastLogRecord.energyConsumption); - dbCache.insertEntry(dbEntry); - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/profilers/ProgramProfiler.java b/AccelerationClient/src/eu/project/rapid/ac/profilers/ProgramProfiler.java deleted file mode 100755 index 20d8251..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/profilers/ProgramProfiler.java +++ /dev/null @@ -1,229 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac.profilers; - -import android.os.Debug; -import android.util.Log; -import dalvik.bytecode.Opcodes; - -// Removed VMDebug since it cannot be imported for android >= 2.3 -//import dalvik.system.VMDebug; - -public class ProgramProfiler { - - private static final String TAG = "ProgramProfiler"; - - public String appName; - public String methodName; - public Long execTime; - public Long threadCpuTime; - - public int threadAllocSize; - public int instructionCount; - public int methodInvocationCount; - public int gcThreadInvocationCount; - public int gcGlobalInvocationCount; - - private PrivateInstructionCount mIcount; - private Long mStartTime; - private int mStartThreadAllocSize; - private Long mStartThreadCpuTime; - private int mStartThreadGcInvocationCount; - private int mStartGlobalGcInvocationCount; - - private static Integer profilersRunning; - private static Boolean memAllocTrackerRunning; - - public ProgramProfiler() { - methodName = ""; - mIcount = new PrivateInstructionCount(); - if (memAllocTrackerRunning == null) { - memAllocTrackerRunning = false; - profilersRunning = 0; - } - } - - public ProgramProfiler(String appName, String mName) { - this.appName = appName; - methodName = mName; - mIcount = new PrivateInstructionCount(); - if (memAllocTrackerRunning == null) { - memAllocTrackerRunning = false; - profilersRunning = 0; - } - } - - public void startExecutionInfoTracking() { - mStartTime = System.nanoTime(); - mStartThreadCpuTime = Debug.threadCpuTimeNanos(); - - if (memAllocTrackerRunning == false) { - Debug.startAllocCounting(); - memAllocTrackerRunning = true; - } - mStartThreadAllocSize = Debug.getThreadAllocSize(); - mStartThreadGcInvocationCount = Debug.getThreadGcInvocationCount(); - mStartGlobalGcInvocationCount = Debug.getGlobalGcInvocationCount(); - - mIcount.startInstructionCounting(); - profilersRunning++; - } - - public void stopAndCollectExecutionInfoTracking() { - profilersRunning--; - mIcount.stopInstructionCounting(); - instructionCount = mIcount.instructionsExecuted; - methodInvocationCount = mIcount.methodsExecuted; - threadAllocSize = Debug.getThreadAllocSize() - mStartThreadAllocSize; - gcThreadInvocationCount = Debug.getThreadGcInvocationCount() - mStartThreadGcInvocationCount; - gcGlobalInvocationCount = Debug.getGlobalGcInvocationCount() - mStartGlobalGcInvocationCount; - - if (profilersRunning == 0) { - Debug.stopAllocCounting(); - memAllocTrackerRunning = false; - } - - threadCpuTime = Debug.threadCpuTimeNanos() - mStartThreadCpuTime; - execTime = System.nanoTime() - mStartTime; - - Log.d(TAG, methodName + ": Thread Alloc Size - " - + (Debug.getThreadAllocSize() - mStartThreadAllocSize)); - Log.d(TAG, methodName - + "Total instructions executed: " + instructionCount - + " Method invocations: " + methodInvocationCount + "in " - + execTime / 1000000 + "ms"); - } - - /** - * A wrapper class for VMDebug for instruction counting. Needed because of - * issues (probably a bug) in the original debugging library, when counters - * are not correctly altered. - * - * Only start InstructionCounting once, if none is running and only stop - * when the last monitoring method is exiting. - * - */ - private static class PrivateInstructionCount { - private static final int NUM_INSTR = 256; - - private int[] mCounts; - private int mStartInstructions; - private int mStartMethods; - private static int localProfilersRunning; - - public int instructionsExecuted; - public int methodsExecuted; - - public PrivateInstructionCount() { - mCounts = new int[NUM_INSTR]; - instructionsExecuted = 0; - methodsExecuted = 0; - } - - /** - * Start InstructionCounting by taking note of current VM instruction - * count and starting VMDebug InstructionCounting if none is running - */ - public void startInstructionCounting() { - // Sokol: uncomment if switching to android 2.1 -// if (localProfilersRunning == 0) -// VMDebug.startInstructionCounting(); - if (collect()) { - mStartInstructions = globalTotal(); - mStartMethods = globalMethodInvocations(); - } - localProfilersRunning++; - } - - /** - * Stop InstructionCounting by collecting the number of instructions - * executed and stopping VMDebug InstructionCounting if it is the last - * profiler wanting the data. - * - * @return instructions since performing startInstructionCounting() - */ - public void stopInstructionCounting() { - localProfilersRunning--; - // Sokol: uncomment if switching to android 2.1 -// if (localProfilersRunning == 0) -// VMDebug.stopInstructionCounting(); - if (collect()) { - instructionsExecuted = globalTotal() - mStartInstructions; - methodsExecuted = globalMethodInvocations() - mStartMethods; - } - } - - /** - * Method copied from android.os.Debug.InstructionCount class, for loop - * changed to supposedly faster format - * - * @return number of instructions executed globally - */ - public int globalTotal() { - int count = 0; - for (int c : mCounts) { - count += c; - } - - return count; - } - - /** - * Method copied from android.os.Debug.InstructionCount - * - * @return - */ - public int globalMethodInvocations() { - int count = 0; - // count += mCounts[Opcodes.OP_EXECUTE_INLINE]; - count += mCounts[Opcodes.OP_INVOKE_VIRTUAL]; - count += mCounts[Opcodes.OP_INVOKE_SUPER]; - count += mCounts[Opcodes.OP_INVOKE_DIRECT]; - count += mCounts[Opcodes.OP_INVOKE_STATIC]; - count += mCounts[Opcodes.OP_INVOKE_INTERFACE]; - count += mCounts[Opcodes.OP_INVOKE_VIRTUAL_RANGE]; - count += mCounts[Opcodes.OP_INVOKE_SUPER_RANGE]; - count += mCounts[Opcodes.OP_INVOKE_DIRECT_RANGE]; - count += mCounts[Opcodes.OP_INVOKE_STATIC_RANGE]; - count += mCounts[Opcodes.OP_INVOKE_INTERFACE_RANGE]; - // count += mCounts[Opcodes.OP_INVOKE_DIRECT_EMPTY]; - count += mCounts[Opcodes.OP_INVOKE_VIRTUAL_QUICK]; - count += mCounts[Opcodes.OP_INVOKE_VIRTUAL_QUICK_RANGE]; - count += mCounts[Opcodes.OP_INVOKE_SUPER_QUICK]; - count += mCounts[Opcodes.OP_INVOKE_SUPER_QUICK_RANGE]; - return count; - } - - /** - * Method copied from android.os.Debug.InstructionCount - * - * @return - */ - private boolean collect() { - // Sokol: uncomment if switching to android 2.1 -// try { -// VMDebug.getInstructionCount(mCounts); -// } catch (UnsupportedOperationException uoe) { -// return false; -// } -// return true; - - return false; - } - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/profilers/phone/Phone.java b/AccelerationClient/src/eu/project/rapid/ac/profilers/phone/Phone.java deleted file mode 100644 index 5ed772e..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/profilers/phone/Phone.java +++ /dev/null @@ -1,286 +0,0 @@ -package eu.project.rapid.ac.profilers.phone; - -import android.util.Log; -import eu.project.rapid.ac.profilers.DeviceProfiler; -import eu.project.rapid.ac.profilers.NetworkProfiler; -import eu.project.rapid.ac.profilers.ProgramProfiler; - -/** - * This is the abstract class that contains the coefficients for the energy estimation model. - * - * @author sokol - * - */ -public abstract class Phone { - - private final String TAG = "Phone"; - - private DeviceProfiler devProfiler; - private NetworkProfiler netProfiler; - private ProgramProfiler progProfiler; - - // CPU - int MIN_FREQ; // The minimum frequency of the CPU - int MAX_FREQ; // The maximum frequency of the CPU - double betaUh; - double betaUl; - double betaCpu; - - // Screen - double betaBrightness; - - // WiFi - double betaWiFiHigh; - int betaWiFiLow; - - // 3G - int beta3GIdle; - int beta3GFACH; - int beta3GDCH; - - private long totalEstimatedEnergy; - private double estimatedCpuEnergy; - private double estimatedScreenEnergy; - private double estimatedWiFiEnergy; - private double estimated3GEnergy; - - public Phone(DeviceProfiler devProfiler, NetworkProfiler netProfiler, - ProgramProfiler progProfiler) { - - this.devProfiler = devProfiler; - this.netProfiler = netProfiler; - this.progProfiler = progProfiler; - } - - public void estimateEnergyConsumption() { - int duration = devProfiler.getSeconds(); - - estimatedCpuEnergy = estimateCpuEnergy(duration); - Log.d(TAG, "CPU energy: " + estimatedCpuEnergy + " mJ"); - - estimatedScreenEnergy = estimateScreenEnergy(duration); - Log.d(TAG, "Screen energy: " + estimatedScreenEnergy + " mJ"); - - // if (lastLogRecord.execLocation.equals("REMOTE") && lastLogRecord.networkType.equals("WIFI")) - // { - estimatedWiFiEnergy = estimateWiFiEnergy(duration); - Log.d(TAG, "WiFi energy: " + estimatedWiFiEnergy + " mJ"); - // } else if (lastLogRecord.execLocation.equals("REMOTE") && - // lastLogRecord.networkType.equals("MOBILE")) { - estimated3GEnergy = estimate3GEnergy(duration); - Log.d(TAG, "3G energy: " + estimated3GEnergy + " mJ"); - // } - - totalEstimatedEnergy = (long) (estimatedCpuEnergy + estimatedScreenEnergy + estimatedWiFiEnergy - + estimated3GEnergy); - - Log.d(TAG, "Total energy: " + totalEstimatedEnergy + " mJ"); - Log.d(TAG, "-------------------------------------------"); - } - - /** - * Estimate the Power for the CPU every second: P0, P1, P2, ..., Pt
- * where t is the execution time in seconds.
- * If we calculate the average power Pm = (P0 + P1 + ... + Pt) / t and multiply
- * by the execution time we obtain the Energy consumed by the CPU executing the method.
- * This is: E_cpu = Pm * t which is equal to: E_cpu = P0 + P1 + ... + Pt
- * NOTE: This is due to the fact that we measure every second.
- * - * @param duration Duration of method execution - * @return The estimated energy consumed by the CPU (mJ) - * - */ - private double estimateCpuEnergy(int duration) { - double estimatedCpuEnergy = 0; - byte freqL = 0, freqH = 0; - int util; - byte cpuON; - - for (int i = 0; i < duration; i++) { - util = calculateCpuUtil(i); - - if (devProfiler.getFrequence(i) == MAX_FREQ) { - freqH = 1; - } else { - freqL = 1; - } - - /** - * If the CPU has been in idle state for more than 90 jiffies
- * then decide to consider it in idle state for all the second (1 jiffie = 1/100 sec) - */ - cpuON = (byte) ((devProfiler.getIdleSystem(i) < 90) ? 1 : 0); - - estimatedCpuEnergy += (betaUh * freqH + betaUl * freqL) * util + betaCpu * cpuON; - - // Log.d(TAG, "util freqH freqL cpuON power: " + - // util + " " + freqH + " " + freqL + " " + cpuON + - // " " + estimatedCpuEnergy + "mJ"); - - // Log.d(TAG, "CPU Energy: " + estimatedCpuEnergy + "mJ"); - - freqH = 0; - freqL = 0; - } - - return estimatedCpuEnergy; - } - - private int calculateCpuUtil(int i) { - return (int) Math.ceil(100 * devProfiler.getPidCpuUsage(i) / devProfiler.getSystemCpuUsage(i)); - } - - - private double estimateScreenEnergy(int duration) { - double estimatedScreenEnergy = 0; - - for (int i = 0; i < duration; i++) { - estimatedScreenEnergy += betaBrightness * devProfiler.getScreenBrightness(i); - } - - return estimatedScreenEnergy; - } - - - /** - * The WiFi interface can be (mainly) in two states: high_state or low_state
- * Transition from low_state to high_state happens when packet_rate > 15
- * packet_rate = (nRxPackets + nTxPackets) / s
- * RChannel: WiFi channel rate
- * Rdata: WiFi data rate
- * - * @param duration Duration of method execution - * @return The estimated energy consumed by the WiFi interface (mJ) - * - */ - private double estimateWiFiEnergy(int duration) { - - if (netProfiler == null) { - return 0; - } - - double estimatedWiFiEnergy = 0; - boolean inHighPowerState = false; - int nRxPackets, nTxPackets; - double betaRChannel; - // double betaWiFiHigh; - double Rdata; - - for (int i = 0; i < duration; i++) { - nRxPackets = netProfiler.getWiFiRxPacketRate(i); - nTxPackets = netProfiler.getWiFiTxPacketRate(i); - Rdata = (netProfiler.getUplinkDataRate(i) * 8) / 1000000; // Convert from B/s -> b/s -> Mb/s - - // The Wifi interface transits to the high-power state if the packet rate - // is higher than 15 (according to the paper of PowerTutor) - // Then the transition to the low-power state is done when the packet rate - // is lower than 8 - if (!inHighPowerState) { - if (nRxPackets + nTxPackets > 15) { - inHighPowerState = true; - betaRChannel = calculateBetaRChannel(); - betaWiFiHigh = 710 + betaRChannel * Rdata; - estimatedWiFiEnergy += betaWiFiHigh; - } else { - estimatedWiFiEnergy += betaWiFiLow; - } - } else { - if (nRxPackets + nTxPackets < 8) { - inHighPowerState = false; - estimatedWiFiEnergy += betaWiFiLow; - } else { - betaRChannel = calculateBetaRChannel(); - betaWiFiHigh = 710 + betaRChannel * Rdata; - estimatedWiFiEnergy += betaWiFiHigh; - } - } - - // Log.d(TAG, "nRxPackets nTxPackets: " + nRxPackets + " " + nTxPackets); - // Log.d(TAG, "Partial Wifi Energy: " + estimatedWiFiEnergy + " mJ"); - } - - return estimatedWiFiEnergy; - } - - private double calculateBetaRChannel() { - // The Channel Rate of WiFi connection (Mbps) - int RChannel = netProfiler.getLinkSpeed(); - return 48 - 0.768 * RChannel; - } - - /** - * In the powerTutor paper the states of 3G interface are three: idle, cell_fach and - * cell_dch
- * Transition from idle to cell_fach happens if there are data to send or receive - *
- * Transition from cell_fach to idle happens if no activity for 4 seconds
- * Transition from cell_fach to cell_dch happens when uplink_buffer > uplink_queue ore d_b > d_q - *
- * Transition from cell_dch to cell_fach happens if no activity for 6 seconds. - * - * @param duration Duration of method execution - * @return The estimated energy consumed by the 3G interface (mJ) - * - */ - private double estimate3GEnergy(int duration) { - - if (netProfiler == null) { - return 0; - } - - double estimated3GEnergy = 0; - - for (int i = 0; i < duration; i++) { - switch (netProfiler.get3GActiveState(i)) { - case NetworkProfiler.THREEG_IN_IDLE_STATE: - estimated3GEnergy += beta3GIdle; - break; - - case NetworkProfiler.THREEG_IN_FACH_STATE: - estimated3GEnergy += beta3GFACH; - break; - - case NetworkProfiler.THREEG_IN_DCH_STATE: - estimated3GEnergy += beta3GDCH; - break; - } - } - - return estimated3GEnergy; - } - - /** - * @return the totalEstimatedEnergy - */ - public long getTotalEstimatedEnergy() { - return totalEstimatedEnergy; - } - - /** - * @return the estimatedCpuEnergy - */ - public double getEstimatedCpuEnergy() { - return estimatedCpuEnergy; - } - - /** - * @return the estimatedScreenEnergy - */ - public double getEstimatedScreenEnergy() { - return estimatedScreenEnergy; - } - - /** - * @return the estimatedWiFiEnergy - */ - public double getEstimatedWiFiEnergy() { - return estimatedWiFiEnergy; - } - - /** - * @return the estimated3GEnergy - */ - public double getEstimated3GEnergy() { - return estimated3GEnergy; - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/profilers/phone/PhoneAlcatelOneTouchPixi.java b/AccelerationClient/src/eu/project/rapid/ac/profilers/phone/PhoneAlcatelOneTouchPixi.java deleted file mode 100644 index 640673a..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/profilers/phone/PhoneAlcatelOneTouchPixi.java +++ /dev/null @@ -1,32 +0,0 @@ -package eu.project.rapid.ac.profilers.phone; - -import eu.project.rapid.ac.profilers.DeviceProfiler; -import eu.project.rapid.ac.profilers.NetworkProfiler; -import eu.project.rapid.ac.profilers.ProgramProfiler; - -public class PhoneAlcatelOneTouchPixi extends Phone { - - public PhoneAlcatelOneTouchPixi(DeviceProfiler devProfiler, NetworkProfiler netProfiler, - ProgramProfiler progProfiler) { - super(devProfiler, netProfiler, progProfiler); - - // CPU - MIN_FREQ = 598000; // The minimum frequency (KHz) - MAX_FREQ = 1000000; // The maximum frequency (KHz) - betaUh = 0.1232; // (mW/MHz) - betaUl = 0.094; // (mW/MHz) - betaCpu = 18.438; // (mW) - - // Screen - betaBrightness = 0.591; // (mW) - - // WiFi - betaWiFiLow = 5; // (mW) - betaWiFiHigh = 155; // (mW) - - // 3G - beta3GIdle = 10; // (mW) - beta3GFACH = 510; // (mW) - beta3GDCH = 672; // (mW) - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/profilers/phone/PhoneFactory.java b/AccelerationClient/src/eu/project/rapid/ac/profilers/phone/PhoneFactory.java deleted file mode 100644 index 4c4f131..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/profilers/phone/PhoneFactory.java +++ /dev/null @@ -1,23 +0,0 @@ -package eu.project.rapid.ac.profilers.phone; - -import eu.project.rapid.ac.profilers.DeviceProfiler; -import eu.project.rapid.ac.profilers.NetworkProfiler; -import eu.project.rapid.ac.profilers.ProgramProfiler; -import eu.project.rapid.ac.utils.Constants; - -public class PhoneFactory { - - private PhoneFactory() {}; - - public static Phone getPhone(DeviceProfiler devProfiler, NetworkProfiler netProfiler, - ProgramProfiler progProfiler) { - if (android.os.Build.MODEL.equals(Constants.PHONE_NAME_HTC_G1)) { - return new PhoneHtcDream(devProfiler, netProfiler, progProfiler); - } - // Add here all the cases for the other phones. - else { - // By default, if the current phone's call is not implemented yet, use the htc dream. - return new PhoneHtcDream(devProfiler, netProfiler, progProfiler); - } - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/profilers/phone/PhoneHtcDream.java b/AccelerationClient/src/eu/project/rapid/ac/profilers/phone/PhoneHtcDream.java deleted file mode 100644 index ab9dce8..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/profilers/phone/PhoneHtcDream.java +++ /dev/null @@ -1,31 +0,0 @@ -package eu.project.rapid.ac.profilers.phone; - -import eu.project.rapid.ac.profilers.DeviceProfiler; -import eu.project.rapid.ac.profilers.NetworkProfiler; -import eu.project.rapid.ac.profilers.ProgramProfiler; - -public class PhoneHtcDream extends Phone { - - public PhoneHtcDream(DeviceProfiler devProfiler, NetworkProfiler netProfiler, - ProgramProfiler progProfiler) { - super(devProfiler, netProfiler, progProfiler); - - // CPU - MIN_FREQ = 245760; // The minimum frequency for HTC Dream CPU - MAX_FREQ = 352000; // The maximum frequency for HTC Dream CPU - betaUh = 4.34; - betaUl = 3.42; - betaCpu = 121.46; - - // Screen - betaBrightness = 2.4; - - // WiFi - betaWiFiLow = 20; - - // 3G - beta3GIdle = 10; - beta3GFACH = 401; - beta3GDCH = 570; - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/profilers/phone/PhoneMotorolaMotoG.java b/AccelerationClient/src/eu/project/rapid/ac/profilers/phone/PhoneMotorolaMotoG.java deleted file mode 100644 index 7bd1211..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/profilers/phone/PhoneMotorolaMotoG.java +++ /dev/null @@ -1,14 +0,0 @@ -package eu.project.rapid.ac.profilers.phone; - -import eu.project.rapid.ac.profilers.DeviceProfiler; -import eu.project.rapid.ac.profilers.NetworkProfiler; -import eu.project.rapid.ac.profilers.ProgramProfiler; - -public class PhoneMotorolaMotoG extends Phone { - - public PhoneMotorolaMotoG(DeviceProfiler devProfiler, NetworkProfiler netProfiler, - ProgramProfiler progProfiler) { - super(devProfiler, netProfiler, progProfiler); - // TODO Auto-generated constructor stub - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/utils/Constants.java b/AccelerationClient/src/eu/project/rapid/ac/utils/Constants.java deleted file mode 100644 index 14ff9e7..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/utils/Constants.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac.utils; - -import java.io.File; - -import android.os.Environment; - -public class Constants { - - public static final int MAX_NUM_CLIENTS = 32; - - public static final String DEFAULT_DB_NAME = "Rapid-DB.db"; - // The number of recent method executions to keep in DB so that they can be used for offloading - // decision. - public static final int MAX_METHOD_EXEC_HISTORY = 50; - - // Offloading decision related variables - // public static final int LOCATION_NOT_DECIDED = -1; - public static final int LOCATION_LOCAL = 1; - public static final int LOCATION_REMOTE = 2; - public static final int LOCATION_HYBRID = 3; - public static final int LOCATION_DYNAMIC_TIME = 4; - public static final int LOCATION_DYNAMIC_ENERGY = 5; - public static final int LOCATION_DYNAMIC_TIME_ENERGY = 6; - - // TODO: check the real device name as returned by android for the HTC G1 phone - public static final String PHONE_NAME_HTC_G1 = "HTC G1"; - public static final String PHONE_MODEL_HTC_DESIRE = "HTC Desire"; - public static final String PHONE_MODEL_SAMSUNG_GALAXY_S = "samsung GT-I9000"; - public static final String PHONE_MODEL_MOTOROLA_MOTO_G = "Motorola Moto G"; - - public enum SETUP_TYPE { - KVM, VIRTUALBOX, AMAZON, HYBRID - } - - public static final String RAPID_SETTINGS = "rapid_settings"; - public static final String MY_OLD_ID = "MY_OLD_ID"; - public static final String PREV_VM_IP = "PREV_VM_IP"; - public static final String PREV_VMM_IP = "PREV_VMM_IP"; - public static final String MY_OLD_ID_WITH_DS = "MY_OLD_ID_WITH_DS"; - - public static final String MNT_SDCARD = - Environment.getExternalStorageDirectory().getAbsolutePath(); - // public static final String MNT_SDCARD = "/mnt/sdcard/"; - - public static final String RAPID_FOLDER = MNT_SDCARD + File.separator + "rapid"; - public static final String CLONE_CONFIG_FILE = RAPID_FOLDER + File.separator + "config-clone.cfg"; - public static final String PHONE_CONFIG_FILE = RAPID_FOLDER + File.separator + "config-phone.cfg"; - public static final String TEST_LOGS_FOLDER = - RAPID_FOLDER + File.separator + "test_logs" + File.separator; - public static final String LOG_FILE_NAME = RAPID_FOLDER + File.separator + "rapid-log.csv"; - public static final String SSL_KEYSTORE = RAPID_FOLDER + File.separator + "keystore.bks"; - public static final String SSL_CA_TRUSTSTORE = - RAPID_FOLDER + File.separator + "ca_truststore.bks"; - public static final String SSL_CERT_ALIAS = "cert"; - public static final String SSL_DEFAULT_PASSW = "changeme"; - - public static final String FILE_OFFLOADED = RAPID_FOLDER + File.separator + "offloaded"; - public static final String FILE_D2D_PHONES = RAPID_FOLDER + File.separator + "d2d-phones-set.ser"; - public static final String FILE_DB_CACHE = RAPID_FOLDER + File.separator + "dbCache.ser"; - public static final String CLONE_ID_FILE = RAPID_FOLDER + File.separator + "cloneId"; - public static final String FACE_PICTURE_FOLDER = RAPID_FOLDER + File.separator + "faceDetection"; - // Memory space problem for amazon clones - public static final String FACE_PICTURE_FOLDER_CLONE = "/system/etc/faceDetection/"; - public static final String FACE_PICTURE_TEST = RAPID_FOLDER + "/faceDetection/test.jpg"; - - public static final String VIRUS_DB_PATH = RAPID_FOLDER + File.separator + "virusDB"; - public static final String VIRUS_FOLDER_TO_SCAN = - RAPID_FOLDER + File.separator + "virusFolderToScan_big"; - public static final String VIRUS_FILES_EXCLUDE_ZIP = - RAPID_FOLDER + File.separator + "filesExcludeZip.txt"; - public static final String VIRUS_FOLDER_TAR_GZ = VIRUS_FOLDER_TO_SCAN + ".tar.gz"; - public static final String VIRUS_FOLDER_ZIP = VIRUS_FOLDER_TO_SCAN + ".zip"; - - // The constants of the configuration files - public static final String DEMO_SERVER_IP = "[DEMO SERVER IP]"; - public static final String DEMO_SERVER_PORT = "[DEMO SERVER PORT]"; - public static final String DS_IP = "[DS IP]"; - public static final String DS_PORT = "[DS PORT]"; - public static final String MANAGER_IP = "[MANAGER IP]"; - public static final String MANAGER_PORT = "[MANAGER PORT]"; - public static final String CLONE_TYPES = "[CLONE TYPES]"; // Type has to be one of: Local, Amazon, - // or Hybrid - public static final String NR_CLONES_KVM_TO_START = "[NUMBER OF KVM CLONES TO START ON STARTUP]"; - public static final String NR_CLONES_VB_TO_START = "[NUMBER OF VB CLONES TO START ON STARTUP]"; - public static final String NR_CLONES_AMAZON_TO_START = - "[NUMBER OF AMAZON CLONES TO START ON STARTUP]"; - public static final String KVM_CLONES = "[KVM CLONES]"; - public static final String VB_CLONES = "[VIRTUALBOX CLONES]"; - public static final String AMAZON_CLONES = "[AMAZON CLONES]"; - public static final String CLONE_PORT = "[CLONE PORT]"; - public static final String CLONE_SSL_PORT = "[CLONE SSL PORT]"; - public static final String CLONE_BW_TEST_PORT = "[CLONE BW TEST PORT]"; - public static final String CLONE_NAME = "[CLONE NAME]"; - public static final String CLONE_ID = "[CLONE ID]"; - - public static final int D2D_BROADCAST_PORT = 7654; - public static final int D2D_BROADCAST_INTERVAL = 60 * 1000; // frequency (ms) to broadcast the - // hello message - - public static final String MANAGER_CONFIG_FILE = "config-manager.cfg"; - public static final String DS_CONFIG_FILE = "config-ds.cfg"; -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/utils/Utils.java b/AccelerationClient/src/eu/project/rapid/ac/utils/Utils.java deleted file mode 100644 index f3b941e..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/utils/Utils.java +++ /dev/null @@ -1,751 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac.utils; - -import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.RandomAccessFile; -import java.io.StreamCorruptedException; -import java.net.Inet4Address; -import java.net.InetAddress; -import java.net.InterfaceAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.nio.channels.FileChannel; -import java.nio.channels.FileLock; -import java.nio.charset.Charset; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Scanner; - -import android.content.Context; -import android.telephony.TelephonyManager; -import android.util.Log; - -public class Utils { - - private static final String TAG = "RapidUtils"; - private final static char[] hexArray = "0123456789ABCDEF".toCharArray(); - private final static Map hexToDec = new HashMap(); - private static Object syncFeatureObject = new Object(); - - static { - hexToDec.put('A', 10); - hexToDec.put('B', 11); - hexToDec.put('C', 12); - hexToDec.put('D', 13); - hexToDec.put('E', 14); - hexToDec.put('F', 15); - } - - public static String bytesToHex(byte[] bytes) { - - char[] hexChars = new char[bytes.length * 2]; - for (int j = 0; j < bytes.length; j++) { - int v = bytes[j] & 0xFF; - hexChars[j * 2] = hexArray[v >>> 4]; - hexChars[j * 2 + 1] = hexArray[v & 0x0F]; - } - return new String(hexChars).trim(); - } - - public static byte[] hexToBytes(String hexString) { - byte[] bytes = new byte[hexString.length() / 2]; - - for (int i = 0; i < hexString.length(); i += 2) { - char c1 = hexString.charAt(i); - char c2 = hexString.charAt(i + 1); - - int n1 = Character.getNumericValue(c1); - if (n1 < 0) { - n1 = hexToDec.get(c1); - } - - int n2 = Character.getNumericValue(c2); - if (n2 < 0) { - n2 = hexToDec.get(c2); - } - - bytes[i / 2] = (byte) (n1 * 16 + n2); - } - - return bytes; - } - - public static byte[] objectToByteArray(Object o) throws IOException { - byte[] bytes = null; - ByteArrayOutputStream bos = null; - ObjectOutputStream oos = null; - try { - bos = new ByteArrayOutputStream(); - oos = new ObjectOutputStream(bos); - oos.writeObject(o); - oos.flush(); - bytes = bos.toByteArray(); - } finally { - if (oos != null) { - oos.close(); - } - if (bos != null) { - bos.close(); - } - } - return bytes; - } - - public static Object byteArrayToObject(byte[] bytes) - throws StreamCorruptedException, IOException, ClassNotFoundException { - Object obj = null; - ByteArrayInputStream bis = null; - ObjectInputStream ois = null; - try { - bis = new ByteArrayInputStream(bytes); - ois = new ObjectInputStream(bis); - obj = ois.readObject(); - } finally { - if (bis != null) { - bis.close(); - } - if (ois != null) { - ois.close(); - } - } - return obj; - } - - /** - * @param context The context of the app calling this method. - * @return The unique ID of this device, which usually is the IMEI. - */ - private static String getDeviceId(Context context) { - TelephonyManager telephonyManager = - (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); - String deviceId = telephonyManager.getDeviceId(); - - return (deviceId != null ? deviceId : "null"); - } - - public static String getDeviceIdHashHex(Context context) { - return sha256HashHex(getDeviceId(context)); - } - - public static byte[] getDeviceIdHashByteArray(Context context) { - return sha256HashByteArray(getDeviceId(context)); - } - - /** - * read the file: /sys/devices/system/cpu/possible
- * output: 0-n - * - * @return (n+1) or -1 if file not found. - */ - public static int getDeviceNrCPUs() { - // read the file: /sys/devices/system/cpu/possible - // output: 0-3 - Scanner s = null; - String fileName = "/sys/devices/system/cpu/possible"; - try { - s = (new Scanner(new File(fileName))); - s.useDelimiter("[-\n]"); - s.nextInt(); - return s.nextInt() + 1; - } catch (Exception e) { - Log.e(TAG, "Could not read number of CPUs: " + e); - } finally { - if (s != null) { - s.close(); - } - } - - return -1; - } - - /** - * read the file: /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
- * output: 1190400 (in KHz) - * - * @return The frequency of cpu0 in KHz or -1 if file not found - */ - public static int getDeviceCPUFreq() { - String fileName = "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"; - Scanner s = null; - try { - s = (new Scanner(new File(fileName))); - return s.nextInt(); - } catch (Exception e) { - Log.e(TAG, "Could not read frequence: " + e); - } finally { - if (s != null) { - s.close(); - } - } - - return -1; - } - - /** - * @param s The string to be hash-ed. - * @return The byte array hash digested result. - */ - public static byte[] sha256HashByteArray(String s) { - byte[] hash = null; - try { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - hash = md.digest(s.getBytes()); - } catch (NoSuchAlgorithmException e) { - Log.e(TAG, "Algorithm not found while hashing string: " + e); - // e.printStackTrace(); - } - - return hash; - } - - public static String sha256HashHex(String s) { - return bytesToHex(sha256HashByteArray(s)); - } - - /** - * This utility method will be used to write an object on a file. The object can be a Set, a Map, - * etc.
- * The method creates a lock file (if it doesn't exist) and tries to get a blocking lock on - * the lock file. After writing the object the lock is released, so that other processes that want - * to read the file can access it by getting the lock. - * - * @param filePath The full path of the file where to write the object. If the file exists it will - * first be deleted and then created from scratch. - * @param obj The object to write on the file. - * @throws IOException - */ - public static void writeObjectToFile(String filePath, Object obj) throws IOException { - // Get a lock on the lockFile so that concurrent DFEs don't mess with each other by - // reading/writing the d2dSetFile. - File lockFile = new File(filePath + ".lock"); - // Create a FileChannel that can read and write that file. - // This will create the file if it doesn't exit. - RandomAccessFile file = new RandomAccessFile(lockFile, "rw"); - FileChannel f = file.getChannel(); - - // Try to get an exclusive lock on the file. - // FileLock lock = f.tryLock(); - FileLock lock = f.lock(); - - // Now we have the lock, so we can write on the file - File outFile = new File(filePath); - if (outFile.exists()) { - outFile.delete(); - } - outFile.createNewFile(); - FileOutputStream fout = new FileOutputStream(outFile); - ObjectOutputStream oos = new ObjectOutputStream(fout); - oos.writeObject(obj); - oos.close(); - - // Now we release the lock and close the lockFile - lock.release(); - file.close(); - } - - /** - * Reads the previously serialized object from the filename.
- * This method will try to get a non blocking lock on a lock file. - * - * @param filePath The full path of the file from where to read the object. - * @return The serialized object previously written using the method - * writeObjectToFile - * @throws IOException - * @throws ClassNotFoundException - */ - public static Object readObjectFromFile(String filePath) - throws IOException, ClassNotFoundException { - Object obj = null; - - // First try to get the lock on a lock file - File lockFile = new File(filePath + ".lock"); - if (!lockFile.exists()) { - // It means that no other process has written an object before. - return null; - } - - // Create a FileChannel that can read and write that file. - // This will create the file if it doesn't exit. - RandomAccessFile file = new RandomAccessFile(lockFile, "rw"); - FileChannel f = file.getChannel(); - - // Try to get an exclusive lock on the file. - // FileLock lock = f.tryLock(); - FileLock lock = f.lock(); - - // Now we have the lock, so we can read from the file - File inFile = new File(filePath); - FileInputStream fis = new FileInputStream(inFile); - ObjectInputStream ois = new ObjectInputStream(fis); - obj = ois.readObject(); - ois.close(); - - // Now we release the lock and close the lockFile - lock.release(); - file.close(); - return obj; - } - - /** - * Get IP address from first non-localhost interface - * - * @return address or null - */ - public static InetAddress getIpAddress() { - try { - List interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); - for (NetworkInterface intf : interfaces) { - // Log.i(TAG, "Interface: " + intf); - List addrs = Collections.list(intf.getInetAddresses()); - for (InetAddress addr : addrs) { - // Sokol: FIXME remove the hard coded "wlan" check - // Log.i(TAG, "IP: " + addr); - if (intf.getDisplayName().contains("wlan") && !addr.isLoopbackAddress() - // && InetAddressUtils.isIPv4Address(addr.getHostAddress())) { - && addr instanceof Inet4Address) { - return addr; - } - // On emulator - if (intf.getDisplayName().contains("eth0") && !addr.isLoopbackAddress() - // && InetAddressUtils.isIPv4Address(addr.getHostAddress())) { - && addr instanceof Inet4Address) { - return addr; - } - } - } - } catch (Exception e) { - Log.i(TAG, "Exception while getting IP address: " + e); - } - return null; - } - - public static InetAddress getBroadcast(InetAddress myIpAddress) { - - NetworkInterface temp; - InetAddress iAddr = null; - try { - temp = NetworkInterface.getByInetAddress(myIpAddress); - List addresses = temp.getInterfaceAddresses(); - - for (InterfaceAddress inetAddress : addresses) { - iAddr = inetAddress.getBroadcast(); - } - Log.d(TAG, "iAddr=" + iAddr); - return iAddr; - - } catch (SocketException e) { - - e.printStackTrace(); - Log.d(TAG, "getBroadcast" + e.getMessage()); - } - return null; - } - - /** - * An empty file will be created automatically on the clone by Acceleration-Server. The presence - * or absence of this file can let the method know if it is running on the phone or on the clone. - * - * @return True if it is running on the clone
- * False if it is running on the phone. - */ - public static boolean isOffloaded() { - try { - File tempFile = new File(Constants.FILE_OFFLOADED); - return tempFile.exists(); - } catch (Exception e) { - return true; - } - } - - /** - * Execute a shell command on an Android device - * - * @param TAG - * @param cmd - * @param asRoot - * @return - */ - public static int executeAndroidShellCommand(String TAG, String cmd, boolean asRoot) { - Process p = null; - DataOutputStream outs = null; - int shellComandExitValue = 0; - - try { - long startTime = System.currentTimeMillis(); - - if (asRoot) { - p = Runtime.getRuntime().exec("su"); - outs = new DataOutputStream(p.getOutputStream()); - outs.writeBytes(cmd + "\n"); - outs.writeBytes("exit\n"); - outs.close(); - } else { - p = Runtime.getRuntime().exec(cmd); - outs = new DataOutputStream(p.getOutputStream()); - outs.writeBytes("exit\n"); - outs.close(); - } - - shellComandExitValue = p.waitFor(); - Log.i(TAG, "Executed cmd: " + cmd + " in " + (System.currentTimeMillis() - startTime) - + " ms (exitValue: " + shellComandExitValue + ")"); - - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - // destroyProcess(p); - try { - if (outs != null) - outs.close(); - // p.destroy(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - return shellComandExitValue; - } - - /** - * Write the ID of this clone on the file "/mnt/sdcard/rapid/cloneId".
- * The IDs are assigned by the main clone during the PING and are consecutive. The main clone has - * cloneHelperId equal to 0. The IDs can be used by the developer when parallelizing the - * applications among multiple clones. He can use the IDs to split the data input and assign - * portions to clones based on their ID. - * - * @param cloneHelperId the ID of this clone assigned by the main clone. - */ - public static void writeCloneHelperId(int cloneHelperId) { - try { - File cloneIdFile = new File(Constants.CLONE_ID_FILE); - FileWriter cloneIdWriter = new FileWriter(cloneIdFile); - cloneIdWriter.write(String.valueOf(cloneHelperId)); - cloneIdWriter.close(); - } catch (IOException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * Read the file "/mnt/sdcard/rapid/cloneId" for the ID of this clone. - * - * @return 0 if this is the phone or the main clone (the file may even not exist in these cases) - *
- * CLONE_ID otherwise - */ - public static int readCloneHelperId() { - Scanner cloneIdReader = null; - int cloneId = 0; - - try { - File cloneIdFile = new File(Constants.CLONE_ID_FILE); - cloneIdReader = new Scanner(cloneIdFile); - cloneId = cloneIdReader.nextInt(); - } catch (Exception e) { - // Stay quiet, we know it. - } finally { - try { - cloneIdReader.close(); - } catch (Exception e) { - Log.e(TAG, - "CloneId file is not here, this means that this is the main clone (or the phone)"); - } - } - - return cloneId; - } - - /** - * Delete the file containing the cloneHelperId. - */ - public static void deleteCloneHelperId() { - File cloneIdFile = new File(Constants.CLONE_ID_FILE); - cloneIdFile.delete(); - } - - private static final String SCRIPT_FILE = "temp_sokol.sh"; - - public static int runScript(Context ctx, String script, StringBuilder res, boolean asroot) { - final File file = new File(ctx.getDir("bin", 0), SCRIPT_FILE); - final ScriptRunner runner = new ScriptRunner(file, script, res, asroot); - runner.start(); - try { - runner.join(); - } catch (InterruptedException ex) { - } - return runner.exitcode; - } - - /** - * Run a script in Android. - * - */ - public static final class ScriptRunner extends Thread { - private final File file; - private final String script; - private final StringBuilder res; - private final boolean asroot; - public int exitcode = -1; - private Process exec; - private static final String TAG = "ScriptRunner"; - - /** - * Creates a new script runner. - * - * @param file temporary script file - * @param script script to run - * @param res response output - * @param asroot if true, executes the script as root - */ - public ScriptRunner(File file, String script, StringBuilder res, boolean asroot) { - this.file = file; - this.script = script; - this.res = res; - this.asroot = asroot; - } - - @Override - public void run() { - try { - Log.d(TAG, "Running script: " + script); - - file.createNewFile(); - final String abspath = file.getAbsolutePath(); - // make sure we have execution permission on the script file - Runtime.getRuntime().exec("chmod 777 " + abspath).waitFor(); - // Write the script to be executed - final OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file)); - if (new File("/system/bin/sh").exists()) { - out.write("#!/system/bin/sh\n"); - } - out.write(script); - if (!script.endsWith("\n")) - out.write("\n"); - out.write("exit\n"); - out.flush(); - out.close(); - if (this.asroot) { - // Create the "su" request to run the script - exec = Runtime.getRuntime().exec("su -c " + abspath); - } else { - // Create the "sh" request to run the script - exec = Runtime.getRuntime().exec("sh " + abspath); - } - final InputStream stdout = exec.getInputStream(); - final InputStream stderr = exec.getErrorStream(); - final byte buf[] = new byte[8192]; - int read = 0; - while (true) { - final Process localexec = exec; - if (localexec == null) - break; - try { - // get the process exit code - will raise IllegalThreadStateException if still running - this.exitcode = localexec.exitValue(); - } catch (IllegalThreadStateException ex) { - // The process is still running - } - // Read stdout - if (stdout.available() > 0) { - read = stdout.read(buf); - if (res != null) - res.append(new String(buf, 0, read)); - } - // Read stderr - if (stderr.available() > 0) { - read = stderr.read(buf); - if (res != null) - res.append(new String(buf, 0, read)); - } - if (this.exitcode != -1) { - // finished - break; - } - // Sleep for the next round - Thread.sleep(50); - } - } catch (InterruptedException ex) { - Log.i(TAG, "InterruptedException "); - ex.printStackTrace(); - if (res != null) - res.append("\nOperation timed-out"); - } catch (Exception ex) { - Log.i(TAG, "Exception"); - ex.printStackTrace(); - if (res != null) - res.append("\n" + ex); - } finally { - destroy(); - } - } - - /** - * Destroy this script runner - */ - public synchronized void destroy() { - if (exec != null) - exec.destroy(); - exec = null; - } - } - - public static long copy(InputStream from, OutputStream to) throws IOException { - // checkNotNull(from); - // checkNotNull(to); - byte[] buf = createBuffer(); - long total = 0; - while (true) { - int r = from.read(buf); - if (r == -1) { - break; - } - to.write(buf, 0, r); - total += r; - } - return total; - } - - static byte[] createBuffer() { - return new byte[8192]; - } - - public static byte[] toByteArray(InputStream in) throws IOException { - // Presize the ByteArrayOutputStream since we know how large it will need - // to be, unless that value is less than the default ByteArrayOutputStream - // size (32). - ByteArrayOutputStream out = new ByteArrayOutputStream(Math.max(32, in.available())); - copy(in, out); - return out.toByteArray(); - } - - public static String readAssetFileAsString(Context context, String fileName) throws IOException { - InputStream is = context.getAssets().open(fileName); - - byte[] bytes = toByteArray(is); - is.close(); - return new String(bytes, Charset.forName("UTF-8")); - } - - - /** - * Write an object to the internal memory of this application. We will use this method to store - * the features of the user so that other components of our application can read them. The object - * will then be read using the method readObjectFromInternalFile. We synchronize the - * writing and reading process so that we don't end up reading a partial object. - * - * @param context The context of the application. Needed to access the internal file directory. - * @param o The object to store. - * @param fileName The name of the file where to store the object. - * @throws IOException - */ - public static void saveObjectToInternalFile(Context context, Object o, String fileName) - throws IOException { - File f = new File(context.getFilesDir(), fileName); - - synchronized (syncFeatureObject) { - if (f.exists()) { - if (f.delete()) { - Log.i(TAG, "File " + f.getName() + " deleted"); - } else { - Log.i(TAG, "Could not delete file " + f.getName() + " (maybe it doesn't exist)"); - } - } - - if (f.createNewFile()) { - FileOutputStream fos = new FileOutputStream(f); - ObjectOutputStream oos = new ObjectOutputStream(fos); - oos.writeObject(o); - oos.close(); - } - } - } - - /** - * - * @param context The context of the application. Needed to access the internal file directory. - * @param fileName The name of the file where the object was saved before. - * @return The object that was read from the file. - * @throws IOException - * @throws ClassNotFoundException - */ - public static Object readObjectFromInternalFile(Context context, String fileName) - throws IOException, ClassNotFoundException { - File f = new File(context.getFilesDir(), fileName); - - synchronized (syncFeatureObject) { - if (!f.exists()) { - throw new FileNotFoundException("File " + fileName + " doesn't exist"); - } - - ObjectInputStream ois = new ObjectInputStream(new FileInputStream(f)); - Object o = ois.readObject(); - ois.close(); - return o; - } - } - - public static BufferedWriter createMeasurementFile(String filePath, String header) { - return createMeasurementFile(filePath, header, false); - } - - /** - * Creates a file where we can write the measurements. - * - * @param filePath - * @param header - * @return A BuuferedWriter that we should not forget to close when we're done. - */ - public static BufferedWriter createMeasurementFile(String filePath, String header, - boolean appending) { - File dseTestFile = new File(filePath); - BufferedWriter dseTestFileBuf = null; - try { - dseTestFileBuf = new BufferedWriter(new FileWriter(dseTestFile, appending)); - if (!appending) { - dseTestFileBuf.write(header); - } - } catch (IOException e1) { - Log.w(TAG, "Could not create file " + filePath + ": " + e1); - } - - return dseTestFileBuf; - } -} diff --git a/AccelerationClient/src/eu/project/rapid/ac/utils/ZipHandler.java b/AccelerationClient/src/eu/project/rapid/ac/utils/ZipHandler.java deleted file mode 100644 index 7fbc1fa..0000000 --- a/AccelerationClient/src/eu/project/rapid/ac/utils/ZipHandler.java +++ /dev/null @@ -1,200 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.ac.utils; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Enumeration; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; -import java.util.zip.ZipFile; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; - -import android.util.Log; - -/** - * Utility class used to handle zip folders. - */ -public class ZipHandler { - - static public void zipFolder(String srcFolder, String destZipFile, int start, int end) - throws Exception { - FileOutputStream fileWriter = new FileOutputStream(destZipFile); - ZipOutputStream zip = new ZipOutputStream(fileWriter); - - addFolderToZip("", srcFolder, zip, start, end); - zip.flush(); - zip.close(); - } - - static public byte[] zipFolder(ByteArrayOutputStream baos, String srcFolder, int start, int end) - throws Exception { - // ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ZipOutputStream zip = new ZipOutputStream(baos); - - addFolderToZip("", srcFolder, zip, start, end); - zip.flush(); - zip.close(); - - return baos.toByteArray(); - } - - static private void addFileToZip(String path, String srcFile, ZipOutputStream zip) - throws Exception { - - File folder = new File(srcFile); - if (folder.isDirectory()) { - addFolderToZip(path, srcFile, zip, -1, -1); - } else { - byte[] buf = new byte[1024]; - int len; - FileInputStream in = new FileInputStream(srcFile); - zip.putNextEntry(new ZipEntry(path + "/" + folder.getName())); - while ((len = in.read(buf)) > 0) { - zip.write(buf, 0, len); - } - in.close(); - } - } - - static private void addFolderToZip(String path, String srcFolder, ZipOutputStream zip, int start, - int end) throws Exception { - File folder = new File(srcFolder); - - System.out.println("Start: " + start + ", End: " + end); - - for (String fileName : folder.list()) { - - if (Integer.parseInt(fileName) < start || Integer.parseInt(fileName) > end) - continue; - - if (path.equals("")) { - addFileToZip(folder.getName(), srcFolder + "/" + fileName, zip); - } else { - addFileToZip(path + "/" + folder.getName(), srcFolder + "/" + fileName, zip); - } - } - } - - static public String extractBytes(byte[] zipBytes) { - - Log.i("ZipHandler", "Extracting files in: " + Constants.MNT_SDCARD); - - String destParent = null; - try { - ZipInputStream zipStream = new ZipInputStream(new ByteArrayInputStream(zipBytes)); - - ZipEntry entry = null; - while ((entry = zipStream.getNextEntry()) != null) { - String currentEntry = Constants.MNT_SDCARD + entry.getName(); - File destFile = new File(currentEntry); - destParent = destFile.getParent(); - - new File(destParent).mkdirs(); - Log.i("ZipHandler", "Creating file: " + currentEntry); - FileOutputStream out = new FileOutputStream(currentEntry); - byte[] buf = new byte[4096]; - int bytesRead = 0; - while ((bytesRead = zipStream.read(buf)) != -1) { - out.write(buf, 0, bytesRead); - } - out.close(); - zipStream.closeEntry(); - } - - // TODO: this should work only if there are not subfolders - return destParent; - - } catch (ZipException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return null; - } - - static public void extractFolder(String zipFile) throws ZipException, IOException { - System.out.println(zipFile); - - ZipFile zip = new ZipFile(new File(zipFile)); - String newPath = zipFile.substring(0, zipFile.length() - ".zip".length()); - - new File(newPath).mkdir(); - Enumeration zipFileEntries = zip.entries(); - - // Process each entry - while (zipFileEntries.hasMoreElements()) { - // grab a zip file entry - ZipEntry entry = (ZipEntry) zipFileEntries.nextElement(); - String currentEntry = entry.getName(); - - File destFile = new File(newPath, currentEntry.substring(currentEntry.indexOf("/") + 1)); - File destinationParent = destFile.getParentFile(); - - // create the parent directory structure if needed - destinationParent.mkdirs(); - - if (!entry.isDirectory()) { - extractZipEntry(zip, entry, destFile); - } - - if (currentEntry.endsWith(".zip")) { - // found a zip file, try to open - extractFolder(destFile.getAbsolutePath()); - } - } - } - - static void extractZipEntry(ZipFile zip, ZipEntry entry, File destFile) { - - // System.out.println("Extracting: " + destFile.getAbsolutePath()); - - int BUFFER = 2048; - BufferedInputStream is; - try { - is = new BufferedInputStream(zip.getInputStream(entry)); - int currentByte; - // establish buffer for writing file - byte data[] = new byte[BUFFER]; - - // write the current file to disk - FileOutputStream fos = new FileOutputStream(destFile); - BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER); - - // read and write until last byte is encountered - while ((currentByte = is.read(data, 0, BUFFER)) != -1) { - dest.write(data, 0, currentByte); - } - dest.flush(); - dest.close(); - is.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/AccelerationClient/src/eu/project/rapid/gvirtusfe/Buffer.java b/AccelerationClient/src/eu/project/rapid/gvirtusfe/Buffer.java deleted file mode 100755 index ed59eb6..0000000 --- a/AccelerationClient/src/eu/project/rapid/gvirtusfe/Buffer.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. To change this - * template file, choose Tools | Templates and open the template in the editor. - */ -package eu.project.rapid.gvirtusfe; - -import eu.project.rapid.ac.utils.Utils; - -/** - * - * @author cferraro - */ -public class Buffer { - - String mpBuffer; - int mLenght; - int mBackOffset; - int mOffset; - - public Buffer() { - mpBuffer = ""; - mLenght = 0; - mBackOffset = 0; - mOffset = 0; - } - - - - public void AddPointerNull() { - byte[] bites = {(byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0}; - // Sokol: DatatypeConverter does not exist in Android. - // mpBuffer += javax.xml.bind.DatatypeConverter.printHexBinary(bites); - mpBuffer += Utils.bytesToHex(bites); - mLenght += Long.SIZE / 8; - mBackOffset = mLenght; - } - - public void Add(int item) { - byte[] bites = - {(byte) item, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0}; - mpBuffer += Utils.bytesToHex(bites); - mLenght += Integer.SIZE / 8; - mBackOffset = mLenght; - } - - public void Add(long item) { - byte[] bites = - {(byte) item, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0}; - mpBuffer += Utils.bytesToHex(bites); - mLenght += Long.SIZE / 8; - mBackOffset = mLenght; - } - - public void Add(String item) { - // Sokol - // byte[] bites = DatatypeConverter.parseHexBinary(item); - byte[] bites = Utils.hexToBytes(item); - mpBuffer += Utils.bytesToHex(bites); - mLenght += bites.length; - mBackOffset = mLenght; - } - - public void Add(float[] item) { - // byte bites[] = new byte[item.length*4]; - for (int i = 0; i < item.length; i++) { - String s = String.format("%8s", Integer.toHexString(Float.floatToRawIntBits(item[i]))) - .replace(' ', '0'); - StringBuilder out2 = new StringBuilder(); - String ss = ""; - for (int j = s.length() - 1; j > 0; j -= 2) { - String str = s.substring(j - 1, j + 1); - out2.append(str); - ss = out2.toString(); - } - mpBuffer += ss; - } - // mpBuffer+=Utils.bytesToHex(bites); - mLenght += Long.SIZE / 8 * item.length; - mBackOffset = mLenght; - } - - public void Add(int[] item) { - // byte bites[] = new byte[item.length*4]; - Add(item.length * 4); - - - for (int i = 0; i < item.length; i++) { - AddInt(item[i]); - } - mLenght += Integer.SIZE / 8 * item.length; - mBackOffset = mLenght; - } - - public void AddInt(int item) { - byte[] bites = {(byte) item, (byte) 0, (byte) 0, (byte) 0}; - mpBuffer += Utils.bytesToHex(bites); - mLenght += Integer.SIZE / 8; - mBackOffset = mLenght; - } - - public void AddPointer(int item) { - byte[] bites = {(byte) item, (byte) 0, (byte) 0, (byte) 0}; - int size = (Integer.SIZE / 8); - this.Add(size); - mpBuffer += Utils.bytesToHex(bites); - mLenght += size; - mBackOffset = mLenght; - } - - public String GetString() { - return mpBuffer; - } - - public long Size() { - return mpBuffer.length(); - } - - void AddStruct(CudaRt_device.cudaDeviceProp struct) { - byte[] bites = new byte[640]; - bites[0] = (byte) 0x78; - bites[1] = (byte) 0x02; - for (int i = 2; i < 640; i++) { - bites[i] = (byte) 0; - - } - mpBuffer += Utils.bytesToHex(bites); - mLenght += bites.length; - mBackOffset = mLenght; - - - } - - void AddByte(int i) { - byte[] bites = new byte[1]; - bites[0] = (byte) i; - mpBuffer += Utils.bytesToHex(bites); - mLenght += bites.length; - mBackOffset = mLenght; - } - -} diff --git a/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_context.java b/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_context.java deleted file mode 100644 index 5f7893a..0000000 --- a/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_context.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. To change this - * template file, choose Tools | Templates and open the template in the editor. - */ -package eu.project.rapid.gvirtusfe; - -import java.io.IOException; - -import eu.project.rapid.ac.utils.Utils; - -/** - * - * @author cferraro - */ -public class CudaDr_context { - - public CudaDr_context() {} - - public String cuCtxCreate(Frontend fe, Result res, int flags, int dev) throws IOException { - - Buffer b = new Buffer(); - b.AddInt(flags); - b.AddInt(dev); - String outbuffer = ""; - fe.Execute("cuCtxCreate", b, res); - return getHex(res, 8); - } - - public int cuCtxDestroy(Frontend fe, Result res, String ctx) throws IOException { - - Buffer b = new Buffer(); - b.Add(ctx); - fe.Execute("cuCtxDestroy", b, res); - return 0; - } - - - - private String getHex(Result res, int size) throws IOException { - - byte[] array = new byte[size]; - for (int i = 0; i < size; i++) { - byte bit = res.getInput_stream().readByte(); - array[i] = bit; - } - // Sokol - // String hex = DatatypeConverter.printHexBinary(array); - String hex = Utils.bytesToHex(array); - return hex; - } - -} diff --git a/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_device.java b/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_device.java deleted file mode 100644 index 5cb97bb..0000000 --- a/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_device.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. To change this - * template file, choose Tools | Templates and open the template in the editor. - */ -package eu.project.rapid.gvirtusfe; - -import java.io.IOException; - -/** - * - * @author cferraro - */ -public class CudaDr_device { - - public CudaDr_device() {} - - public int cuDeviceGet(Frontend fe, Result res, int devID) throws IOException { - - Buffer b = new Buffer(); - b.AddPointer(0); - b.AddInt(devID); - String outputbuffer = ""; - StringBuilder output = new StringBuilder(); - fe.Execute("cuDeviceGet", b, res); - int sizeType = res.getInput_stream().readByte(); - for (int i = 0; i < 7; i++) - res.getInput_stream().readByte(); - for (int i = 0; i < sizeType; i++) { - if (i == 0 || i == 1) { - byte bb = res.getInput_stream().readByte(); - outputbuffer += Integer.toHexString(bb & 0xFF); - } else - res.getInput_stream().readByte(); - } - StringBuilder out2 = new StringBuilder(); - if (outputbuffer.length() > 2) { - for (int i = 0; i < outputbuffer.length() - 1; i += 2) { - String str = outputbuffer.substring(i, i + 2); - out2.insert(0, str); - } - outputbuffer = String.valueOf(Integer.parseInt(out2.toString(), 16)); - } - return Integer.valueOf(outputbuffer); - - } - - - public String cuDeviceGetName(Frontend fe, Result res, int len, int dev) throws IOException { - - Buffer b = new Buffer(); - b.AddByte(1); - for (int i = 0; i < 8; i++) - b.AddByte(0); - b.AddByte(1); - for (int i = 0; i < 7; i++) - b.AddByte(0); - b.AddInt(len); - b.AddInt(dev); - - - String outbuffer = ""; - StringBuilder output = new StringBuilder(); - fe.Execute("cuDeviceGetName", b, res); - int sizeType = res.getInput_stream().readByte(); - - for (int i = 0; i < 7; i++) - res.getInput_stream().readByte(); - res.getInput_stream().readByte(); - - for (int i = 0; i < 7; i++) - res.getInput_stream().readByte(); - - - for (int i = 0; i < sizeType; i++) { - byte bit = res.getInput_stream().readByte(); - outbuffer += Integer.toHexString(bit); - } - for (int i = 0; i < outbuffer.length() - 1; i += 2) { - String str = outbuffer.substring(i, i + 2); - output.append((char) Integer.parseInt(str, 16)); - - } - return output.toString(); - - } - - - public int cuDeviceGetCount(Frontend fe, Result res) throws IOException { - - Buffer b = new Buffer(); - b.AddPointer(0); - String outputbuffer = ""; - fe.Execute("cuDeviceGetCount", b, res); - int sizeType = res.getInput_stream().readByte(); - for (int i = 0; i < 7; i++) - res.getInput_stream().readByte(); - for (int i = 0; i < sizeType; i++) { - if (i == 0) { - byte bb = res.getInput_stream().readByte(); - outputbuffer += Integer.toHexString(bb & 0xFF); - } else - res.getInput_stream().readByte(); - } - StringBuilder out2 = new StringBuilder(); - if (outputbuffer.length() > 2) { - for (int i = 0; i < outputbuffer.length() - 1; i += 2) { - String str = outputbuffer.substring(i, i + 2); - out2.insert(0, str); - } - outputbuffer = String.valueOf(Integer.parseInt(out2.toString(), 16)); - } - - return Integer.valueOf(outputbuffer); - - } - - public int[] cuDeviceComputeCapability(Frontend fe, Result res, int device) throws IOException { - - Buffer b = new Buffer(); - b.AddPointer(0); - b.AddPointer(0); - b.AddInt(device); - String outputbuffer = ""; - fe.Execute("cuDeviceComputeCapability", b, res); - int sizeType = res.getInput_stream().readByte(); - for (int i = 0; i < 7; i++) - res.getInput_stream().readByte(); - for (int i = 0; i < sizeType; i++) { - if (i == 0) { - byte bb = res.getInput_stream().readByte(); - outputbuffer += Integer.toHexString(bb & 0xFF); - } else - res.getInput_stream().readByte(); - } - StringBuilder out2 = new StringBuilder(); - if (outputbuffer.length() > 2) { - for (int i = 0; i < outputbuffer.length() - 1; i += 2) { - String str = outputbuffer.substring(i, i + 2); - out2.insert(0, str); - } - outputbuffer = String.valueOf(Integer.parseInt(out2.toString(), 16)); - } - - int[] majorminor = new int[2]; - - majorminor[0] = Integer.valueOf(outputbuffer); - outputbuffer = ""; - sizeType = res.getInput_stream().readByte(); - for (int i = 0; i < 7; i++) - res.getInput_stream().readByte(); - for (int i = 0; i < sizeType; i++) { - if (i == 0) { - byte bb = res.getInput_stream().readByte(); - outputbuffer += Integer.toHexString(bb & 0xFF); - } else - res.getInput_stream().readByte(); - } - StringBuilder out3 = new StringBuilder(); - if (outputbuffer.length() > 2) { - for (int i = 0; i < outputbuffer.length() - 1; i += 2) { - String str = outputbuffer.substring(i, i + 2); - out3.insert(0, str); - } - outputbuffer = String.valueOf(Integer.parseInt(out3.toString(), 16)); - } - majorminor[1] = Integer.valueOf(outputbuffer); - return majorminor; - - } - - public int cuDeviceGetAttribute(Frontend fe, Result res, int attribute, int device) - throws IOException { - Buffer b = new Buffer(); - b.AddPointer(0); - b.AddInt(attribute); - b.AddInt(device); - String outputbuffer = ""; - fe.Execute("cuDeviceGetAttribute", b, res); - int sizeType = res.getInput_stream().readByte(); - for (int i = 0; i < 7; i++) - res.getInput_stream().readByte(); - for (int i = 0; i < sizeType; i++) { - if (i == 0) { - byte bb = res.getInput_stream().readByte(); - outputbuffer += Integer.toHexString(bb & 0xFF); - } else - res.getInput_stream().readByte(); - } - StringBuilder out2 = new StringBuilder(); - if (outputbuffer.length() > 2) { - for (int i = 0; i < outputbuffer.length() - 1; i += 2) { - String str = outputbuffer.substring(i, i + 2); - out2.insert(0, str); - } - outputbuffer = String.valueOf(Integer.parseInt(out2.toString(), 16)); - } - - return Integer.valueOf(outputbuffer); - - } - - public long cuDeviceTotalMem(Frontend fe, Result res, int dev) throws IOException { - - Buffer b = new Buffer(); - b.AddByte(8); - for (int i = 0; i < 16; i++) - b.AddByte(0); - b.AddInt(dev); - fe.Execute("cuDeviceTotalMem", b, res); - for (int i = 0; i < 8; i++) - res.getInput_stream().readByte(); - long x = getLong(res); - return x; - - } - - private long getLong(Result res) throws IOException { - - StringBuilder output = new StringBuilder(); - for (int i = 0; i < 8; i++) { - byte bit = res.getInput_stream().readByte(); - int a = bit & 0xFF; - if (a == 0) { - output.insert(0, Integer.toHexString(a)); - output.insert(0, Integer.toHexString(a)); - } else { - output.insert(0, Integer.toHexString(a)); - } - } - return Long.parseLong(output.toString(), 16); - } -} diff --git a/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_execution.java b/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_execution.java deleted file mode 100644 index c2b7b84..0000000 --- a/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_execution.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. To change this - * template file, choose Tools | Templates and open the template in the editor. - */ -package eu.project.rapid.gvirtusfe; - -import java.io.IOException; - -/** - * - * @author cferraro - */ -public class CudaDr_execution { - - public CudaDr_execution() {} - - public void cuParamSetv(Frontend fe, Result res, String hfunc, int offset, String ptr, - int numbytes) throws IOException { - - Buffer b = new Buffer(); - b.AddInt(offset); - b.AddInt(numbytes); - long sizeofp = 8; - b.Add(sizeofp); - b.Add(ptr); - b.Add(hfunc); - fe.Execute("cuParamSetv", b, res); - - } - - public void cuParamSeti(Frontend FE, Result res, String hfunc, int offset, int value) - throws IOException { - - Buffer b = new Buffer(); - b.AddInt(offset); - b.AddInt(value); - b.Add(hfunc); - FE.Execute("cuParamSeti", b, res); - } - - public void cuParamSetSize(Frontend FE, Result res, String hfunc, int numbytes) - throws IOException { - - Buffer b = new Buffer(); - b.AddInt(numbytes); - b.Add(hfunc); - FE.Execute("cuParamSetSize", b, res); - } - - public void cuFuncSetBlockShape(Frontend FE, Result res, String hfunc, int x, int y, int z) - throws IOException { - - Buffer b = new Buffer(); - b.AddInt(x); - b.AddInt(y); - b.AddInt(z); - b.Add(hfunc); - FE.Execute("cuFuncSetBlockShape", b, res); - } - - public void cuFuncSetSharedSize(Frontend FE, Result res, String hfunc, int bytes) - throws IOException { - - Buffer b = new Buffer(); - byte[] bits = this.intToByteArray(bytes); - for (int i = 0; i < bits.length; i++) { - b.AddByte(bits[i] & 0xFF); - } - b.Add(hfunc); - FE.Execute("cuFuncSetSharedSize", b, res); - } - - public void cuLaunchGrid(Frontend FE, Result res, String hfunc, int grid_width, int grid_height) - throws IOException { - - Buffer b = new Buffer(); - b.AddInt(grid_width); - b.AddInt(grid_height); - b.Add(hfunc); - FE.Execute("cuLaunchGrid", b, res); - } - - public byte[] intToByteArray(int value) { - return new byte[] {(byte) value, (byte) (value >> 8), (byte) (value >> 16), - (byte) (value >> 24)}; - } -} diff --git a/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_initialization.java b/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_initialization.java deleted file mode 100644 index e4e3bab..0000000 --- a/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_initialization.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. To change this - * template file, choose Tools | Templates and open the template in the editor. - */ -package eu.project.rapid.gvirtusfe; - -import java.io.IOException; - -/** - * - * @author cferraro - */ -public class CudaDr_initialization { - - public CudaDr_initialization() {} - - public int cuInit(Frontend fe, Result res, int flags) throws IOException { - Buffer b = new Buffer(); - b.AddInt(flags); - fe.Execute("cuInit", b, res); - return 0; - } - - -} diff --git a/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_memory.java b/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_memory.java deleted file mode 100644 index d1e8ac9..0000000 --- a/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_memory.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. To change this - * template file, choose Tools | Templates and open the template in the editor. - */ -package eu.project.rapid.gvirtusfe; - -import java.io.IOException; - -import eu.project.rapid.ac.utils.Utils; - -/** - * - * @author cferraro - */ -public class CudaDr_memory { - - public CudaDr_memory() {} - - public String cuMemAlloc(Frontend fe, Result res, long size) throws IOException { - - Buffer b = new Buffer(); - byte[] bits = this.longToByteArray(size); - for (int i = 0; i < bits.length; i++) { - b.AddByte(bits[i] & 0xFF); - } - String pointer = ""; - fe.Execute("cuMemAlloc", b, res); - pointer = getHex(res, 8); - return pointer; - } - - - private String getHex(Result res, int size) throws IOException { - - byte[] array = new byte[size]; - for (int i = 0; i < size; i++) { - byte bit = res.getInput_stream().readByte(); - array[i] = bit; - } - // String hex = DatatypeConverter.printHexBinary(array); - String hex = Utils.bytesToHex(array); - return hex; - } - - - public void cuMemcpyHtoD(Frontend fe, Result res, String dst, float[] src, int count) - throws IOException { - - Buffer b = new Buffer(); - byte[] bits = this.longToByteArray(count); - for (int i = 0; i < bits.length; i++) { - b.AddByte(bits[i] & 0xFF); - } - b.Add(dst); - for (int i = 0; i < bits.length; i++) { - b.AddByte(bits[i] & 0xFF); - } - b.Add(src); - fe.Execute("cuMemcpyHtoD", b, res); - - } - - - public float[] cuMemcpyDtoH(Frontend fe, Result res, String srcDevice, long ByteCount) - throws IOException { - - Buffer b = new Buffer(); - b.Add(srcDevice); - - byte[] bits = this.longToByteArray(ByteCount); - for (int i = 0; i < bits.length; i++) { - b.AddByte(bits[i] & 0xFF); - } - fe.Execute("cuMemcpyDtoH", b, res); - for (int i = 0; i <= 7; i++) { - byte bb = res.getInput_stream().readByte(); - } - int sizeType = 98304; - float[] result = new float[sizeType / 4]; - for (int i = 0; i < sizeType / 4; i++) { - result[i] = getFloat(res); - } - - return result; - - } - - public void cuMemFree(Frontend fe, Result res, String ptr) throws IOException { - Buffer b = new Buffer(); - b.Add(ptr); - fe.Execute("cuMemFree", b, res); - - } - - - private float getFloat(Result res) throws IOException { - - byte bytes[] = new byte[4]; - for (int i = 3; i >= 0; i--) { - bytes[i] = res.getInput_stream().readByte(); - } - // Sokol - // String output = javax.xml.bind.DatatypeConverter.printHexBinary(bytes); - String output = Utils.bytesToHex(bytes); - Long i = Long.parseLong(output, 16); - Float f = Float.intBitsToFloat(i.intValue()); - return f; - } - - public byte[] longToByteArray(long value) { - return new byte[] {(byte) value, (byte) (value >> 8), (byte) (value >> 16), - (byte) (value >> 24), (byte) (value >> 32), (byte) (value >> 40), (byte) (value >> 48), - (byte) (value >> 56) - - }; - } - - -} diff --git a/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_module.java b/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_module.java deleted file mode 100644 index c7910b3..0000000 --- a/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_module.java +++ /dev/null @@ -1,119 +0,0 @@ -package eu.project.rapid.gvirtusfe; - -import java.io.IOException; - -import eu.project.rapid.ac.utils.Utils; - - -/** - * - * @author cferraro - */ -public class CudaDr_module { - - public CudaDr_module() {} - - public String cuModuleGetFunction(Frontend FE, Result res, String cmodule, String str) - throws IOException { - - Buffer b = new Buffer(); - str = str + "\0"; - long size = str.length(); - byte[] bits = this.longToByteArray(size); - - for (int i = 0; i < bits.length; i++) { - b.AddByte(bits[i] & 0xFF); - } - for (int i = 0; i < bits.length; i++) { - b.AddByte(bits[i] & 0xFF); - } - for (int i = 0; i < size; i++) { - b.AddByte(str.charAt(i)); - } - - b.Add(cmodule); - - FE.Execute("cuModuleGetFunction", b, res); - String pointer = ""; - pointer = getHex(res, 8); - for (int i = 0; i < res.getSizebuffer() - 8; i++) { - res.getInput_stream().readByte(); - } - - return pointer; - - } - - public String cuModuleLoadDataEx(Frontend FE, Result res, String ptxSource, int jitNumOptions, - int[] jitOptions, long jitOptVals0, char[] jitOptVals1, long jitOptVals2) throws IOException { - Buffer b = new Buffer(); - b.AddInt(jitNumOptions); - b.Add(jitOptions); - // addStringForArgument - ptxSource = ptxSource + "\0"; - long sizePtxSource = ptxSource.length(); - long size = sizePtxSource; - byte[] bits = this.longToByteArray(size); - - for (int i = 0; i < bits.length; i++) { - b.AddByte(bits[i] & 0xFF); - } - for (int i = 0; i < bits.length; i++) { - b.AddByte(bits[i] & 0xFF); - } - for (int i = 0; i < sizePtxSource; i++) - b.AddByte(ptxSource.charAt(i)); - b.Add(8); - long OptVals0 = jitOptVals0; - byte[] bit = this.longToByteArray(OptVals0); - for (int i = 0; i < bit.length; i++) { - b.AddByte(bit[i] & 0xFF); - } - b.Add(8); - b.AddByte(160); - b.AddByte(159); - b.AddByte(236); - b.AddByte(1); - b.AddByte(0); - b.AddByte(0); - b.AddByte(0); - b.AddByte(0); - - b.Add(8); - long OptVals2 = jitOptVals2; - byte[] bit2 = this.longToByteArray(OptVals2); - for (int i = 0; i < bit.length; i++) { - b.AddByte(bit2[i] & 0xFF); - } - - FE.Execute("cuModuleLoadDataEx", b, res); - String pointer = ""; - pointer = getHex(res, 8); - for (int i = 0; i < res.getSizebuffer() - 8; i++) - res.getInput_stream().readByte(); - - return pointer; - } - - - private String getHex(Result res, int size) throws IOException { - - byte[] array = new byte[size]; - for (int i = 0; i < size; i++) { - byte bit = res.getInput_stream().readByte(); - array[i] = bit; - } - // Sokol - // String hex = DatatypeConverter.printHexBinary(array); - String hex = Utils.bytesToHex(array); - return hex; - } - - public byte[] longToByteArray(long value) { - return new byte[] {(byte) value, (byte) (value >> 8), (byte) (value >> 16), - (byte) (value >> 24), (byte) (value >> 32), (byte) (value >> 40), (byte) (value >> 48), - (byte) (value >> 56) - - }; - } -} diff --git a/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaRt_device.java b/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaRt_device.java deleted file mode 100755 index e626852..0000000 --- a/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaRt_device.java +++ /dev/null @@ -1,968 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. To change this - * template file, choose Tools | Templates and open the template in the editor. - */ -package eu.project.rapid.gvirtusfe; - -import java.io.IOException; - - -/** - * - * @author cferraro - */ -public class CudaRt_device { - - public CudaRt_device() {} - - public int cudaGetDeviceCount(Frontend fe, Result res) throws IOException { - - Buffer b = new Buffer(); - b.AddPointer(0); - String outputbuffer = ""; - fe.Execute("cudaGetDeviceCount", b, res); - // fe.ExecuteMultiThread("cudaGetDeviceCount",b,res); - int sizeType = res.getInput_stream().readByte(); - for (int i = 0; i < 7; i++) - res.getInput_stream().readByte(); - for (int i = 0; i < sizeType; i++) { - if (i == 0) { - byte bb = res.getInput_stream().readByte(); - outputbuffer += Integer.toHexString(bb & 0xFF); - } else - res.getInput_stream().readByte(); - } - StringBuilder out2 = new StringBuilder(); - if (outputbuffer.length() > 2) { - for (int i = 0; i < outputbuffer.length() - 1; i += 2) { - String str = outputbuffer.substring(i, i + 2); - out2.insert(0, str); - } - outputbuffer = String.valueOf(Integer.parseInt(out2.toString(), 16)); - } - - return Integer.valueOf(outputbuffer); - } - - public int cudaDeviceCanAccessPeer(Frontend fe, Result res, int device, int peers) - throws IOException { - Buffer b = new Buffer(); - b.AddPointer(0); - b.AddInt(device); - b.AddInt(peers); - String outputbuffer = ""; - fe.Execute("cudaDeviceCanAccessPeer", b, res); - // fe.ExecuteMultiThread("cudaDeviceCanAccessPeer",b,res); - int sizeType = res.getInput_stream().readByte(); - for (int i = 0; i < 7; i++) - res.getInput_stream().readByte(); - for (int i = 0; i < sizeType; i++) { - if (i == 0) { - byte bb = res.getInput_stream().readByte(); - outputbuffer += Integer.toHexString(bb & 0xFF); - } else - res.getInput_stream().readByte(); - } - StringBuilder out2 = new StringBuilder(); - if (outputbuffer.length() > 2) { - for (int i = 0; i < outputbuffer.length() - 1; i += 2) { - String str = outputbuffer.substring(i, i + 2); - out2.insert(0, str); - } - outputbuffer = String.valueOf(Integer.parseInt(out2.toString(), 16)); - } - return Integer.valueOf(outputbuffer); - } - - public int cudaDriverGetVersion(Frontend fe, Result res) throws IOException { - - - Buffer b = new Buffer(); - b.AddPointer(0); - String outputbuffer = ""; - fe.Execute("cudaDriverGetVersion", b, res); - // fe.ExecuteMultiThread("cudaDriverGetVersion",b,res); - int sizeType = res.getInput_stream().readByte(); - for (int i = 0; i < 7; i++) - res.getInput_stream().readByte(); - for (int i = 0; i < sizeType; i++) { - if (i == 0 || i == 1) { - byte bb = res.getInput_stream().readByte(); - outputbuffer += Integer.toHexString(bb & 0xFF); - } else - res.getInput_stream().readByte(); - } - - StringBuilder out2 = new StringBuilder(); - if (outputbuffer.length() > 2) { - for (int i = 0; i < outputbuffer.length() - 1; i += 2) { - String str = outputbuffer.substring(i, i + 2); - out2.insert(0, str); - } - outputbuffer = String.valueOf(Integer.parseInt(out2.toString(), 16)); - } - return Integer.valueOf(outputbuffer); - } - - public int cudaRuntimeGetVersion(Frontend fe, Result res) throws IOException { - - Buffer b = new Buffer(); - b.AddPointer(0); - String outputbuffer = ""; - fe.Execute("cudaRuntimeGetVersion", b, res); - // fe.ExecuteMultiThread("cudaRuntimeGetVersion",b,res); - int sizeType = res.getInput_stream().readByte(); - for (int i = 0; i < 7; i++) - res.getInput_stream().readByte(); - for (int i = 0; i < sizeType; i++) { - if (i == 0 || i == 1) { - byte bb = res.getInput_stream().readByte(); - outputbuffer += Integer.toHexString(bb & 0xFF); - } else - res.getInput_stream().readByte(); - } - StringBuilder out2 = new StringBuilder(); - if (outputbuffer.length() > 2) { - for (int i = 0; i < outputbuffer.length() - 1; i += 2) { - String str = outputbuffer.substring(i, i + 2); - out2.insert(0, str); - } - outputbuffer = String.valueOf(Integer.parseInt(out2.toString(), 16)); - } - return Integer.valueOf(outputbuffer); - } - - - public int cudaSetDevice(Frontend fe, int device, Result res) throws IOException { - - Buffer b = new Buffer(); - b.Add(device); - fe.Execute("cudaSetDevice", b, res); - // fe.ExecuteMultiThread("cudaSetDevice",b,res); - return 0; - } - - public String cudaGetErrorString(Frontend fe, int error, Result res) throws IOException { - - Buffer b = new Buffer(); - b.AddInt(error); - String outbuffer = ""; - StringBuilder output = new StringBuilder(); - fe.Execute("cudaGetErrorString", b, res); - int sizeType = res.getInput_stream().readByte(); - // System.out.print("sizeType " + sizeType); - - for (int i = 0; i < 7; i++) - res.getInput_stream().readByte(); - res.getInput_stream().readByte(); - // System.out.print("sizeType " + sizeType); - - for (int i = 0; i < 7; i++) - res.getInput_stream().readByte(); - - - for (int i = 0; i < sizeType; i++) { - byte bit = res.getInput_stream().readByte(); - outbuffer += Integer.toHexString(bit); - // System.out.print(outbuffer.toString()); - } - for (int i = 0; i < outbuffer.length() - 1; i += 2) { - String str = outbuffer.substring(i, i + 2); - output.append((char) Integer.parseInt(str, 16)); - - } - return output.toString(); - - } - - public void cudaDeviceReset(Frontend fe, Result res) throws IOException { - Buffer b = new Buffer(); - fe.Execute("cudaDeviceReset", b, res); - // fe.ExecuteMultiThread("cudaDeviceReset", b, res); - - } - - - private int getInt(Result res) throws IOException { - - StringBuilder output = new StringBuilder(); - for (int i = 0; i < 4; i++) { - byte bit = res.getInput_stream().readByte(); - int a = bit & 0xFF; - if (a == 0) { - output.insert(0, Integer.toHexString(a)); - output.insert(0, Integer.toHexString(a)); - } else { - output.insert(0, Integer.toHexString(a)); - } - } - return Integer.parseInt(output.toString(), 16); - - } - - private long getLong(Result res) throws IOException { - - StringBuilder output = new StringBuilder(); - for (int i = 0; i < 8; i++) { - byte bit = res.getInput_stream().readByte(); - int a = bit & 0xFF; - if (a == 0) { - output.insert(0, Integer.toHexString(a)); - output.insert(0, Integer.toHexString(a)); - } else { - output.insert(0, Integer.toHexString(a)); - } - } - return Long.parseLong(output.toString(), 16); - } - - public cudaDeviceProp cudaGetDeviceProperties(Frontend fe, Result res, int device) - throws IOException { - Buffer b = new Buffer(); - String outbuffer = ""; - StringBuilder output = new StringBuilder(); - cudaDeviceProp struct = new cudaDeviceProp(); - - b.AddStruct(struct); - b.AddInt(device); - fe.Execute("cudaGetDeviceProperties", b, res); - // fe.ExecuteMultiThread("cudaGetDeviceProperties", b,res); - int sizeType = 640; - for (int i = 0; i < 8; i++) { - res.getInput_stream().readByte(); - } // lettura size vettore buffer - // lettura nome device - for (int i = 0; i < 256; i++) { - byte bit = res.getInput_stream().readByte(); - - outbuffer += Integer.toHexString(bit); - } - for (int i = 0; i < outbuffer.length() - 1; i += 2) { - String str = outbuffer.substring(i, i + 2); - output.append((char) Integer.parseInt(str, 16)); - } - struct.name = output.toString().trim(); - struct.totalGlobalMem = this.getLong(res); - struct.sharedMemPerBlock = this.getLong(res); - struct.regsPerBlock = this.getInt(res); - struct.warpSize = this.getInt(res); - struct.memPitch = this.getLong(res); - struct.maxThreadsPerBlock = this.getInt(res); - struct.maxThreadsDim[0] = this.getInt(res); - struct.maxThreadsDim[1] = this.getInt(res); - struct.maxThreadsDim[2] = this.getInt(res); - struct.maxGridSize[0] = this.getInt(res); - struct.maxGridSize[1] = this.getInt(res); - struct.maxGridSize[2] = this.getInt(res); - struct.clockRate = this.getInt(res); // check - struct.totalConstMem = this.getLong(res); - struct.major = this.getInt(res); - struct.minor = this.getInt(res); - struct.textureAlignment = this.getLong(res); - struct.texturePitchAlignment = this.getLong(res); // check - struct.deviceOverlap = this.getInt(res); - struct.multiProcessorCount = this.getInt(res); - struct.kernelExecTimeoutEnabled = this.getInt(res); - struct.integrated = this.getInt(res); - struct.canMapHostMemory = this.getInt(res); - struct.computeMode = this.getInt(res); - struct.maxTexture1D = this.getInt(res); - struct.maxTexture1DMipmap = this.getInt(res); - struct.maxTexture1DLinear = this.getInt(res); // check - struct.maxTexture2D[0] = this.getInt(res); - struct.maxTexture2D[1] = this.getInt(res); - struct.maxTexture2DMipmap[0] = this.getInt(res); - struct.maxTexture2DMipmap[1] = this.getInt(res); - struct.maxTexture2DLinear[0] = this.getInt(res); - struct.maxTexture2DLinear[1] = this.getInt(res); - struct.maxTexture2DLinear[2] = this.getInt(res); - struct.maxTexture2DGather[0] = this.getInt(res); - struct.maxTexture2DGather[1] = this.getInt(res); - struct.maxTexture3D[0] = this.getInt(res); - struct.maxTexture3D[1] = this.getInt(res); - struct.maxTexture3D[2] = this.getInt(res); - struct.maxTexture3DAlt[0] = this.getInt(res); - struct.maxTexture3DAlt[1] = this.getInt(res); - struct.maxTexture3DAlt[2] = this.getInt(res); - struct.maxTextureCubemap = this.getInt(res); - struct.maxTexture1DLayered[0] = this.getInt(res); - struct.maxTexture1DLayered[1] = this.getInt(res); - struct.maxTexture2DLayered[0] = this.getInt(res); - struct.maxTexture2DLayered[1] = this.getInt(res); - struct.maxTexture2DLayered[2] = this.getInt(res); - struct.maxTextureCubemapLayered[0] = this.getInt(res); - struct.maxTextureCubemapLayered[1] = this.getInt(res); - struct.maxSurface1D = this.getInt(res); - struct.maxSurface2D[0] = this.getInt(res); - struct.maxSurface2D[1] = this.getInt(res); - struct.maxSurface3D[0] = this.getInt(res); - struct.maxSurface3D[1] = this.getInt(res); - struct.maxSurface3D[2] = this.getInt(res); - struct.maxSurface1DLayered[0] = this.getInt(res); - struct.maxSurface1DLayered[1] = this.getInt(res); - struct.maxSurface2DLayered[0] = this.getInt(res); - struct.maxSurface2DLayered[1] = this.getInt(res); - struct.maxSurface2DLayered[2] = this.getInt(res); - struct.maxSurfaceCubemap = this.getInt(res); - struct.maxSurfaceCubemapLayered[0] = this.getInt(res); - struct.maxSurfaceCubemapLayered[1] = this.getInt(res); - struct.surfaceAlignment = this.getLong(res); - struct.concurrentKernels = this.getInt(res); - struct.ECCEnabled = this.getInt(res); - struct.pciBusID = this.getInt(res); - struct.pciDeviceID = this.getInt(res); - struct.pciDomainID = this.getInt(res); - struct.tccDriver = this.getInt(res); - struct.asyncEngineCount = this.getInt(res); - struct.unifiedAddressing = this.getInt(res); - struct.memoryClockRate = this.getInt(res); - struct.memoryBusWidth = this.getInt(res); - struct.l2CacheSize = this.getInt(res); - struct.maxThreadsPerMultiProcessor = this.getInt(res); - struct.streamPrioritiesSupported = this.getInt(res); - struct.globalL1CacheSupported = this.getInt(res); - struct.localL1CacheSupported = this.getInt(res); - struct.sharedMemPerMultiprocessor = this.getLong(res); - struct.regsPerMultiprocessor = this.getInt(res); - struct.managedMemory = this.getInt(res); - struct.isMultiGpuBoard = this.getInt(res); - struct.multiGpuBoardGroupID = this.getInt(res); - this.getInt(res); // è in più da capire il perchè - return struct; - } - - public class cudaDeviceProp { - - String name; - long totalGlobalMem = 0; - /** < Global memory available on device in bytes */ - long sharedMemPerBlock = 0; - /** < Shared memory available per block in bytes */ - int regsPerBlock = 0; - /** < 32-bit registers available per block */ - int warpSize = 0; - /** < Warp size in threads */ - long memPitch = 0; - /** < Maximum pitch in bytes allowed by memory copies */ - int maxThreadsPerBlock = 0; - /** < Maximum number of threads per block */ - int[] maxThreadsDim = new int[3]; - /** < Maximum size of each dimension of a block */ - int[] maxGridSize = new int[3]; - /** < Maximum size of each dimension of a grid */ - int clockRate = 0; - /** < Clock frequency in kilohertz */ - long totalConstMem = 0; - /** < Constant memory available on device in bytes */ - int major = 0; - /** < Major compute capability */ - int minor = 0; - /** < Minor compute capability */ - long textureAlignment = 0; - /** < Alignment requirement for textures */ - long texturePitchAlignment = 0; - /** < Pitch alignment requirement for texture references bound to pitched memory */ - int deviceOverlap = 0; - /** - * < Device can concurrently copy memory and execute a kernel. Deprecated. Use instead - * asyncEngineCount. - */ - int multiProcessorCount = 0; - /** < Number of multiprocessors on device */ - int kernelExecTimeoutEnabled = 0; - /** < Specified whether there is a run time limit on kernels */ - int integrated = 0; - /** < Device is integrated as opposed to discrete */ - int canMapHostMemory = 0; - /** < Device can map host memory with cudaHostAlloc/cudaHostGetDevicePointer */ - int computeMode = 0; - /** < Compute mode (See ::cudaComputeMode) */ - int maxTexture1D = 0; - /** < Maximum 1D texture size */ - int maxTexture1DMipmap = 0; - /** < Maximum 1D mipmapped texture size */ - int maxTexture1DLinear = 0; - /** < Maximum size for 1D textures bound to linear memory */ - int[] maxTexture2D = new int[2]; - /** < Maximum 2D texture dimensions */ - int[] maxTexture2DMipmap = new int[2]; - /** < Maximum 2D mipmapped texture dimensions */ - int[] maxTexture2DLinear = new int[3]; - /** < Maximum dimensions (width, height, pitch) for 2D textures bound to pitched memory */ - int[] maxTexture2DGather = new int[2]; - /** < Maximum 2D texture dimensions if texture gather operations have to be performed */ - int[] maxTexture3D = new int[3]; - /** < Maximum 3D texture dimensions */ - int[] maxTexture3DAlt = new int[3]; - /** < Maximum alternate 3D texture dimensions */ - int maxTextureCubemap = 0; - /** < Maximum Cubemap texture dimensions */ - int[] maxTexture1DLayered = new int[2]; - /** < Maximum 1D layered texture dimensions */ - int[] maxTexture2DLayered = new int[3]; - /** < Maximum 2D layered texture dimensions */ - int[] maxTextureCubemapLayered = new int[2]; - /** < Maximum Cubemap layered texture dimensions */ - int maxSurface1D = 0; - /** < Maximum 1D surface size */ - int[] maxSurface2D = new int[2]; - /** < Maximum 2D surface dimensions */ - int[] maxSurface3D = new int[3]; - /** < Maximum 3D surface dimensions */ - int[] maxSurface1DLayered = new int[2]; - /** < Maximum 1D layered surface dimensions */ - int[] maxSurface2DLayered = new int[3]; - /** < Maximum 2D layered surface dimensions */ - int maxSurfaceCubemap = 0; - /** < Maximum Cubemap surface dimensions */ - int[] maxSurfaceCubemapLayered = new int[2]; - /** < Maximum Cubemap layered surface dimensions */ - long surfaceAlignment = 0; - /** < Alignment requirements for surfaces */ - int concurrentKernels = 0; - /** < Device can possibly execute multiple kernels concurrently */ - int ECCEnabled = 0; - /** < Device has ECC support enabled */ - int pciBusID = 0; - /** < PCI bus ID of the device */ - int pciDeviceID = 0; - /** < PCI device ID of the device */ - int pciDomainID = 0; - /** < PCI domain ID of the device */ - int tccDriver = 0; - /** < 1 if device is a Tesla device using TCC driver, 0 otherwise */ - int asyncEngineCount = 0; - /** < Number of asynchronous engines */ - int unifiedAddressing = 0; - /** < Device shares a unified address space with the host */ - int memoryClockRate = 0; - /** < Peak memory clock frequency in kilohertz */ - int memoryBusWidth = 0; - /** < Global memory bus width in bits */ - int l2CacheSize = 0; - /** < Size of L2 cache in bytes */ - int maxThreadsPerMultiProcessor = 0; - /** < Maximum resident threads per multiprocessor */ - int streamPrioritiesSupported = 0; - /** < Device supports stream priorities */ - int globalL1CacheSupported = 0; - /** < Device supports caching globals in L1 */ - int localL1CacheSupported = 0; - /** < Device supports caching locals in L1 */ - long sharedMemPerMultiprocessor = 0; - /** < Shared memory available per multiprocessor in bytes */ - int regsPerMultiprocessor = 0; - /** < 32-bit registers available per multiprocessor */ - int managedMemory = 0; - /** < Device supports allocating managed memory on this system */ - int isMultiGpuBoard = 0; - /** < Device is on a multi-GPU board */ - int multiGpuBoardGroupID = 0; - - /** < Unique identifier for a group of devices on the same multi-GPU board */ - - public cudaDeviceProp() {} - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public long getTotalGlobalMem() { - return totalGlobalMem; - } - - public void setTotalGlobalMem(long totalGlobalMem) { - this.totalGlobalMem = totalGlobalMem; - } - - public long getSharedMemPerBlock() { - return sharedMemPerBlock; - } - - public void setSharedMemPerBlock(long sharedMemPerBlock) { - this.sharedMemPerBlock = sharedMemPerBlock; - } - - public int getRegsPerBlock() { - return regsPerBlock; - } - - public void setRegsPerBlock(int regsPerBlock) { - this.regsPerBlock = regsPerBlock; - } - - public int getWarpSize() { - return warpSize; - } - - public void setWarpSize(int warpSize) { - this.warpSize = warpSize; - } - - public long getMemPitch() { - return memPitch; - } - - public void setMemPitch(long memPitch) { - this.memPitch = memPitch; - } - - public int getMaxThreadsPerBlock() { - return maxThreadsPerBlock; - } - - public void setMaxThreadsPerBlock(int maxThreadsPerBlock) { - this.maxThreadsPerBlock = maxThreadsPerBlock; - } - - public int[] getMaxThreadsDim() { - return maxThreadsDim; - } - - public void setMaxThreadsDim(int[] maxThreadsDim) { - this.maxThreadsDim = maxThreadsDim; - } - - public int[] getMaxGridSize() { - return maxGridSize; - } - - public void setMaxGridSize(int[] maxGridSize) { - this.maxGridSize = maxGridSize; - } - - public int getClockRate() { - return clockRate; - } - - public void setClockRate(int clockRate) { - this.clockRate = clockRate; - } - - public long getTotalConstMem() { - return totalConstMem; - } - - public void setTotalConstMem(long totalConstMem) { - this.totalConstMem = totalConstMem; - } - - public int getMajor() { - return major; - } - - public void setMajor(int major) { - this.major = major; - } - - public int getMinor() { - return minor; - } - - public void setMinor(int minor) { - this.minor = minor; - } - - public long getTextureAlignment() { - return textureAlignment; - } - - public void setTextureAlignment(long textureAlignment) { - this.textureAlignment = textureAlignment; - } - - public long getTexturePitchAlignment() { - return texturePitchAlignment; - } - - public void setTexturePitchAlignment(long texturePitchAlignment) { - this.texturePitchAlignment = texturePitchAlignment; - } - - public int getDeviceOverlap() { - return deviceOverlap; - } - - public void setDeviceOverlap(int deviceOverlap) { - this.deviceOverlap = deviceOverlap; - } - - public int getMultiProcessorCount() { - return multiProcessorCount; - } - - public void setMultiProcessorCount(int multiProcessorCount) { - this.multiProcessorCount = multiProcessorCount; - } - - public int getKernelExecTimeoutEnabled() { - return kernelExecTimeoutEnabled; - } - - public void setKernelExecTimeoutEnabled(int kernelExecTimeoutEnabled) { - this.kernelExecTimeoutEnabled = kernelExecTimeoutEnabled; - } - - public int getIntegrated() { - return integrated; - } - - public void setIntegrated(int integrated) { - this.integrated = integrated; - } - - public int getCanMapHostMemory() { - return canMapHostMemory; - } - - public void setCanMapHostMemory(int canMapHostMemory) { - this.canMapHostMemory = canMapHostMemory; - } - - public int getComputeMode() { - return computeMode; - } - - public void setComputeMode(int computeMode) { - this.computeMode = computeMode; - } - - public int getMaxTexture1D() { - return maxTexture1D; - } - - public void setMaxTexture1D(int maxTexture1D) { - this.maxTexture1D = maxTexture1D; - } - - public int getMaxTexture1DMipmap() { - return maxTexture1DMipmap; - } - - public void setMaxTexture1DMipmap(int maxTexture1DMipmap) { - this.maxTexture1DMipmap = maxTexture1DMipmap; - } - - public int getMaxTexture1DLinear() { - return maxTexture1DLinear; - } - - public void setMaxTexture1DLinear(int maxTexture1DLinear) { - this.maxTexture1DLinear = maxTexture1DLinear; - } - - public int[] getMaxTexture2D() { - return maxTexture2D; - } - - public void setMaxTexture2D(int[] maxTexture2D) { - this.maxTexture2D = maxTexture2D; - } - - public int[] getMaxTexture2DMipmap() { - return maxTexture2DMipmap; - } - - public void setMaxTexture2DMipmap(int[] maxTexture2DMipmap) { - this.maxTexture2DMipmap = maxTexture2DMipmap; - } - - public int[] getMaxTexture2DLinear() { - return maxTexture2DLinear; - } - - public void setMaxTexture2DLinear(int[] maxTexture2DLinear) { - this.maxTexture2DLinear = maxTexture2DLinear; - } - - public int[] getMaxTexture2DGather() { - return maxTexture2DGather; - } - - public void setMaxTexture2DGather(int[] maxTexture2DGather) { - this.maxTexture2DGather = maxTexture2DGather; - } - - public int[] getMaxTexture3D() { - return maxTexture3D; - } - - public void setMaxTexture3D(int[] maxTexture3D) { - this.maxTexture3D = maxTexture3D; - } - - public int[] getMaxTexture3DAlt() { - return maxTexture3DAlt; - } - - public void setMaxTexture3DAlt(int[] maxTexture3DAlt) { - this.maxTexture3DAlt = maxTexture3DAlt; - } - - public int getMaxTextureCubemap() { - return maxTextureCubemap; - } - - public void setMaxTextureCubemap(int maxTextureCubemap) { - this.maxTextureCubemap = maxTextureCubemap; - } - - public int[] getMaxTexture1DLayered() { - return maxTexture1DLayered; - } - - public void setMaxTexture1DLayered(int[] maxTexture1DLayered) { - this.maxTexture1DLayered = maxTexture1DLayered; - } - - public int[] getMaxTexture2DLayered() { - return maxTexture2DLayered; - } - - public void setMaxTexture2DLayered(int[] maxTexture2DLayered) { - this.maxTexture2DLayered = maxTexture2DLayered; - } - - public int[] getMaxTextureCubemapLayered() { - return maxTextureCubemapLayered; - } - - public void setMaxTextureCubemapLayered(int[] maxTextureCubemapLayered) { - this.maxTextureCubemapLayered = maxTextureCubemapLayered; - } - - public int getMaxSurface1D() { - return maxSurface1D; - } - - public void setMaxSurface1D(int maxSurface1D) { - this.maxSurface1D = maxSurface1D; - } - - public int[] getMaxSurface2D() { - return maxSurface2D; - } - - public void setMaxSurface2D(int[] maxSurface2D) { - this.maxSurface2D = maxSurface2D; - } - - public int[] getMaxSurface3D() { - return maxSurface3D; - } - - public void setMaxSurface3D(int[] maxSurface3D) { - this.maxSurface3D = maxSurface3D; - } - - public int[] getMaxSurface1DLayered() { - return maxSurface1DLayered; - } - - public void setMaxSurface1DLayered(int[] maxSurface1DLayered) { - this.maxSurface1DLayered = maxSurface1DLayered; - } - - public int[] getMaxSurface2DLayered() { - return maxSurface2DLayered; - } - - public void setMaxSurface2DLayered(int[] maxSurface2DLayered) { - this.maxSurface2DLayered = maxSurface2DLayered; - } - - public int getMaxSurfaceCubemap() { - return maxSurfaceCubemap; - } - - public void setMaxSurfaceCubemap(int maxSurfaceCubemap) { - this.maxSurfaceCubemap = maxSurfaceCubemap; - } - - public int[] getMaxSurfaceCubemapLayered() { - return maxSurfaceCubemapLayered; - } - - public void setMaxSurfaceCubemapLayered(int[] maxSurfaceCubemapLayered) { - this.maxSurfaceCubemapLayered = maxSurfaceCubemapLayered; - } - - public long getSurfaceAlignment() { - return surfaceAlignment; - } - - public void setSurfaceAlignment(long surfaceAlignment) { - this.surfaceAlignment = surfaceAlignment; - } - - public int getConcurrentKernels() { - return concurrentKernels; - } - - public void setConcurrentKernels(int concurrentKernels) { - this.concurrentKernels = concurrentKernels; - } - - public int getECCEnabled() { - return ECCEnabled; - } - - public void setECCEnabled(int ECCEnabled) { - this.ECCEnabled = ECCEnabled; - } - - public int getPciBusID() { - return pciBusID; - } - - public void setPciBusID(int pciBusID) { - this.pciBusID = pciBusID; - } - - public int getPciDeviceID() { - return pciDeviceID; - } - - public void setPciDeviceID(int pciDeviceID) { - this.pciDeviceID = pciDeviceID; - } - - public int getPciDomainID() { - return pciDomainID; - } - - public void setPciDomainID(int pciDomainID) { - this.pciDomainID = pciDomainID; - } - - public int getTccDriver() { - return tccDriver; - } - - public void setTccDriver(int tccDriver) { - this.tccDriver = tccDriver; - } - - public int getAsyncEngineCount() { - return asyncEngineCount; - } - - public void setAsyncEngineCount(int asyncEngineCount) { - this.asyncEngineCount = asyncEngineCount; - } - - public int getUnifiedAddressing() { - return unifiedAddressing; - } - - public void setUnifiedAddressing(int unifiedAddressing) { - this.unifiedAddressing = unifiedAddressing; - } - - public int getMemoryClockRate() { - return memoryClockRate; - } - - public void setMemoryClockRate(int memoryClockRate) { - this.memoryClockRate = memoryClockRate; - } - - public int getMemoryBusWidth() { - return memoryBusWidth; - } - - public void setMemoryBusWidth(int memoryBusWidth) { - this.memoryBusWidth = memoryBusWidth; - } - - public int getL2CacheSize() { - return l2CacheSize; - } - - public void setL2CacheSize(int l2CacheSize) { - this.l2CacheSize = l2CacheSize; - } - - public int getMaxThreadsPerMultiProcessor() { - return maxThreadsPerMultiProcessor; - } - - public void setMaxThreadsPerMultiProcessor(int maxThreadsPerMultiProcessor) { - this.maxThreadsPerMultiProcessor = maxThreadsPerMultiProcessor; - } - - public int getStreamPrioritiesSupported() { - return streamPrioritiesSupported; - } - - public void setStreamPrioritiesSupported(int streamPrioritiesSupported) { - this.streamPrioritiesSupported = streamPrioritiesSupported; - } - - public int getGlobalL1CacheSupported() { - return globalL1CacheSupported; - } - - public void setGlobalL1CacheSupported(int globalL1CacheSupported) { - this.globalL1CacheSupported = globalL1CacheSupported; - } - - public int getLocalL1CacheSupported() { - return localL1CacheSupported; - } - - public void setLocalL1CacheSupported(int localL1CacheSupported) { - this.localL1CacheSupported = localL1CacheSupported; - } - - public long getSharedMemPerMultiprocessor() { - return sharedMemPerMultiprocessor; - } - - public void setSharedMemPerMultiprocessor(long sharedMemPerMultiprocessor) { - this.sharedMemPerMultiprocessor = sharedMemPerMultiprocessor; - } - - public int getRegsPerMultiprocessor() { - return regsPerMultiprocessor; - } - - public void setRegsPerMultiprocessor(int regsPerMultiprocessor) { - this.regsPerMultiprocessor = regsPerMultiprocessor; - } - - public int getManagedMemory() { - return managedMemory; - } - - public void setManagedMemory(int managedMemory) { - this.managedMemory = managedMemory; - } - - public int getIsMultiGpuBoard() { - return isMultiGpuBoard; - } - - public void setIsMultiGpuBoard(int isMultiGpuBoard) { - this.isMultiGpuBoard = isMultiGpuBoard; - } - - public int getMultiGpuBoardGroupID() { - return multiGpuBoardGroupID; - } - - public void setMultiGpuBoardGroupID(int multiGpuBoardGroupID) { - this.multiGpuBoardGroupID = multiGpuBoardGroupID; - } - - - - } - - - -} diff --git a/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaRt_memory.java b/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaRt_memory.java deleted file mode 100644 index d9a4595..0000000 --- a/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaRt_memory.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. To change this - * template file, choose Tools | Templates and open the template in the editor. - */ -package eu.project.rapid.gvirtusfe; - -import java.io.IOException; - -import eu.project.rapid.ac.utils.Utils; - -/** - * - * @author cferraro - */ -public class CudaRt_memory { - - public CudaRt_memory() {} - - - - public String cudaMalloc(Frontend fe, Result res, long size) throws IOException { - - Buffer b = new Buffer(); - b.Add((int) size); - String pointer = ""; - fe.Execute("cudaMalloc", b, res); - pointer = getHex(res, 8); - return pointer; - } - - public void cudaMemcpy(Frontend fe, Result res, String dst, float[] src, int count, int kind) - throws IOException { - - Buffer b = new Buffer(); - b.Add(dst); - b.Add(count * 4); - b.Add(src); - b.Add(count * 4); - b.AddInt(kind); - fe.Execute("cudaMemcpy", b, res); - - - } - - - private String getHex(Result res, int size) throws IOException { - - byte[] array = new byte[size]; - for (int i = 0; i < size; i++) { - byte bit = res.getInput_stream().readByte(); - array[i] = bit; - } - // String hex = DatatypeConverter.printHexBinary(array); - String hex = Utils.bytesToHex(array); - return hex; - } -} diff --git a/AccelerationClient/src/eu/project/rapid/gvirtusfe/Frontend.java b/AccelerationClient/src/eu/project/rapid/gvirtusfe/Frontend.java deleted file mode 100755 index 791d515..0000000 --- a/AccelerationClient/src/eu/project/rapid/gvirtusfe/Frontend.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. To change this - * template file, choose Tools | Templates and open the template in the editor. - */ -package eu.project.rapid.gvirtusfe; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.net.Socket; - -import android.util.Log; -import eu.project.rapid.ac.utils.Utils; - -/** - * - * @author cferraro - */ -public final class Frontend { - - private static final String TAG = Frontend.class.getName(); - - String serverIpAddress; - int port; - Socket socket, clientSocket; - DataOutputStream outputStream, clientOutputStream; - DataInputStream in, clientIn; - - public Frontend(String url, int port) { - - this.serverIpAddress = url; - this.port = port; - try { - this.socket = new Socket(); - socket.connect(new InetSocketAddress(this.serverIpAddress, this.port), 10 * 1000); - this.outputStream = new DataOutputStream(this.socket.getOutputStream()); - this.in = new DataInputStream(this.socket.getInputStream()); - } catch (IOException e) { - Log.e(TAG, "Could not connect to GVirtuS backend server!" + e); - } - } - - public int Execute(String routine, Buffer input_buffer, Result res) throws IOException { - - for (int i = 0; i < routine.length(); i++) - this.outputStream.writeByte(routine.charAt(i)); - this.outputStream.writeByte(0); - long size = input_buffer.Size() / 2; - byte[] bits = this.longToByteArray(size); - for (int i = 0; i < bits.length; i++) { - this.outputStream.write(bits[i] & 0xFF); - } - - // byte[] bytes2 = DatatypeConverter.parseHexBinary(input_buffer.GetString()); - byte[] bytes2 = Utils.hexToBytes(input_buffer.GetString()); - - for (int i = 0; i < bytes2.length; i++) { - this.outputStream.write(bytes2[i] & 0xFF); - } - int message = this.in.readByte(); - this.in.readByte(); - this.in.readByte(); - this.in.readByte(); - res.setExit_code(message); - int sizes = (int) this.in.readByte(); - res.setSizeBuffer(sizes); - for (int i = 0; i < 7; i++) - this.in.readByte(); - res.setInput_stream(this.in); - return 0; - } - - // - // public int ExecuteMultiThread(String routine,Buffer input_buffer,Result res) throws - // IOException{ - // - // for (int i =0; i< routine.length();i++)this.outputStream.writeByte(routine.charAt(i)); - // this.outputStream.writeByte(0); - // this.clientSocket = new Socket(this.serverIpAddress,9998); - // this.clientIn = new DataInputStream(this.clientSocket.getInputStream()); - // this.clientOutputStream = new DataOutputStream(this.clientSocket.getOutputStream()); - // long size = input_buffer.Size()/2; - // byte[] bits = this.longToByteArray(size); - // for (int i =0; i< bits.length;i++){ - // this.clientOutputStream.write(bits[i] & 0xFF); - // } - // - // byte[] bytes2 = DatatypeConverter.parseHexBinary(input_buffer.GetString()); - // - // for (int i =0; i< bytes2.length;i++){ - // this.clientOutputStream.write(bytes2[i] & 0xFF); - // } - // - // int message = this.clientIn.readByte(); - // this.clientIn.readByte(); - // this.clientIn.readByte(); - // this.clientIn.readByte(); - // res.setExit_code(message); - // long size_buffer = this.clientIn.readByte(); - // for (int i =0 ; i< 7; i++) this.clientIn.readByte(); - // res.setInput_stream(this.clientIn); - // return 0; - // } - // - public void writeLong(DataOutputStream os, long l) throws IOException { - os.write((byte) l); - os.write((byte) (l >> 56)); - os.write((byte) (l >> 48)); - os.write((byte) (l >> 40)); - os.write((byte) (l >> 32)); - os.write((byte) (l >> 24)); - os.write((byte) (l >> 16)); - os.write((byte) (l >> 8)); - } - - public void writeChar(DataOutputStream os, char l) throws IOException { - os.write((byte) l); - os.write((byte) (l >> 56)); - os.write((byte) (l >> 48)); - os.write((byte) (l >> 40)); - os.write((byte) (l >> 32)); - os.write((byte) (l >> 24)); - os.write((byte) (l >> 16)); - os.write((byte) (l >> 8)); - } - - public char readChar(DataInputStream os) throws IOException { - int x; - x = os.readByte(); - x = x >> 56; - x = os.readByte(); - x = x >> 48; - x = os.readByte(); - x = x >> 40; - x = os.readByte(); - x = x >> 32; - x = os.readByte(); - x = x >> 24; - x = os.readByte(); - x = x >> 16; - x = os.readByte(); - x = x >> 8; - x = os.readByte(); - return (char) x; - - } - - public void writeInt(DataOutputStream os, int l) throws IOException { - os.write((byte) l); - os.write((byte) (l >> 24)); - os.write((byte) (l >> 16)); - os.write((byte) (l >> 8)); - } - - public void writeHex(DataOutputStream os, long x) throws IOException { - String hex = Integer.toHexString((int) (x)); - StringBuilder out2 = new StringBuilder(); - int scarto = 0; - if (hex.length() > 2) { - for (int i = hex.length() - 1; i > 0; i -= 2) { - String str = hex.substring(i - 1, i + 1); - out2.insert(0, str); - os.write((byte) Integer.parseInt(out2.toString(), 16)); - scarto += 2; - } - if (scarto != hex.length()) { - os.write((byte) Integer.parseInt(hex.substring(0, 1), 16)); - } - } - os.write((byte) (0)); - os.write((byte) (0)); - os.write((byte) (0)); - os.write((byte) (0)); - os.write((byte) (0)); - os.write((byte) (0)); - } - - public byte[] longToByteArray(long value) { - return new byte[] {(byte) value, (byte) (value >> 8), (byte) (value >> 16), - (byte) (value >> 24), (byte) (value >> 32), (byte) (value >> 40), (byte) (value >> 48), - (byte) (value >> 56) - - - }; - } - -} diff --git a/AccelerationClient/src/eu/project/rapid/gvirtusfe/Result.java b/AccelerationClient/src/eu/project/rapid/gvirtusfe/Result.java deleted file mode 100755 index f8f4a69..0000000 --- a/AccelerationClient/src/eu/project/rapid/gvirtusfe/Result.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. To change this - * template file, choose Tools | Templates and open the template in the editor. - */ -package eu.project.rapid.gvirtusfe; - -import java.io.DataInputStream; - -/** - * - * @author cferraro - */ -public class Result { - int exit_code; - String output_buffer; - DataInputStream input_stream; - int sizebuffer; - - - public DataInputStream getInput_stream() { - return input_stream; - } - - public void setInput_stream(DataInputStream input_stream) { - this.input_stream = input_stream; - } - - public String getOutput_buffer() { - return output_buffer; - } - - public void setOutput_buffer(String output_buffer) { - this.output_buffer = output_buffer; - } - - public Result() { - this.output_buffer = ""; - } - - public int getExit_code() { - return exit_code; - } - - public void setExit_code(int exit_code) { - this.exit_code = exit_code; - } - - void setSizeBuffer(int sizes) { - this.sizebuffer = sizes; - } - - public int getSizebuffer() { - return sizebuffer; - } - -} diff --git a/AccelerationClient/src/eu/project/rapid/gvirtusfe/dim3.java b/AccelerationClient/src/eu/project/rapid/gvirtusfe/dim3.java deleted file mode 100644 index 749401f..0000000 --- a/AccelerationClient/src/eu/project/rapid/gvirtusfe/dim3.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. To change this - * template file, choose Tools | Templates and open the template in the editor. - */ -package eu.project.rapid.gvirtusfe; - -/** - * - * @author cferraro - */ -public class dim3 { - - int x; - int y; - int z; - - public dim3(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } - - /** - * @return the x - */ - public int getX() { - return x; - } - - /** - * @param x the x to set - */ - public void setX(int x) { - this.x = x; - } - - /** - * @return the y - */ - public int getY() { - return y; - } - - /** - * @param y the y to set - */ - public void setY(int y) { - this.y = y; - } - - /** - * @return the z - */ - public int getZ() { - return z; - } - - /** - * @param z the z to set - */ - public void setZ(int z) { - this.z = z; - } - -} diff --git a/AccelerationServer/.classpath b/AccelerationServer/.classpath deleted file mode 100755 index 4ce678a..0000000 --- a/AccelerationServer/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/AccelerationServer/.project b/AccelerationServer/.project deleted file mode 100755 index 9c4c88c..0000000 --- a/AccelerationServer/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - AccelerationServer - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/AccelerationServer/.settings/org.eclipse.jdt.core.prefs b/AccelerationServer/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index d5d624f..0000000 --- a/AccelerationServer/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,297 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=16 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=0 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=0 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=2 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.format_block_comments=true -org.eclipse.jdt.core.formatter.comment.format_header=true -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=true -org.eclipse.jdt.core.formatter.comment.format_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert -org.eclipse.jdt.core.formatter.comment.line_length=100 -org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true -org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true -org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.join_lines_in_comments=true -org.eclipse.jdt.core.formatter.join_wrapped_lines=true -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=100 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=3 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false -org.eclipse.jdt.core.formatter.tabulation.char=space -org.eclipse.jdt.core.formatter.tabulation.size=2 -org.eclipse.jdt.core.formatter.use_on_off_tags=false -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true -org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true -org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true -org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/AccelerationServer/.settings/org.eclipse.jdt.ui.prefs b/AccelerationServer/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 1a05a42..0000000 --- a/AccelerationServer/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,62 +0,0 @@ -eclipse.preferences.version=1 -editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_profile=_GoogleStyle -formatter_settings_version=12 -sp_cleanup.add_default_serial_version_id=true -sp_cleanup.add_generated_serial_version_id=false -sp_cleanup.add_missing_annotations=true -sp_cleanup.add_missing_deprecated_annotations=true -sp_cleanup.add_missing_methods=false -sp_cleanup.add_missing_nls_tags=false -sp_cleanup.add_missing_override_annotations=true -sp_cleanup.add_missing_override_annotations_interface_methods=true -sp_cleanup.add_serial_version_id=false -sp_cleanup.always_use_blocks=true -sp_cleanup.always_use_parentheses_in_expressions=false -sp_cleanup.always_use_this_for_non_static_field_access=false -sp_cleanup.always_use_this_for_non_static_method_access=false -sp_cleanup.convert_functional_interfaces=false -sp_cleanup.convert_to_enhanced_for_loop=false -sp_cleanup.correct_indentation=false -sp_cleanup.format_source_code=true -sp_cleanup.format_source_code_changes_only=false -sp_cleanup.insert_inferred_type_arguments=false -sp_cleanup.make_local_variable_final=true -sp_cleanup.make_parameters_final=false -sp_cleanup.make_private_fields_final=true -sp_cleanup.make_type_abstract_if_missing_method=false -sp_cleanup.make_variable_declarations_final=false -sp_cleanup.never_use_blocks=false -sp_cleanup.never_use_parentheses_in_expressions=true -sp_cleanup.on_save_use_additional_actions=false -sp_cleanup.organize_imports=true -sp_cleanup.qualify_static_field_accesses_with_declaring_class=false -sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_with_declaring_class=false -sp_cleanup.qualify_static_method_accesses_with_declaring_class=false -sp_cleanup.remove_private_constructors=true -sp_cleanup.remove_redundant_type_arguments=true -sp_cleanup.remove_trailing_whitespaces=false -sp_cleanup.remove_trailing_whitespaces_all=true -sp_cleanup.remove_trailing_whitespaces_ignore_empty=false -sp_cleanup.remove_unnecessary_casts=true -sp_cleanup.remove_unnecessary_nls_tags=false -sp_cleanup.remove_unused_imports=false -sp_cleanup.remove_unused_local_variables=false -sp_cleanup.remove_unused_private_fields=true -sp_cleanup.remove_unused_private_members=false -sp_cleanup.remove_unused_private_methods=true -sp_cleanup.remove_unused_private_types=true -sp_cleanup.sort_members=false -sp_cleanup.sort_members_all=false -sp_cleanup.use_anonymous_class_creation=false -sp_cleanup.use_blocks=false -sp_cleanup.use_blocks_only_for_return_and_throw=false -sp_cleanup.use_lambda=true -sp_cleanup.use_parentheses_in_expressions=false -sp_cleanup.use_this_for_non_static_field_access=false -sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true -sp_cleanup.use_this_for_non_static_method_access=false -sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true -sp_cleanup.use_type_arguments=false diff --git a/AccelerationServer/AndroidManifest.xml b/AccelerationServer/AndroidManifest.xml deleted file mode 100755 index 45dcf60..0000000 --- a/AccelerationServer/AndroidManifest.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/AccelerationServer/libs/core-1.51.0.0.jar b/AccelerationServer/libs/core-1.51.0.0.jar deleted file mode 100644 index 60b24dd..0000000 Binary files a/AccelerationServer/libs/core-1.51.0.0.jar and /dev/null differ diff --git a/AccelerationServer/libs/prov-1.51.0.0.jar b/AccelerationServer/libs/prov-1.51.0.0.jar deleted file mode 100644 index d5d7899..0000000 Binary files a/AccelerationServer/libs/prov-1.51.0.0.jar and /dev/null differ diff --git a/AccelerationServer/lint.xml b/AccelerationServer/lint.xml deleted file mode 100644 index 7a77bf7..0000000 --- a/AccelerationServer/lint.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - \ No newline at end of file diff --git a/AccelerationServer/project.properties b/AccelerationServer/project.properties deleted file mode 100644 index eb6bc59..0000000 --- a/AccelerationServer/project.properties +++ /dev/null @@ -1,32 +0,0 @@ -############################################################################### -# Copyright (C) 2015, 2016 RAPID EU Project -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -############################################################################### -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-23 -android.library.reference.1=../AccelerationClient diff --git a/AccelerationServer/res/drawable-hdpi/icon.png b/AccelerationServer/res/drawable-hdpi/icon.png deleted file mode 100755 index 8074c4c..0000000 Binary files a/AccelerationServer/res/drawable-hdpi/icon.png and /dev/null differ diff --git a/AccelerationServer/res/drawable-ldpi/icon.png b/AccelerationServer/res/drawable-ldpi/icon.png deleted file mode 100755 index 1095584..0000000 Binary files a/AccelerationServer/res/drawable-ldpi/icon.png and /dev/null differ diff --git a/AccelerationServer/res/drawable-mdpi/icon.png b/AccelerationServer/res/drawable-mdpi/icon.png deleted file mode 100755 index a07c69f..0000000 Binary files a/AccelerationServer/res/drawable-mdpi/icon.png and /dev/null differ diff --git a/AccelerationServer/res/drawable/icon.png b/AccelerationServer/res/drawable/icon.png deleted file mode 100755 index a07c69f..0000000 Binary files a/AccelerationServer/res/drawable/icon.png and /dev/null differ diff --git a/AccelerationServer/res/layout/main.xml b/AccelerationServer/res/layout/main.xml deleted file mode 100755 index 3cf7f08..0000000 --- a/AccelerationServer/res/layout/main.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - diff --git a/AccelerationServer/res/values/string.xml b/AccelerationServer/res/values/string.xml deleted file mode 100644 index 3937661..0000000 --- a/AccelerationServer/res/values/string.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - RAPID-Server - RAPID-Server - - \ No newline at end of file diff --git a/AccelerationServer/src/eu/project/rapid/as/AccelerationServer.java b/AccelerationServer/src/eu/project/rapid/as/AccelerationServer.java deleted file mode 100755 index f186270..0000000 --- a/AccelerationServer/src/eu/project/rapid/as/AccelerationServer.java +++ /dev/null @@ -1,560 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.as; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.net.DatagramPacket; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.MulticastSocket; -import java.net.ServerSocket; -import java.net.Socket; -import java.net.UnknownHostException; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.Security; -import java.security.UnrecoverableKeyException; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.util.Random; - -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLServerSocket; -import javax.net.ssl.SSLServerSocketFactory; - -import android.app.Service; -import android.content.Context; -import android.content.Intent; -import android.os.Handler; -import android.os.IBinder; -import android.util.Log; -import android.util.SparseArray; -import eu.project.rapid.ac.d2d.D2DMessage; -import eu.project.rapid.ac.utils.Constants; -import eu.project.rapid.ac.utils.Utils; -import eu.project.rapid.common.Configuration; -import eu.project.rapid.common.RapidConstants; -import eu.project.rapid.common.RapidMessages; -import eu.project.rapid.common.RapidMessages.AnimationMsg; -import eu.project.rapid.common.RapidUtils; - -/** - * Execution server which waits for incoming connections and starts a separate thread for each of - * them, leaving the AppHandler to actually deal with the clients - * - */ -public class AccelerationServer extends Service { - - private Context context; - - // When doing tests about send/receive data - // To avoid creating the objects in the real deployment - private static final boolean TESTING_UL_DL_RATE = true; - public static SparseArray bytesToSend; - - private static final String TAG = "AccelerationServer"; - private Configuration config; - - public static boolean asServiceRunning = true; - private static long userId = -1; // The userId will be given by the VMM - private static long vmId = -1; // The vmId will be assigned by the DS - private static String vmIp = ""; // The vmIp should be extracted by us - - private Handler mBroadcastHandler; - private Runnable mBroadcastRunnable; - - static { - Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1); - } - - /** Called when the service is first created. */ - @Override - public void onCreate() { - super.onCreate(); - Log.d(TAG, "Server created"); - - if (TESTING_UL_DL_RATE) { - bytesToSend = new SparseArray(); - byte[] b1 = new byte[1024]; - byte[] b2 = new byte[1024 * 1024]; - new Random().nextBytes(b1); - new Random().nextBytes(b2); - bytesToSend.append(1024, b1); - bytesToSend.append(1024 * 1024, b2); - } - } - - @Override - public void onDestroy() { - super.onDestroy(); - Log.d(TAG, "Server destroyed"); - } - - @Override - public int onStartCommand(Intent intent, int flags, int startId) { - // Create server socket - Log.d(TAG, "Start server socket"); - context = this.getApplicationContext(); - if (context == null) { - Log.e(TAG, "Context is null!!!"); - stopSelf(); - } - - // Create a special file on the clone that methods can use to check - // if are being executed on the clone or on the phone. - // This can be of help to advanced developers. - createOffloadedFile(); - - // Delete the file containing the cloneHelperId assigned to this clone - // (if such file does not exist do nothing). - Utils.deleteCloneHelperId(); - - try { - config = new Configuration(Constants.CLONE_CONFIG_FILE); - config.parseConfigFile(); - } catch (FileNotFoundException e1) { - Log.e(TAG, "Configuration file not found on the clone: " + Constants.CLONE_CONFIG_FILE); - Log.e(TAG, "Continuinig with default values."); - config = new Configuration(); - } - - try { - Log.i(TAG, "KeyStore default type: " + KeyStore.getDefaultType()); - KeyStore keyStore = KeyStore.getInstance("BKS"); - keyStore.load(new FileInputStream(Constants.SSL_KEYSTORE), - Constants.SSL_DEFAULT_PASSW.toCharArray()); - KeyManagerFactory kmf = - KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); - kmf.init(keyStore, Constants.SSL_DEFAULT_PASSW.toCharArray()); - - PrivateKey privateKey = (PrivateKey) keyStore.getKey(Constants.SSL_CERT_ALIAS, - Constants.SSL_DEFAULT_PASSW.toCharArray()); - Certificate cert = keyStore.getCertificate(Constants.SSL_CERT_ALIAS); - PublicKey publicKey = cert.getPublicKey(); - - config.setCryptoInitialized(true); - config.setKmf(kmf); - config.setPublicKey(publicKey); - config.setPrivateKey(privateKey); - - Log.i(TAG, "Certificate: " + cert.toString()); - Log.i(TAG, "PrivateKey algorithm: " + privateKey.getAlgorithm()); - Log.i(TAG, "PublicKey algorithm: " + publicKey.getAlgorithm()); - - } catch (IOException | KeyStoreException | NoSuchAlgorithmException | CertificateException - | UnrecoverableKeyException e) { - Log.e(TAG, "Crypto not initialized: " + e); - } - - // Connect to the manager to register and get the configuration details - Thread t = new Thread(new RegistrationManager()); - t.start(); - - // Start the D2D handler that broadcasts ping messages with a certain frequency - startD2DThread(); - - return START_STICKY; - } - - /** - * Creates a sentinel file on the clone in order to let the method know it is being executed on - * the clone. - */ - private void createOffloadedFile() { - try { - File f = new File(Constants.RAPID_FOLDER); - if (!f.exists()) { - f.mkdirs(); - } - f = new File(Constants.FILE_OFFLOADED); - f.createNewFile(); - } catch (IOException e) { - Log.e(TAG, "Could not create offloaded file: " + e); - } - } - - @Override - public IBinder onBind(Intent intent) { - return null; - } - - /** - * Read the config file to get the IP and port for the Manager. - * - * @throws IOException - * @throws UnknownHostException - */ - private class RegistrationManager implements Runnable { - - @Override - public void run() { - - // Before proceeding wait until the network interface is up and correctly configured - vmIp = waitForNetworkToBeUp(); - Log.i(TAG, "My IP: " + vmIp); - - if (vmIp.startsWith("10.0")) { - Log.i(TAG, "Running on VM on the cloud under VPN, trying to connect to VMM and DS..."); - if (registerWithVmmAndDs()) { - startClientListeners(); - } else { - Log.e(TAG, "Could not register with the VMM and DS, not starting the listeners."); - } - } else { - Log.i(TAG, "Running on a phone for D2D offloading, starting the listeners"); - startClientListeners(); - - // Check if the primary animation server is reachable - boolean primaryAnimationServerReachable = RapidUtils.isPrimaryAnimationServerRunning( - config.getAnimationServerIp(), config.getAnimationServerPort()); - Log.i(TAG, "Primary animation server reachable: " + primaryAnimationServerReachable); - if (!primaryAnimationServerReachable) { - config.setAnimationServerIp(RapidConstants.DEFAULT_SECONDARY_ANIMATION_SERVER_IP); - config.setAnimationServerPort(RapidConstants.DEFAULT_SECONDARY_ANIMATION_SERVER_PORT); - } - } - } - - private String waitForNetworkToBeUp() { - - InetAddress vmIpAddress = null; - do { - vmIpAddress = Utils.getIpAddress(); - try { - Thread.sleep(5 * 1000); - } catch (InterruptedException e) { - } - } while (vmIpAddress == null || !RapidUtils.validateIpAddress(vmIpAddress.getHostAddress())); - Log.i(TAG, "I have an IP: " + vmIpAddress.getHostAddress()); - - // FIXME: remove the hard-coded 10.0.* - if (vmIpAddress.getHostAddress().startsWith("10.0")) { - // This is a VM running on the cloud - boolean hostMachineReachable = false; - do { - try { - // The VMM runs on the host machine, so checking if we can ping the vmmIP in - // reality we are checking if we can ping the host machine. - // We should definitely be able to do that, otherwise this clone is useless if not - // connected to the network. - - InetAddress hostMachineAddress = InetAddress.getByName(config.getVmmIp()); - try { - Log.i(TAG, - "Trying to ping the host machine " + hostMachineAddress.getHostAddress() + "..."); - hostMachineReachable = hostMachineAddress.isReachable(5000); - try { - Thread.sleep(1 * 1000); - } catch (InterruptedException e) { - } - } catch (IOException e) { - Log.w(TAG, "Error while trying to ping the host machine: " + e); - } - } catch (UnknownHostException e1) { - Log.e(TAG, "Error while getting hostname: " + e1); - } - } while (!hostMachineReachable); - Log.i(TAG, "Host machine replied to ping. Network interface is up and running."); - } - - return vmIpAddress.getHostAddress(); - } - - private boolean registerWithVmmAndDs() { - - Socket vmmSocket = null; - ObjectOutputStream vmmOut = null; - ObjectInputStream vmmIn = null; - - try { - Log.d(TAG, "Connecting to VMM: " + config.getVmmIp() + ":" + config.getVmmPort()); - - vmmSocket = new Socket(); - vmmSocket.connect(new InetSocketAddress(config.getVmmIp(), config.getVmmPort()), 10 * 1000); - vmmOut = new ObjectOutputStream(vmmSocket.getOutputStream()); - vmmIn = new ObjectInputStream(vmmSocket.getInputStream()); - - Log.d(TAG, "Sending myIp: " + vmIp); - vmmOut.writeByte(RapidMessages.AS_RM_REGISTER_VMM); - vmmOut.writeUTF(vmIp); - vmmOut.flush(); - - // Receive message format: status (java byte), userId (java long) - byte status = vmmIn.readByte(); - Log.i(TAG, "VMM return Status: " + (status == RapidMessages.OK ? "OK" : "ERROR")); - if (status == RapidMessages.OK) { - userId = vmmIn.readLong(); - Log.i(TAG, "userId is: " + userId); - - if (registerWithDs()) { - // Notify the VMM that the registration with the DS was correct - Log.i(TAG, "Correctly registered with the DS"); - vmmOut.writeByte(RapidMessages.OK); - vmmOut.flush(); - return true; - } else { - // Notify the VMM that the registration with the DS was correct - Log.i(TAG, "Registration with the DS failed"); - vmmOut.writeByte(RapidMessages.ERROR); - vmmOut.flush(); - return false; - } - } - } catch (IOException e) { - Log.e(TAG, "Could not connect with the VMM: " + e); - } finally { - Log.d(TAG, "Done talking with the VMM"); - // Close the connection with the VMM - RapidUtils.closeQuietly(vmmOut); - RapidUtils.closeQuietly(vmmIn); - RapidUtils.closeQuietly(vmmSocket); - } - return false; - } - - private boolean registerWithDs() { - Log.i(TAG, "Registering with the DS..."); - - Socket dsSocket = null; - ObjectOutputStream dsOut = null; - ObjectInputStream dsIn = null; - - try { - dsSocket = new Socket(config.getDSIp(), config.getDSPort()); - dsOut = new ObjectOutputStream(dsSocket.getOutputStream()); - // dsOut.flush(); - dsIn = new ObjectInputStream(dsSocket.getInputStream()); - - // Send message format: command (java byte), userId (java long) - dsOut.writeByte(RapidMessages.AS_RM_REGISTER_DS); - dsOut.writeLong(userId); // userId - dsOut.flush(); - - // Receive message format: status (java byte), vmId (java long) - byte status = dsIn.readByte(); - System.out.println("Return Status: " + (status == RapidMessages.OK ? "OK" : "ERROR")); - if (status == RapidMessages.OK) { - vmId = dsIn.readLong(); - Log.i(TAG, "Received vmId: " + vmId); - return true; - } - - // Maybe we can add this functionality, the DS to send information about other components. - // config.setAnimationServerIp(dsIn.readUTF()); - // config.setAnimationServerPort(dsIn.readInt()); - - } catch (IOException e) { - Log.e(TAG, "Registering with the DS failed: " + e); - } finally { - RapidUtils.closeQuietly(dsOut); - RapidUtils.closeQuietly(dsIn); - RapidUtils.closeQuietly(dsSocket); - } - - return false; - } - } - - private void startClientListeners() { - - Log.d(TAG, "Starting NetworkProfilerServer on port " + config.getClonePortBandwidthTest()); - new Thread(new NetworkProfilerServer(config)).start(); - - Log.d(TAG, "Starting ClientListenerClear on port " + config.getClonePort()); - new Thread(new ClientListenerClear(context, config)).start(); - - if (config.isCryptoInitialized()) { - Log.d(TAG, "Starting ClientListenerSSL on port " + config.getSslClonePort()); - new Thread(new ClientListenerSSL(context, config)).start(); - } else { - Log.w(TAG, - "Cannot start the CloneSSLThread since the cryptographic initialization was not succesful"); - } - } - - - /** - * The thread that listens for new clients (phones or other clones) to connect in clear. - * - */ - private class ClientListenerClear implements Runnable { - - private static final String TAG = "ClientListenerClear"; - - private Context context; - private Configuration config; - - public ClientListenerClear(Context context, eu.project.rapid.common.Configuration config) { - this.context = context; - this.config = config; - } - - @Override - public void run() { - - ServerSocket serverSocket = null; - try { - serverSocket = new ServerSocket(config.getClonePort()); - Log.i(TAG, "ClientListenerClear started on port " + config.getClonePort()); - while (true) { - Socket clientSocket = serverSocket.accept(); - Log.i(TAG, "New client connected in clear"); - new AppHandler(clientSocket, context, config); - } - } catch (IOException e) { - Log.e(TAG, "IOException: " + e.getMessage()); - e.printStackTrace(); - } finally { - if (serverSocket != null) { - try { - serverSocket.close(); - } catch (IOException e) { - Log.e(TAG, "Error while closing server socket: " + e); - } - } - } - } - } - - /** - * The thread that listens for new clients (phones or other clones) to connect using SSL. - */ - public class ClientListenerSSL implements Runnable { - - private static final String TAG = "ClientListenerSSL"; - - private Context context; - private eu.project.rapid.common.Configuration config; - - public ClientListenerSSL(Context context, Configuration config) { - this.context = context; - this.config = config; - } - - @Override - public void run() { - - Log.i(TAG, "ClientListenerSSL started"); - - try { - SSLContext sslContext = SSLContext.getInstance("SSL"); - sslContext.init(config.getKmf().getKeyManagers(), null, null); - - SSLServerSocketFactory factory = - (SSLServerSocketFactory) sslContext.getServerSocketFactory(); - Log.i(TAG, "factory created"); - - SSLServerSocket serverSocket = - (SSLServerSocket) factory.createServerSocket(config.getSslClonePort()); - Log.i(TAG, "server socket created"); - - // If we want also the client to authenticate himself - // serverSocket.setNeedClientAuth(true); // default is false - - while (true) { - // Log.i(TAG, "Saved session IDs: "); - // Enumeration sessionIDs = sslContext.getServerSessionContext().getIds(); - // while(sessionIDs.hasMoreElements()) { - // Log.i(TAG, "ID: " + RapidUtils.bytesToHex(sessionIDs.nextElement())); - // } - // Log.i(TAG, ""); - // - Socket clientSocket = serverSocket.accept(); - Log.i(TAG, "New client connected using SSL"); - new AppHandler(clientSocket, context, config); - } - - } catch (IOException | NoSuchAlgorithmException | KeyManagementException e1) { - e1.printStackTrace(); - } - } - } - - /** - * FIXME This thread should run only on the mobile devices, so it should not be started - * automatically here but the user should have to press a button to start it. - */ - private void startD2DThread() { - if (mBroadcastHandler == null) { - mBroadcastHandler = new Handler(); - } - if (mBroadcastRunnable == null) { - mBroadcastRunnable = new D2DBroadcastThread(); - } - mBroadcastHandler.postDelayed(mBroadcastRunnable, Constants.D2D_BROADCAST_INTERVAL); - } - - private class D2DBroadcastThread implements Runnable { - public void run() { - Log.i(TAG, "Running the broadcast message runnable"); - if (context == null) { - Log.e(TAG, "Context is null!!!"); - } - broadcastMessage(new D2DMessage(context, D2DMessage.MsgType.HELLO)); - mBroadcastHandler.postDelayed(mBroadcastRunnable, Constants.D2D_BROADCAST_INTERVAL); - } - - private void broadcastMessage(final D2DMessage msg) { - new Thread() { - public void run() { - DatagramPacket packet; - MulticastSocket socket = null; - try { - byte[] data = Utils.objectToByteArray(msg); - - socket = new MulticastSocket(Constants.D2D_BROADCAST_PORT); - socket.setBroadcast(true); - - InetAddress myIpAddress = Utils.getIpAddress(); - if (myIpAddress != null) { - Log.i(TAG, "My IP address: " + myIpAddress.getHostAddress()); - - InetAddress broadcastAddress = Utils.getBroadcast(myIpAddress); - Log.i(TAG, "Broadcast IP address: " + broadcastAddress); - try { - packet = new DatagramPacket(data, data.length, broadcastAddress, - Constants.D2D_BROADCAST_PORT); - socket.send(packet); - Log.i(TAG, "==>> Broadcast message sent to " + broadcastAddress); - Log.i(TAG, "==>> CMD: " + msg); - RapidUtils.sendAnimationMsg(config, AnimationMsg.AS_BROADCASTING_D2D); - - } catch (NullPointerException | IOException e) { - Log.e(TAG, "Exception while sending data: " + e); - } - } - } catch (Exception e) { - Log.e(TAG, "Exception while sending data: " + e); - } finally { - if (socket != null) { - socket.close(); - } - } - } - }.start(); - } - } -} diff --git a/AccelerationServer/src/eu/project/rapid/as/AccelerationServerAutoStarter.java b/AccelerationServer/src/eu/project/rapid/as/AccelerationServerAutoStarter.java deleted file mode 100755 index 314ce2d..0000000 --- a/AccelerationServer/src/eu/project/rapid/as/AccelerationServerAutoStarter.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.as; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.util.Log; - -/** - * Listens to android.intent.action.BOOT_COMPLETED (defined in AndroidManifest.xml) and starts the - * execution server when the system has finished booting - * - */ -public class AccelerationServerAutoStarter extends BroadcastReceiver { - private static final String TAG = AccelerationServerAutoStarter.class.getName(); - - @Override - public void onReceive(Context context, Intent intent) { - Log.d(TAG, "onReceiveIntent: Start Execution Service"); - - Intent serviceIntent = new Intent(); - serviceIntent.setAction("eu.project.rapid.as.AccelerationServer"); - context.startService(serviceIntent); - } -} diff --git a/AccelerationServer/src/eu/project/rapid/as/AppHandler.java b/AccelerationServer/src/eu/project/rapid/as/AppHandler.java deleted file mode 100755 index 087a502..0000000 --- a/AccelerationServer/src/eu/project/rapid/as/AppHandler.java +++ /dev/null @@ -1,989 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.as; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.OptionalDataException; -import java.io.OutputStream; -import java.lang.reflect.Array; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.net.SocketException; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.LinkedList; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import android.content.Context; -import android.util.Log; -import dalvik.system.DexClassLoader; -import eu.project.rapid.ac.ResultContainer; -import eu.project.rapid.ac.profilers.DeviceProfiler; -import eu.project.rapid.ac.utils.Utils; -import eu.project.rapid.common.Clone; -import eu.project.rapid.common.Configuration; -import eu.project.rapid.common.RapidMessages; -import eu.project.rapid.common.RapidUtils; - -/** - * The server-side class handling client requests for invocation. Works in a separate thread for - * each client. This can handle requests coming from the phone (when behaving as the main clone) or - * requests coming from the main clone when behaving as a clone helper. - * - */ -public class AppHandler { - - private static final String TAG = "AppHandler"; - - private Configuration config; - // The main thread has cloneId = 0 - // the clone helpers have cloneId \in [1, nrClones-1] - private int cloneHelperId = 0; - private final Socket mClient; - private InputStream mIs; - private OutputStream mOs; - private DynamicObjectInputStream mObjIs; - private ObjectOutputStream mObjOs; - private final Context mContext; - private final int BUFFER = 8192; - - static int numberOfCloneHelpers = 0; // The number of clone helpers requested (not considering the - // main clone) - private ArrayList cloneHelpers; // Array containing the clone helpers - private static boolean withMultipleClones = false; // True if more than one clone is requested, - // False otherwise. - private Boolean[] pausedHelper; // Needed for synchronization with the clone helpers - private int requestFromMainServer = 0; // The main clone sends commands to the clone helpers - private Object responsesFromServers; // Array of partial results returned by the clone helpers - private AtomicInteger nrClonesReady = new AtomicInteger(0); // The main thread waits for all the - // clone helpers to finish execution - - private String appName; // the app name sent by the phone - private int appLength; // the app length in bytes sent by the phone - private Object objToExecute = new Object(); // the object to be executed sent by the phone - private String methodName; // the method to be executed - private Class[] pTypes; // the types of the parameters passed to the method - private Object[] pValues; // the values of the parameters to be passed to the method - private Class returnType; // the return type of the method - private String apkFilePath; // the path where the apk is installed - - // Classloaders needed by the dynamicObjectInputStream - private ClassLoader mCurrent = ClassLoader.getSystemClassLoader(); - private DexClassLoader mCurrentDexLoader = null; - - public AppHandler(Socket pClient, final Context cW, Configuration config) { - Log.d(TAG, "New Client connected"); - this.mClient = pClient; - this.mContext = cW; - this.config = config; - - Executer communicator = new Executer(); - communicator.start(); - } - - /** - * Method to retrieve an apk of an application that needs to be executed - * - * @param objIn Object input stream to simplify retrieval of data - * @return the file where the apk package is stored - * @throws IOException throw up an exception thrown if socket fails - */ - private void receiveApk(DynamicObjectInputStream objIn, String apkFilePath) { - // Receiving the apk file - // Get the length of the file receiving - try { - // Write it to the filesystem - File apkFile = new File(apkFilePath); - FileOutputStream fout = new FileOutputStream(apkFile); - BufferedOutputStream bout = new BufferedOutputStream(fout, BUFFER); - - // Get the apk file - Log.d(TAG, "Read apk"); - byte[] tempArray = new byte[BUFFER]; - int read = 0; - int totalRead = 0; - int prevPerc = 0; - int currPerc = 0; - while (totalRead < appLength) { - read = objIn.read(tempArray); - totalRead += read; - // Log.d(TAG, "Read " + read + " bytes"); - bout.write(tempArray, 0, read); - - currPerc = (int) (((double) totalRead / appLength) * 100); - if (currPerc % 10 > prevPerc) { - Log.d(TAG, "Got: " + currPerc + " % of the apk."); - Log.d(TAG, "TotalRead: " + totalRead + " of " + appLength + " bytes"); - prevPerc = currPerc; - } - } - - bout.flush(); - bout.close(); - - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * Extract native libraries for the x86 platform included in the .apk file (which is actually a - * zip file). - * - * The x86 shared libraries are: lib/x86/library.so inside the apk file. We extract them from the - * apk and save in the /data/data/eu.rapid.project.as/files folder. Initially we used to save them - * with the same name as the original (library.so) but this caused many problems related to - * classloaders. When an app was offloaded for the first time and used the library, the library - * was loaded in the jvm. If the client disconnected, the classloader that loaded the library was - * not unloaded, which means that also the library was not unloaded from the jvm. On consequent - * offloads of the same app, the classloader is different, meaning that the library could not be - * loaded anymore due to the fact that was already loaded by another classloader. But it could not - * even be used, due to the fact that the classloaders differ.
- *
- * To solve this problem we save the library within a new folder, increasing a sequence number - * each time the same app is offloaded. So, the library.so file will be saved as - * library-1/library.so, library-2/library.so, and so on. - * - * @param dexFile the apk file - * @return the list of shared libraries - */ - - @SuppressWarnings("unchecked") - private LinkedList addLibraries(File dexFile) { - Long startTime = System.nanoTime(); - - ZipFile apkFile; - LinkedList libFiles = new LinkedList(); - try { - apkFile = new ZipFile(dexFile); - Enumeration entries = (Enumeration) apkFile.entries(); - ZipEntry entry; - while (entries.hasMoreElements()) { - entry = entries.nextElement(); - // Zip entry for a lib file is in the form of - // lib/platform/library.so - // But only load x86 libraries on the server side - if (entry.getName().matches("lib/x86/(.*).so")) { - Log.d(TAG, "Matching APK entry - " + entry.getName()); - // Unzip the lib file from apk - BufferedInputStream is = new BufferedInputStream(apkFile.getInputStream(entry)); - - - // Folder where to put the libraries (usually this will resolve to: - // /data/data/eu.rapid.project.as/files) - File libFolder = new File(mContext.getFilesDir().getAbsolutePath()); - - // Get the library name without the .so extension - String libName = entry.getName().replace("lib/x86/", "").replace(".so", ""); - - // The sequence number to append to the library name - int libSeqNr = 1; - for (File f : libFolder.listFiles()) { - // Scan all the previously created folder libraries until we find this one - int lastIndexDash = f.getName().lastIndexOf("-"); - if (lastIndexDash != -1 && libName.equals(f.getName().substring(0, lastIndexDash))) { - try { - libSeqNr = Integer.parseInt(f.getName().substring(lastIndexDash + 1)); - // And increment the sequence number so that the library can be saved with a new - // name - libSeqNr++; - } catch (Exception e) { - Log.w(TAG, - "Library file does not contain any number in the name, maybe is not written by us!"); - } - - // Delete the current one - if (f.isDirectory()) { - for (File f2 : f.listFiles()) { - f2.delete(); - } - } - f.delete(); - } - } - - File currLibFolder = - new File(libFolder.getAbsolutePath() + File.separator + libName + "-" + libSeqNr); - currLibFolder.mkdir(); - - File libFile = - new File(currLibFolder.getAbsolutePath() + File.separator + libName + ".so"); - - // - // File libFile = new File(mContext.getFilesDir().getAbsolutePath() + "/" - // + entry.getName().replace("lib/x86/", "")); - // - // // Delete the old library files, otherwise the server crashes - // // when the app is installed twice. - // libFile.delete(); - // Let the error propagate if the file cannot be created - // - handled by IOException - libFile.createNewFile(); - - Log.d(TAG, "Writing lib file to " + libFile.getAbsolutePath()); - FileOutputStream fos = new FileOutputStream(libFile); - BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER); - - byte data[] = new byte[BUFFER]; - int count = 0; - while ((count = is.read(data, 0, BUFFER)) != -1) { - dest.write(data, 0, count); - } - dest.flush(); - dest.close(); - is.close(); - - // Store the library to the list - libFiles.add(libFile); - } - } - - } catch (IOException e) { - Log.d(TAG, "ERROR: File unzipping error " + e); - } - Log.d(TAG, - "Duration of unzipping libraries - " + ((System.nanoTime() - startTime) / 1000000) + "ms"); - return libFiles; - - } - - /** - * Reads in the object to execute an operation on, name of the method to be executed and executes - * it - * - * @param objIn Dynamic object input stream for reading an arbitrary object (class loaded from a - * previously obtained dex file inside an apk) - * @return result of executing the required method - * @throws IllegalArgumentException - * @throws IllegalAccessException - * @throws InvocationTargetException - * @throws OptionalDataException - * @throws ClassNotFoundException - * @throws IOException - * @throws SecurityException - * @throws NoSuchMethodException - * @throws NoSuchFieldException - */ - private Object retrieveAndExecute(DynamicObjectInputStream objIn, LinkedList libraries) { - Long getObjectDuration = -1L; - Long startTime = System.nanoTime(); - // Read the object in for execution - Log.d(TAG, "Read Object"); - try { - - // Receive the number of clones needed - numberOfCloneHelpers = objIn.readInt(); - Log.i(TAG, "The user is asking for " + numberOfCloneHelpers + " clones"); - numberOfCloneHelpers--; - withMultipleClones = numberOfCloneHelpers > 0; - - // Get the object - objToExecute = objIn.readObject(); - - // Get the class of the object, dynamically - Class objClass = objToExecute.getClass(); - - getObjectDuration = System.nanoTime() - startTime; - - Log.d(TAG, "Done Reading Object: " + objClass.getName() + " in " - + (getObjectDuration / 1000000000.0) + " seconds"); - - // Set up server-side DFE for the object - java.lang.reflect.Field fDfe = objClass.getDeclaredField("dfe"); - fDfe.setAccessible(true); - - Class dfeType = fDfe.getType(); - Constructor cons = dfeType.getConstructor((Class[]) null); - Object dfe = null; - try { - dfe = cons.newInstance((Object[]) null); - } catch (InstantiationException e) { - // too bad. still try to carry on. - e.printStackTrace(); - } - - fDfe.set(objToExecute, dfe); - - Log.d(TAG, "Read Method"); - // Read the name of the method to be executed - methodName = (String) objIn.readObject(); - - Object tempTypes = objIn.readObject(); - pTypes = (Class[]) tempTypes; - - Object tempValues = objIn.readObject(); - pValues = (Object[]) tempValues; - - Log.d(TAG, "Run Method " + methodName); - // Get the method to be run by reflection - Method runMethod = objClass.getDeclaredMethod(methodName, pTypes); - // And force it to be accessible (quite often would be declared - // private originally) - runMethod.setAccessible(true); // Set the method to be accessible - - if (withMultipleClones) { - pausedHelper = new Boolean[numberOfCloneHelpers + 1]; - for (int i = 1; i < numberOfCloneHelpers + 1; i++) - pausedHelper[i] = true; - - withMultipleClones = connectToServerHelpers(); - - if (withMultipleClones) { - Log.i(TAG, "The clones are successfully allocated."); - - returnType = runMethod.getReturnType(); // the return type of the offloaded method - - // Allocate the space for the responses from the other clones - responsesFromServers = Array.newInstance(returnType, numberOfCloneHelpers + 1); - - // Wait until all the threads are connected to the clone helpers - waitForThreadsToBeReady(); - - // Give the command to register the app first - sendCommandToAllThreads(RapidMessages.AC_REGISTER_AS); - - // Wait again for the threads to be ready - waitForThreadsToBeReady(); - - // And send a ping to all clones just for testing - // sendCommandToAllThreads(RapidMessages.PING); - // waitForThreadsToBeReady(); - /** - * Wake up the server helper threads and tell them to send the object to execute, the - * method, parameter types and parameter values - */ - sendCommandToAllThreads(RapidMessages.AC_OFFLOAD_REQ_AS); - } else { - Log.i(TAG, "Could not allocate other clones, doing only my part of the job."); - } - } - - // Run the method and retrieve the result - Object result; - Long execDuration = null; - try { - // RapidUtils.sendAnimationMsg(config, RapidMessages.AC_EXEC_REMOTE); - Long startExecTime = System.nanoTime(); - try { - // long s = System.nanoTime(); - Method prepareDataMethod = - objToExecute.getClass().getDeclaredMethod("prepareDataOnServer"); - prepareDataMethod.setAccessible(true); - // RapidUtils.sendAnimationMsg(config, RapidMessages.AC_PREPARE_DATA); - long s = System.nanoTime(); - prepareDataMethod.invoke(objToExecute); - long prepareDataDuration = System.nanoTime() - s; - Log.w(TAG, "Executed method prepareDataOnServer() on " + (prepareDataDuration / 1000000) - + " ms"); - - } catch (NoSuchMethodException e) { - Log.w(TAG, "The method prepareDataOnServer() does not exist"); - } - - result = runMethod.invoke(objToExecute, pValues); - execDuration = System.nanoTime() - startExecTime; - Log.d(TAG, - runMethod.getName() + ": pure execution time - " + (execDuration / 1000000) + "ms"); - } catch (InvocationTargetException e) { - // The method might have failed if the required shared library - // had not been loaded before, try loading the apk's libraries and - // restarting the method - if (e.getTargetException() instanceof UnsatisfiedLinkError - || e.getTargetException() instanceof ExceptionInInitializerError) { - Log.d(TAG, "UnsatisfiedLinkError thrown, loading libs and retrying"); - - Method libLoader = objClass.getMethod("loadLibraries", LinkedList.class); - try { - libLoader.invoke(objToExecute, libraries); - // RapidUtils.sendAnimationMsg(config, RapidMessages.AC_EXEC_REMOTE); - Long startExecTime = System.nanoTime(); - result = runMethod.invoke(objToExecute, pValues); - execDuration = System.nanoTime() - startExecTime; - Log.d(TAG, - runMethod.getName() + ": pure execution time - " + (execDuration / 1000000) + "ms"); - } catch (InvocationTargetException e1) { - Log.e(TAG, "InvocationTargetException after loading the libraries"); - result = e1; - e1.printStackTrace(); - } - } else { - Log.w(TAG, "The remote execution resulted in exception: " + e); - result = e; - e.printStackTrace(); - } - } - - Log.d(TAG, runMethod.getName() + ": retrieveAndExecute time - " - + ((System.nanoTime() - startTime) / 1000000) + "ms"); - - if (withMultipleClones) { - // Wait for all the clones to finish execution before returning the result - waitForThreadsToBeReady(); - Log.d(TAG, "All servers finished execution, send result back."); - - // Kill the threads. - sendCommandToAllThreads(-1); - - // put the result of the main clone as the first element of the array - synchronized (responsesFromServers) { - Array.set(responsesFromServers, 0, result); - } - - // Call the reduce function implemented by the developer to combine the partial results. - try { - // Array of the returned type - Class arrayReturnType = - Array.newInstance(returnType, numberOfCloneHelpers + 1).getClass(); - Method runMethodReduce = - objClass.getDeclaredMethod(methodName + "Reduce", arrayReturnType); - runMethodReduce.setAccessible(true); - Log.i(TAG, "Reducing the results using the method: " + runMethodReduce.getName()); - - Object reducedResult = - runMethodReduce.invoke(objToExecute, new Object[] {responsesFromServers}); - result = reducedResult; - - Log.i(TAG, "The reduced result: " + reducedResult); - - } catch (Exception e) { - Log.e(TAG, "Impossible to reduce the result"); - e.printStackTrace(); - } - } - - objToExecute = null; - - // If this is the main clone send back also the object to execute, - // otherwise the helper clones don't need to send it back. - if (cloneHelperId == 0) { - // If we choose to also send back the object then the nr of bytes will increase. - // If necessary just uncomment the line below. - // return new ResultContainer(objToExecute, result, execDuration); - return new ResultContainer(null, result, getObjectDuration, execDuration); - } else { - return new ResultContainer(null, result, getObjectDuration, execDuration); - } - - } catch (Exception e) { - // catch and return any exception since we do not know how to handle - // them on the server side - e.printStackTrace(); - return new ResultContainer(e, getObjectDuration); - } - } - - private void waitForThreadsToBeReady() { - // Wait for the threads to be ready - synchronized (nrClonesReady) { - while (nrClonesReady.get() < numberOfCloneHelpers) { - try { - nrClonesReady.wait(); - } catch (InterruptedException e) { - } - } - - nrClonesReady.set(0); - } - } - - private void sendCommandToAllThreads(int command) { - synchronized (pausedHelper) { - for (int i = 1; i < numberOfCloneHelpers + 1; i++) { - pausedHelper[i] = false; - } - requestFromMainServer = command; - pausedHelper.notifyAll(); - } - } - - /** - * The Executer of remote code, which deals with the control protocol, flow of control, etc. - * - */ - private class Executer extends Thread { - private Object result; - private LinkedList libraries; - - @Override - public void run() { - - try { - mIs = mClient.getInputStream(); - mOs = mClient.getOutputStream(); - mObjIs = new DynamicObjectInputStream(mIs); - mObjOs = new ObjectOutputStream(mOs); - - mObjIs.setClassLoaders(mCurrent, mCurrentDexLoader); - - int request = 0; - while (request != -1) { - - request = mIs.read(); - Log.d(TAG, "Request - " + request); - - switch (request) { - case RapidMessages.AC_OFFLOAD_REQ_AS: - - // Start profiling on remote side - DeviceProfiler devProfiler = new DeviceProfiler(mContext); - devProfiler.startDeviceProfiling(); - - Log.d(TAG, "Execute request - " + request); - result = retrieveAndExecute(mObjIs, libraries); - - // Delete the file containing the cloneHelperId assigned to this clone - // (if such file does not exist do nothing) - Utils.deleteCloneHelperId(); - - devProfiler.stopAndCollectDeviceProfiling(); - - try { - // Send back over the socket connection - - // RapidUtils.sendAnimationMsg(config, RapidMessages.AC_RESULT_REMOTE); - mObjOs.writeObject(result); - // Clear ObjectOutputCache - Java caching unsuitable in this case - mObjOs.flush(); - mObjOs.reset(); - - Log.d(TAG, "Result successfully sent"); - - } catch (IOException e) { - Log.d(TAG, "Connection failed"); - e.printStackTrace(); - return; - } - - break; - - case RapidMessages.PING: - Log.d(TAG, "Reply to PING"); - mOs.write(RapidMessages.PONG); - break; - - case RapidMessages.AC_REGISTER_AS: - Log.d(TAG, "Registering apk"); - appName = (String) mObjIs.readObject(); - Log.i(TAG, "apk name: " + appName); - appLength = mObjIs.readInt(); - apkFilePath = mContext.getFilesDir().getAbsolutePath() + "/" + appName + ".apk"; - Log.d(TAG, "Registering apk: " + appName + " of size: " + appLength + " bytes"); - if (apkPresent(apkFilePath, appLength)) { - Log.d(TAG, "APK present"); - mOs.write(RapidMessages.AS_APP_PRESENT_AC); - } else { - Log.d(TAG, "request APK"); - mOs.write(RapidMessages.AS_APP_REQ_AC); - // Receive the apk file from the client - receiveApk(mObjIs, apkFilePath); - - // Delete the old .dex file of this apk to avoid the crash due to dexopt: - // DexOpt: source file mod time mismatch (457373af vs 457374dd) - // D/dalvikvm( 3885): ODEX file is stale or bad; removing and retrying - String oldDexFilePath = - mContext.getFilesDir().getAbsolutePath() + "/" + appName + ".dex"; - new File(oldDexFilePath).delete(); - } - // Create the new (if needed) dex file and load the .dex file - File dexFile = new File(apkFilePath); - Log.d(TAG, "APK file size on disk: " + dexFile.length()); - libraries = addLibraries(dexFile); - mCurrentDexLoader = mObjIs.addDex(dexFile); - Log.d(TAG, "DEX file added."); - - break; - - case RapidMessages.CLONE_ID_SEND: - cloneHelperId = mIs.read(); - Utils.writeCloneHelperId(cloneHelperId); - break; - - case RapidMessages.SEND_INT: - // Used for testing how much it takes to read an int with different data rates. - mObjIs.readInt(); - mOs.write(1); - break; - - case RapidMessages.SEND_BYTES: - // Used for testing how much it takes to read an object of different size with - // different data rates. - mObjIs.readObject(); - mOs.write(1); - break; - - case RapidMessages.RECEIVE_INT: - // The phone is asking the clone to send an int - // Used for measuring the costs of data receiving on the phone - long s = System.nanoTime(); - mObjOs.writeInt((int) System.currentTimeMillis()); - mObjOs.flush(); - mIs.read(); - s = System.nanoTime() - s; - mObjOs.writeLong(s); - mObjOs.flush(); - - break; - - case RapidMessages.RECEIVE_BYTES: - // The phone is asking the clone to send an object of specific size - // Used for measuring the costs of data receiving on the phone - int size = mObjIs.readInt(); - s = System.nanoTime(); - mObjOs.writeObject(AccelerationServer.bytesToSend.get(size)); - mObjOs.flush(); - mIs.read(); - s = System.nanoTime() - s; - mObjOs.writeLong(s); - mObjOs.flush(); - - break; - } - } - Log.d(TAG, "Client disconnected"); - RapidUtils.closeQuietly(mObjOs); - RapidUtils.closeQuietly(mObjIs); - RapidUtils.closeQuietly(mClient); - - } catch (SocketException e) { - Log.w(TAG, "Client disconnected: " + e); - } catch (Exception e) { - // We don't want any exceptions to escape from here, - // hide everything silently if we didn't foresee them cropping - // up... Since we don't want the server to die because - // somebody's program is misbehaving - Log.e(TAG, "Exception not caught properly - " + e); - e.printStackTrace(); - } catch (Error e) { - // We don't want any exceptions to escape from here, - // hide everything silently if we didn't foresee them cropping - // up... Since we don't want the server to die because - // somebody's program is misbehaving - Log.e(TAG, "Error not caught properly - " + e); - e.printStackTrace(); - } finally { - RapidUtils.closeQuietly(mObjOs); - RapidUtils.closeQuietly(mObjIs); - RapidUtils.closeQuietly(mClient); - } - } - } - - /** - * Check if the application is already present on the machine - * - * @param filename filename of the apk file (used for identification) - * @return true if the apk is present, false otherwise - */ - private boolean apkPresent(String filename, int appLength) { - // TODO: more sophisticated checking for existence - File apkFile = new File(filename); - return (apkFile.exists() && apkFile.length() == appLength); - } - - - /** - * Connect to the manager and ask for more clones.
- * The manager will reply with the IP address of the clones
- * - * Launch the threads to connect to the other clones.
- */ - private boolean connectToServerHelpers() { - - Socket socket = null; - OutputStream os = null; - InputStream is = null; - ObjectOutputStream oos = null; - ObjectInputStream ois = null; - - try { - - Log.d(TAG, "Trying to connect to the manager: " + config.getVmmIp()); - - // Connect to the directory service - socket = new Socket(config.getVmmIp(), config.getVmmPort()); - os = socket.getOutputStream(); - is = socket.getInputStream(); - - Log.d(TAG, "Connection established whith directory service " + config.getVmmIp() + ":" - + config.getVmmPort()); - - // Tell DirService that this is a clone connecting - os.write(RapidMessages.CLONE_CONNECTION); - - oos = new ObjectOutputStream(os); - ois = new ObjectInputStream(is); - - // Ask for more clones - os.write(RapidMessages.PARALLEL_REQ); - oos.writeInt(config.getCloneId()); - oos.writeInt(numberOfCloneHelpers); - oos.flush(); - - cloneHelpers = (ArrayList) ois.readObject(); - if (cloneHelpers.size() != numberOfCloneHelpers) { - Log.i(TAG, "The directory service could not start the needed clones, actually started: " - + cloneHelpers.size()); - return false; - } - - // Assign the IDs to the new clone helpers - Log.i(TAG, "The helper clones:"); - int cloneHelperId = 1; - for (Clone c : cloneHelpers) { - - Log.i(TAG, c.toString()); - - // Start the thread that should connect to the clone helper - (new VMHelperThread(config, cloneHelperId++, c)).start(); - } - - return true; - - } catch (Exception e) { - Log.e(TAG, "Not able to connect to the manager: " + e.getMessage()); - } catch (Error e) { - Log.e(TAG, "Not able to connect to the manager: " + e.getMessage()); - } finally { - RapidUtils.closeQuietly(ois); - RapidUtils.closeQuietly(oos); - RapidUtils.closeQuietly(socket); - } - - return false; - } - - - /** - * The thread taking care of communication with the VM helpers - * - */ - public class VMHelperThread extends Thread { - - private String TAG = "ServerHelper-"; - private Configuration config; - private Clone clone; - private Socket mSocket; - private OutputStream mOutStream; - private InputStream mInStream; - private ObjectOutputStream mObjOutStream; - private DynamicObjectInputStream mObjInStream; - - // This id is assigned to the clone helper by the main clone. - // It is needed for splitting the input when parallelizing a certain method (see for example - // virusScanning). - // To not be confused with the id that the AS has read from the config file. - private int cloneHelperId; - - public VMHelperThread(Configuration config, int cloneHelperId, Clone clone) { - this.config = config; - this.clone = clone; - this.cloneHelperId = cloneHelperId; - TAG = TAG + this.cloneHelperId; - } - - @Override - public void run() { - - try { - - // Try to connect to the clone helper. - // If it is not possible to connect stop running. - if (!establishConnection()) { - // Try to close created sockets - closeConnection(); - return; - } - - // Send the cloneId to this clone. - mOutStream.write(RapidMessages.CLONE_ID_SEND); - mOutStream.write(cloneHelperId); - - while (true) { - - synchronized (nrClonesReady) { - Log.d(TAG, "Server Helpers started so far: " + nrClonesReady.addAndGet(1)); - if (nrClonesReady.get() >= AppHandler.numberOfCloneHelpers) - nrClonesReady.notifyAll(); - } - - /** - * wait() until the main server wakes up the thread then do something depending on the - * request - */ - synchronized (pausedHelper) { - while (pausedHelper[cloneHelperId]) { - try { - pausedHelper.wait(); - } catch (InterruptedException e) { - } - } - - pausedHelper[cloneHelperId] = true; - } - - Log.d(TAG, "Sending command: " + requestFromMainServer); - - switch (requestFromMainServer) { - - case RapidMessages.PING: - pingOtherServer(); - break; - - case RapidMessages.AC_REGISTER_AS: - mOutStream.write(RapidMessages.AC_REGISTER_AS); - mObjOutStream.writeObject(appName); - mObjOutStream.writeInt(appLength); - mObjOutStream.flush(); - - int response = mInStream.read(); - - if (response == RapidMessages.AS_APP_REQ_AC) { - // Send the APK file if needed - Log.d(TAG, "Sending apk to the clone " + clone.getIp()); - - File apkFile = new File(apkFilePath); - FileInputStream fin = new FileInputStream(apkFile); - BufferedInputStream bis = new BufferedInputStream(fin); - int BUFFER_SIZE = 8192; - byte[] tempArray = new byte[BUFFER_SIZE]; - int read = 0; - int totalRead = 0; - Log.d(TAG, "Sending apk"); - while ((read = bis.read(tempArray, 0, tempArray.length)) > -1) { - totalRead += read; - mObjOutStream.write(tempArray, 0, read); - Log.d(TAG, "Sent " + totalRead + " of " + apkFile.length() + " bytes"); - } - mObjOutStream.flush(); - bis.close(); - } else if (response == RapidMessages.AS_APP_PRESENT_AC) { - Log.d(TAG, "Application already registered on clone " + clone.getIp()); - } - break; - - case RapidMessages.AC_OFFLOAD_REQ_AS: - Log.d(TAG, "Asking clone " + clone.getIp() + " to parallelize the execution"); - - mOutStream.write(RapidMessages.AC_OFFLOAD_REQ_AS); - - // Send the number of clones needed. - // Since this is a helper clone, only one clone should be requested. - mObjOutStream.writeInt(1); - mObjOutStream.writeObject(objToExecute); - mObjOutStream.writeObject(methodName); - mObjOutStream.writeObject(pTypes); - mObjOutStream.writeObject(pValues); - mObjOutStream.flush(); - - /** - * This is the response from the clone helper, which is a partial result of the method - * execution. This partial result is stored in an array, and will be later composed - * with the other partial results of the other clones to obtain the total desired - * result to be sent back to the phone. - */ - Object cloneResult = mObjInStream.readObject(); - - ResultContainer container = (ResultContainer) cloneResult; - - Log.d(TAG, "Received response from clone ip: " + clone.getIp() + " port: " - + clone.getPort()); - Log.d(TAG, "Writing in responsesFromServer in position: " + cloneHelperId); - synchronized (responsesFromServers) { - Array.set(responsesFromServers, cloneHelperId, container.functionResult); - } - break; - - case -1: - closeConnection(); - return; - } - } - } catch (IOException e) { - e.printStackTrace(); - } catch (ClassNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - closeConnection(); - } - } - - private boolean establishConnection() { - try { - - Log.d(TAG, "Trying to connect to clone " + clone.getIp() + ":" + clone.getPort()); - - mSocket = new Socket(); - mSocket.connect(new InetSocketAddress(clone.getIp(), clone.getPort()), 10 * 1000); - - mOutStream = mSocket.getOutputStream(); - mInStream = mSocket.getInputStream(); - mObjOutStream = new ObjectOutputStream(mOutStream); - mObjInStream = new DynamicObjectInputStream(mInStream); - - Log.d(TAG, "Connection established whith clone " + clone.getIp()); - - return true; - } catch (Exception e) { - Log.e(TAG, "Exception not caught properly - " + e); - return false; - } catch (Error e) { - Log.e(TAG, "Error not caught properly - " + e); - return false; - } - } - - private void pingOtherServer() { - try { - // Send a message to the Server Helper (other server) - Log.d(TAG, "PING other server"); - mOutStream.write(eu.project.rapid.common.RapidMessages.PING); - - // Read and display the response message sent by server helper - int response = mInStream.read(); - - if (response == RapidMessages.PONG) - Log.d(TAG, "PONG from other server: " + clone.getIp() + ":" + clone.getPort()); - else { - Log.d(TAG, "Bad Response to Ping - " + response); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - private void closeConnection() { - RapidUtils.closeQuietly(mObjOutStream); - RapidUtils.closeQuietly(mObjInStream); - RapidUtils.closeQuietly(mSocket); - } - } - -} diff --git a/AccelerationServer/src/eu/project/rapid/as/DynamicObjectInputStream.java b/AccelerationServer/src/eu/project/rapid/as/DynamicObjectInputStream.java deleted file mode 100755 index 479e93d..0000000 --- a/AccelerationServer/src/eu/project/rapid/as/DynamicObjectInputStream.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.as; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectStreamClass; - -import dalvik.system.DexClassLoader; - -/** - * Custom object input stream to also deal with dynamically loaded classes. The classes can be - * retrieved from Android Dex files, provided in Apk (android application) files. - * - */ -public class DynamicObjectInputStream extends ObjectInputStream { - private static final String TAG = "DynamicObjectInputStream"; - - private ClassLoader mCurrent = null; - private DexClassLoader mCurrentDexLoader = null; - - public DynamicObjectInputStream(InputStream in) throws IOException { - super(in); - } - - /** - * Server side only. Need to have the server's classloaders otherwise if the classloaders are - * initialized here it doesn't work correctly. - * - * @param classLoader - * @param dexClassLoader - */ - public void setClassLoaders(ClassLoader classLoader, DexClassLoader dexClassLoader) { - mCurrent = classLoader; - mCurrentDexLoader = dexClassLoader; - } - - /** - * Override the method resolving a class to also look into the constructed DexClassLoader - */ - @Override - protected Class resolveClass(ObjectStreamClass desc) - throws IOException, ClassNotFoundException { - // Log.i(TAG, "Resolving class: " + desc.getName()); - - try { - try { - return mCurrent.loadClass(desc.getName()); - } catch (ClassNotFoundException e) { - return mCurrentDexLoader.loadClass(desc.getName()); - } - } catch (ClassNotFoundException e) { - return super.resolveClass(desc); - } catch (NullPointerException e) { - // Thrown when currentDexLoader is - // not yet set up - return super.resolveClass(desc); - } - } - - /** - * Add a Dex file to the Class Loader for dynamic class loading for clients - * - * @param apkFile the apk package - */ - public DexClassLoader addDex(final File apkFile) { - - if (mCurrentDexLoader == null) { - mCurrentDexLoader = new DexClassLoader(apkFile.getAbsolutePath(), - apkFile.getParentFile().getAbsolutePath(), null, mCurrent); - } else { - mCurrentDexLoader = new DexClassLoader(apkFile.getAbsolutePath(), - apkFile.getParentFile().getAbsolutePath(), null, mCurrentDexLoader); - } - - return mCurrentDexLoader; - } -} diff --git a/AccelerationServer/src/eu/project/rapid/as/NetworkProfilerServer.java b/AccelerationServer/src/eu/project/rapid/as/NetworkProfilerServer.java deleted file mode 100644 index 9eb91b9..0000000 --- a/AccelerationServer/src/eu/project/rapid/as/NetworkProfilerServer.java +++ /dev/null @@ -1,149 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.as; - -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.ServerSocket; -import java.net.Socket; -import java.util.Random; - -import android.util.Log; -import eu.project.rapid.common.Configuration; -import eu.project.rapid.common.RapidMessages; -import eu.project.rapid.common.RapidUtils; - -/** - * Listen for phone connections for measuring the data rate. The phone will send/receive some data - * for 3 seconds. - * - */ -public class NetworkProfilerServer implements Runnable { - - private static final String TAG = "NetworkProfilerServer"; - public static final int uid = android.os.Process.myUid(); - - private Configuration config; - private ServerSocket serverSocket; - - private long totalBytesRead; - private long totalTimeBytesRead; - private static final int BUFFER_SIZE = 10 * 1024; - private byte[] buffer; - - public NetworkProfilerServer(Configuration config) { - this.config = config; - buffer = new byte[BUFFER_SIZE]; - } - - @Override - public void run() { - try { - serverSocket = new ServerSocket(config.getClonePortBandwidthTest()); - while (true) { - Socket clientSocket = serverSocket.accept(); - new Thread(new ClientThread(clientSocket)).start(); - } - } catch (IOException e) { - Log.e(TAG, - "Could not start server on port " + config.getClonePortBandwidthTest() + " (" + e + ")"); - } - } - - private class ClientThread implements Runnable { - - private Socket clientSocket; - - public ClientThread(Socket clientSocket) { - this.clientSocket = clientSocket; - } - - @Override - public void run() { - int request = 0; - - InputStream is = null; - OutputStream os = null; - DataOutputStream dos = null; - try { - is = clientSocket.getInputStream(); - os = clientSocket.getOutputStream(); - dos = new DataOutputStream(os); - - while (request != -1) { - request = is.read(); - - switch (request) { - - case RapidMessages.UPLOAD_FILE: - new Thread(new Runnable() { - - @Override - public void run() { - long t0 = System.nanoTime(); - long elapsed = 0; - while (elapsed < 3000) { - try { - Thread.sleep(3000 - elapsed); - } catch (InterruptedException e1) { - } finally { - elapsed = (System.nanoTime() - t0) / 1000000; - } - } - RapidUtils.closeQuietly(clientSocket); - } - - }).start(); - - totalTimeBytesRead = System.nanoTime(); - totalBytesRead = 0; - while (true) { - totalBytesRead += is.read(buffer); - os.write(1); - } - - case RapidMessages.UPLOAD_FILE_RESULT: - dos.writeLong(totalBytesRead); - dos.writeLong(totalTimeBytesRead); - dos.flush(); - break; - - case RapidMessages.DOWNLOAD_FILE: - new Random().nextBytes(buffer); - // Used for measuring the dlRate on the phone - while (true) { - os.write(buffer); - is.read(); - } - } - } - - } catch (IOException e) { - } finally { - Log.i(TAG, "Client finished bandwidth measurement: " + request); - - if (request == RapidMessages.UPLOAD_FILE) - totalTimeBytesRead = System.nanoTime() - totalTimeBytesRead; - - RapidUtils.closeQuietly(os); - RapidUtils.closeQuietly(dos); - RapidUtils.closeQuietly(is); - } - } - } -} diff --git a/AccelerationServer/src/eu/project/rapid/as/RapidServerActivity.java b/AccelerationServer/src/eu/project/rapid/as/RapidServerActivity.java deleted file mode 100644 index adcbf28..0000000 --- a/AccelerationServer/src/eu/project/rapid/as/RapidServerActivity.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version - * 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - *******************************************************************************/ -package eu.project.rapid.as; - -import android.app.Activity; -import android.content.ComponentName; -import android.content.Intent; -import android.os.Bundle; -import android.util.Log; - -public class RapidServerActivity extends Activity { - - private static final String TAG = RapidServerActivity.class.getName(); - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - Log.d(TAG, "onCreate"); - - ComponentName comp = new ComponentName(getPackageName(), AccelerationServer.class.getName()); - startService(new Intent().setComponent(comp)); - - } -} diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 19e3071..0000000 --- a/LICENSE +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -(This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.) - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - {description} - Copyright (C) {year} {fullname} - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random - Hacker. - - {signature of Ty Coon}, 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/README.md b/README.md deleted file mode 100644 index 9f5a334..0000000 --- a/README.md +++ /dev/null @@ -1,64 +0,0 @@ -# Rapid - Android Offloading Framework -This is part of the [Rapid Project](http://www.rapid-project.eu) and is an ongoing work. While Rapid envisions to support heteregenous devices, this is the component that enables code offloading on Android devices. -Check the other Rapid repositories for code offloading on other platforms. - ->The main goal of the RAPID framework is to allow low-power devices to support compute-intensive tasks and applications at reasonable time. Hence, RAPID aspires to enable devices such as smartphones, notebooks, tablets, wearable devices, etc. to deliver both Central Processing Unit (CPU) and GPU intensive tasks, exploiting resources of more capable devices, or even the cloud, participating in the RAPID ecosystem. In this perspective, RAPID is developing an efficient heterogeneous CPU-GPU cloud computing infrastructure, which can be used to seamlessly offload CPU-based and GPU-based (using CUDA) tasks of applications to more powerful devices over a heterogeneous network (HetNet). - -## Terminology -* **User Device (UD):** is the low-power device (phone, e.g.) that will be accelerated by code offloading. In our scenario it will be a phone running Android (version 4.1+ is recommended). -* **Clone:** is a Virtual Machine (**VM**) running on virtualized software, with the same operating system as the UD. In our scenario it will be an Android-x86 instance (version 4.0+ is recommended) running on VirtualBox. -* **Acceleration Server (AS):** is an Android application that runs on the clone and is responsible for executing the offloaded code by the client. -* **Acceleration Client (AC):** is an Android library that enables code offloading on Android applications. -* **Rapid Common:** is a library that should be included by the AC project. -* **Rapid-DemoApp:** is an Android app that implements some simple applications that use code offloading. - -# Installation -We have implemented two ways of deploying the framework. -The first one is fast and is meant to be a simple setup for testing the offloading framework. -The second one requires all components of the Rapid project to be up and running. - -## Quick setup without Rapid infrastructure -Just following the simple steps described below you should be able to run the demo applications included in this repo in less than one hour. - -### What you need -* A computer running any operating system able to run a virtualization software such as [VirtualBox](https://www.virtualbox.org/). -* An Android phone running Android 4.1+ (recommended). -* A WiFi router where both computer and phone are connected. - * The phone should be able to ping the computer, as shown in the figure below. -![](https://dl.dropboxusercontent.com/u/7728796/img-quick-setup.png "An example of a simple setup.") - -### Download the components -* Download the following projects from github and build them using Eclipse. -* **AccelerationServer** is an Android application and is the component that will run on the *clone*. It will be responsible for executing the offloaded code. -* **AccelerationClient** is an *Android library* that should be included by the applications that want to perform code offloading. It should also be included by the Acceleration Server. - * This component should include the [RapidCommon](https://github.com/RapidProjectH2020/rapid-common) project. -* **Rapid-DemoApp** implements some demo apps to demonstrate how to use the offloading framework. It includes the AccelerationClient android library. - -### Download and deploy Android-x86 -* Download the Android-x86 iso from [here](http://www.android-x86.org/) (4.0+ is recommended). -* Install Android-x86 on a virtualization software (e.g. [VirtualBox](https://www.virtualbox.org/)) on a computer that is connected to the same router as the phone. -* After installing the VM, make sure the network interface of Android-x86 is correctly configured and is up. - * We recommend to configure networking as _Bridged_ adapter on VirtualBox. For more information on how to install and configure Android-x86 on VirtualBox please refer to [this page](http://www.android-x86.org/documents/virtualboxhowto). - * Get the IP address of the Android-x86 VM by accessing the _Terminal Emulator_ app on the VM and using the ```netcfg``` command. -* Make sure the Android phone and the Android-x86 VM are on the same network (e.g. they can ping each other). - -### Install _AccelerationServer_ component on Android-x86 -* First connect to the Android-x86 instance from your computer using ```adb connect [VM_IP]```. -* Install the AccelerationServer project on the Android-x86 *clone*. To do so, use Eclipse to launch the project as an Android app and select the Android-x86 as the target device. -* The AS will automatically start running on the VM and will start listening by default on port 4322. - -### Install _Rapid-DemoApp_ on the Android phone -* Attach your phone to the computer using the usb cable. - * Now your device should be recognized by adb. You can check it from the terminal using the ```adb devices``` command. -* Install the Rapid-DemoApp application on the phone. From Eclipse run the application as Android app and choose the phone as target device when asked where to install it. -* The app should automatically start and a graphical application will appear. -* We built a graphical interface to easily interact with the application and with the framework. -* Try to run the simple built-in applications and check the Android logcat for errors or for info messages. - -![](https://dl.dropboxusercontent.com/u/7728796/rapid1.png "The first activity used to insert the IP of the VM and start the connection.") -![](https://dl.dropboxusercontent.com/u/7728796/rapid2.png "The activity with some testing applications ready to run.") - -## Full setup with Rapid infrastructure -**TODO** - - diff --git a/Rapid-DemoApp/.classpath b/Rapid-DemoApp/.classpath deleted file mode 100755 index 5176974..0000000 --- a/Rapid-DemoApp/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/Rapid-DemoApp/.externalToolBuilders/NDK Build.launch b/Rapid-DemoApp/.externalToolBuilders/NDK Build.launch deleted file mode 100644 index 27ce3af..0000000 --- a/Rapid-DemoApp/.externalToolBuilders/NDK Build.launch +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Rapid-DemoApp/.project b/Rapid-DemoApp/.project deleted file mode 100755 index f8e040d..0000000 --- a/Rapid-DemoApp/.project +++ /dev/null @@ -1,43 +0,0 @@ - - - Rapid-DemoApp - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/NDK Build.launch - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/Rapid-DemoApp/.settings/org.eclipse.jdt.core.prefs b/Rapid-DemoApp/.settings/org.eclipse.jdt.core.prefs deleted file mode 100755 index d5d624f..0000000 --- a/Rapid-DemoApp/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,297 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=16 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=0 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=0 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=2 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.format_block_comments=true -org.eclipse.jdt.core.formatter.comment.format_header=true -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=true -org.eclipse.jdt.core.formatter.comment.format_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert -org.eclipse.jdt.core.formatter.comment.line_length=100 -org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true -org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true -org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.join_lines_in_comments=true -org.eclipse.jdt.core.formatter.join_wrapped_lines=true -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=100 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=3 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false -org.eclipse.jdt.core.formatter.tabulation.char=space -org.eclipse.jdt.core.formatter.tabulation.size=2 -org.eclipse.jdt.core.formatter.use_on_off_tags=false -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true -org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true -org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true -org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/Rapid-DemoApp/.settings/org.eclipse.jdt.ui.prefs b/Rapid-DemoApp/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 1a05a42..0000000 --- a/Rapid-DemoApp/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,62 +0,0 @@ -eclipse.preferences.version=1 -editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_profile=_GoogleStyle -formatter_settings_version=12 -sp_cleanup.add_default_serial_version_id=true -sp_cleanup.add_generated_serial_version_id=false -sp_cleanup.add_missing_annotations=true -sp_cleanup.add_missing_deprecated_annotations=true -sp_cleanup.add_missing_methods=false -sp_cleanup.add_missing_nls_tags=false -sp_cleanup.add_missing_override_annotations=true -sp_cleanup.add_missing_override_annotations_interface_methods=true -sp_cleanup.add_serial_version_id=false -sp_cleanup.always_use_blocks=true -sp_cleanup.always_use_parentheses_in_expressions=false -sp_cleanup.always_use_this_for_non_static_field_access=false -sp_cleanup.always_use_this_for_non_static_method_access=false -sp_cleanup.convert_functional_interfaces=false -sp_cleanup.convert_to_enhanced_for_loop=false -sp_cleanup.correct_indentation=false -sp_cleanup.format_source_code=true -sp_cleanup.format_source_code_changes_only=false -sp_cleanup.insert_inferred_type_arguments=false -sp_cleanup.make_local_variable_final=true -sp_cleanup.make_parameters_final=false -sp_cleanup.make_private_fields_final=true -sp_cleanup.make_type_abstract_if_missing_method=false -sp_cleanup.make_variable_declarations_final=false -sp_cleanup.never_use_blocks=false -sp_cleanup.never_use_parentheses_in_expressions=true -sp_cleanup.on_save_use_additional_actions=false -sp_cleanup.organize_imports=true -sp_cleanup.qualify_static_field_accesses_with_declaring_class=false -sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_with_declaring_class=false -sp_cleanup.qualify_static_method_accesses_with_declaring_class=false -sp_cleanup.remove_private_constructors=true -sp_cleanup.remove_redundant_type_arguments=true -sp_cleanup.remove_trailing_whitespaces=false -sp_cleanup.remove_trailing_whitespaces_all=true -sp_cleanup.remove_trailing_whitespaces_ignore_empty=false -sp_cleanup.remove_unnecessary_casts=true -sp_cleanup.remove_unnecessary_nls_tags=false -sp_cleanup.remove_unused_imports=false -sp_cleanup.remove_unused_local_variables=false -sp_cleanup.remove_unused_private_fields=true -sp_cleanup.remove_unused_private_members=false -sp_cleanup.remove_unused_private_methods=true -sp_cleanup.remove_unused_private_types=true -sp_cleanup.sort_members=false -sp_cleanup.sort_members_all=false -sp_cleanup.use_anonymous_class_creation=false -sp_cleanup.use_blocks=false -sp_cleanup.use_blocks_only_for_return_and_throw=false -sp_cleanup.use_lambda=true -sp_cleanup.use_parentheses_in_expressions=false -sp_cleanup.use_this_for_non_static_field_access=false -sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true -sp_cleanup.use_this_for_non_static_method_access=false -sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true -sp_cleanup.use_type_arguments=false diff --git a/Rapid-DemoApp/AndroidManifest.xml b/Rapid-DemoApp/AndroidManifest.xml deleted file mode 100755 index 222a3d0..0000000 --- a/Rapid-DemoApp/AndroidManifest.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Rapid-DemoApp/assets/cuda-kernels/matrixMul_kernel64.ptx b/Rapid-DemoApp/assets/cuda-kernels/matrixMul_kernel64.ptx deleted file mode 100644 index dcfd72d..0000000 --- a/Rapid-DemoApp/assets/cuda-kernels/matrixMul_kernel64.ptx +++ /dev/null @@ -1,772 +0,0 @@ - .version 1.4 - .target sm_11, map_f64_to_f32 - // compiled with /usr/local/cuda-6.5/open64/lib//be - // nvopencc 4.1 built on 2014-06-19 - - //----------------------------------------------------------- - // Compiling /tmp/tmpxft_000024c7_00000000-9_matrixMul_kernel.cpp3.i (/tmp/ccBI#.ypLfpy) - //----------------------------------------------------------- - - //----------------------------------------------------------- - // Options: - //----------------------------------------------------------- - // Target:ptx, ISA:sm_11, Endian:little, Pointer Size:64 - // -O3 (Optimization level) - // -g0 (Debug level) - // -m2 (Report advisories) - //----------------------------------------------------------- - - .file 1 "" - .file 2 "/usr/include/stdc-predef.h" - .file 3 "/tmp/tmpxft_000024c7_00000000-8_matrixMul_kernel.cudafe2.gpu" - .file 4 "/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h" - .file 5 "/usr/local/cuda/include/crt/device_runtime.h" - .file 6 "/usr/local/cuda/include/host_defines.h" - .file 7 "/usr/local/cuda/include/builtin_types.h" - .file 8 "/usr/local/cuda/include/device_types.h" - .file 9 "/usr/local/cuda/include/driver_types.h" - .file 10 "/usr/local/cuda/include/surface_types.h" - .file 11 "/usr/local/cuda/include/texture_types.h" - .file 12 "/usr/local/cuda/include/vector_types.h" - .file 13 "/usr/local/cuda/include/device_launch_parameters.h" - .file 14 "/usr/local/cuda/include/crt/storage_class.h" - .file 15 "matrixMul_kernel.cu" - .file 16 "/usr/local/cuda/include/common_functions.h" - .file 17 "/usr/local/cuda/include/math_functions.h" - .file 18 "/usr/local/cuda/include/math_constants.h" - .file 19 "/usr/local/cuda/include/device_functions.h" - .file 20 "/usr/local/cuda/include/sm_11_atomic_functions.h" - .file 21 "/usr/local/cuda/include/sm_12_atomic_functions.h" - .file 22 "/usr/local/cuda/include/sm_13_double_functions.h" - .file 23 "/usr/local/cuda/include/sm_20_atomic_functions.h" - .file 24 "/usr/local/cuda/include/sm_32_atomic_functions.h" - .file 25 "/usr/local/cuda/include/sm_35_atomic_functions.h" - .file 26 "/usr/local/cuda/include/sm_20_intrinsics.h" - .file 27 "/usr/local/cuda/include/sm_30_intrinsics.h" - .file 28 "/usr/local/cuda/include/sm_32_intrinsics.h" - .file 29 "/usr/local/cuda/include/sm_35_intrinsics.h" - .file 30 "/usr/local/cuda/include/surface_functions.h" - .file 31 "/usr/local/cuda/include/texture_fetch_functions.h" - .file 32 "/usr/local/cuda/include/texture_indirect_functions.h" - .file 33 "/usr/local/cuda/include/surface_indirect_functions.h" - .file 34 "/usr/local/cuda/include/math_functions_dbl_ptx1.h" - - .shared .align 4 .b8 __cuda_local_var_16455_39_non_const_As__6[1024]; - .shared .align 4 .b8 __cuda_local_var_16459_39_non_const_Bs__7[1024]; - - .entry matrixMul_bs16_32bit ( - .param .u64 __cudaparm_matrixMul_bs16_32bit_C, - .param .u64 __cudaparm_matrixMul_bs16_32bit_A, - .param .u64 __cudaparm_matrixMul_bs16_32bit_B, - .param .s32 __cudaparm_matrixMul_bs16_32bit_wA, - .param .s32 __cudaparm_matrixMul_bs16_32bit_wB) - { - .reg .u32 %r<34>; - .reg .u64 %rd<29>; - .reg .f32 %f<52>; - .reg .pred %p<4>; - .loc 15 109 0 -$LDWbegin_matrixMul_bs16_32bit: - .loc 15 66 0 - cvt.s32.u16 %r1, %ctaid.x; - mul24.lo.s32 %r2, %r1, 16; - cvt.s32.u16 %r3, %ctaid.y; - ld.param.s32 %r4, [__cudaparm_matrixMul_bs16_32bit_wA]; - mul.lo.s32 %r5, %r3, %r4; - mul.lo.s32 %r6, %r5, 16; - add.s32 %r7, %r6, %r4; - sub.s32 %r8, %r7, 1; - cvt.s32.u16 %r9, %tid.x; - cvt.s32.u16 %r10, %tid.y; - ld.param.s32 %r11, [__cudaparm_matrixMul_bs16_32bit_wB]; - setp.lt.s32 %p1, %r8, %r6; - @%p1 bra $Lt_0_3330; - mov.u64 %rd1, __cuda_local_var_16455_39_non_const_As__6; - mov.u64 %rd2, __cuda_local_var_16459_39_non_const_Bs__7; - ld.param.s32 %r4, [__cudaparm_matrixMul_bs16_32bit_wA]; - add.s32 %r12, %r4, 15; - shr.s32 %r13, %r12, 31; - mov.s32 %r14, 15; - and.b32 %r15, %r13, %r14; - add.s32 %r16, %r15, %r12; - shr.s32 %r17, %r16, 4; - ld.param.s32 %r11, [__cudaparm_matrixMul_bs16_32bit_wB]; - mul.lo.s32 %r18, %r10, %r11; - mul.lo.s32 %r19, %r10, %r4; - cvt.s64.s32 %rd3, %r9; - cvt.s64.s32 %rd4, %r10; - add.s32 %r20, %r19, %r6; - add.s32 %r21, %r9, %r20; - mul.wide.s32 %rd5, %r9, 4; - add.u64 %rd6, %rd2, %rd5; - mul.wide.s32 %rd7, %r10, 64; - add.u64 %rd8, %rd1, %rd7; - mul.wide.s32 %rd9, %r10, 16; - add.u64 %rd10, %rd3, %rd9; - mul.lo.u64 %rd11, %rd10, 4; - add.s32 %r22, %r19, %r8; - mul.lo.s32 %r23, %r11, 16; - cvt.s64.s32 %rd12, %r23; - mul.wide.s32 %rd13, %r23, 4; - add.u64 %rd14, %rd11, %rd1; - add.u64 %rd15, %rd11, %rd2; - add.s32 %r24, %r22, %r9; - ld.param.u64 %rd16, [__cudaparm_matrixMul_bs16_32bit_B]; - add.s32 %r25, %r18, %r2; - add.s32 %r26, %r9, %r25; - cvt.s64.s32 %rd17, %r26; - mul.wide.s32 %rd18, %r26, 4; - add.u64 %rd19, %rd16, %rd18; - ld.param.u64 %rd20, [__cudaparm_matrixMul_bs16_32bit_A]; - cvt.s64.s32 %rd21, %r21; - mul.wide.s32 %rd22, %r21, 4; - add.u64 %rd23, %rd20, %rd22; - mov.f32 %f1, 0f00000000; // 0 - mov.s32 %r27, %r17; -$Lt_0_2818: - // Loop body line 66, nesting depth: 1, estimated iterations: unknown - .loc 15 82 0 - ld.global.f32 %f2, [%rd23+0]; - st.shared.f32 [%rd14+0], %f2; - .loc 15 83 0 - ld.global.f32 %f3, [%rd19+0]; - st.shared.f32 [%rd15+0], %f3; - .loc 15 86 0 - bar.sync 0; - .loc 15 94 0 - ld.shared.f32 %f4, [%rd8+0]; - ld.shared.f32 %f5, [%rd6+0]; - mad.f32 %f6, %f4, %f5, %f1; - ld.shared.f32 %f7, [%rd8+4]; - ld.shared.f32 %f8, [%rd6+64]; - mad.f32 %f9, %f7, %f8, %f6; - ld.shared.f32 %f10, [%rd8+8]; - ld.shared.f32 %f11, [%rd6+128]; - mad.f32 %f12, %f10, %f11, %f9; - ld.shared.f32 %f13, [%rd8+12]; - ld.shared.f32 %f14, [%rd6+192]; - mad.f32 %f15, %f13, %f14, %f12; - ld.shared.f32 %f16, [%rd8+16]; - ld.shared.f32 %f17, [%rd6+256]; - mad.f32 %f18, %f16, %f17, %f15; - ld.shared.f32 %f19, [%rd8+20]; - ld.shared.f32 %f20, [%rd6+320]; - mad.f32 %f21, %f19, %f20, %f18; - ld.shared.f32 %f22, [%rd8+24]; - ld.shared.f32 %f23, [%rd6+384]; - mad.f32 %f24, %f22, %f23, %f21; - ld.shared.f32 %f25, [%rd8+28]; - ld.shared.f32 %f26, [%rd6+448]; - mad.f32 %f27, %f25, %f26, %f24; - ld.shared.f32 %f28, [%rd8+32]; - ld.shared.f32 %f29, [%rd6+512]; - mad.f32 %f30, %f28, %f29, %f27; - ld.shared.f32 %f31, [%rd8+36]; - ld.shared.f32 %f32, [%rd6+576]; - mad.f32 %f33, %f31, %f32, %f30; - ld.shared.f32 %f34, [%rd8+40]; - ld.shared.f32 %f35, [%rd6+640]; - mad.f32 %f36, %f34, %f35, %f33; - ld.shared.f32 %f37, [%rd8+44]; - ld.shared.f32 %f38, [%rd6+704]; - mad.f32 %f39, %f37, %f38, %f36; - ld.shared.f32 %f40, [%rd8+48]; - ld.shared.f32 %f41, [%rd6+768]; - mad.f32 %f42, %f40, %f41, %f39; - ld.shared.f32 %f43, [%rd8+52]; - ld.shared.f32 %f44, [%rd6+832]; - mad.f32 %f45, %f43, %f44, %f42; - ld.shared.f32 %f46, [%rd8+56]; - ld.shared.f32 %f47, [%rd6+896]; - mad.f32 %f48, %f46, %f47, %f45; - ld.shared.f32 %f49, [%rd8+60]; - ld.shared.f32 %f50, [%rd6+960]; - mad.f32 %f1, %f49, %f50, %f48; - .loc 15 99 0 - bar.sync 0; - .loc 15 66 0 - add.u64 %rd19, %rd13, %rd19; - add.s32 %r21, %r21, 16; - add.u64 %rd23, %rd23, 64; - setp.le.s32 %p2, %r21, %r24; - @%p2 bra $Lt_0_2818; - bra.uni $Lt_0_2306; -$Lt_0_3330: - ld.param.s32 %r11, [__cudaparm_matrixMul_bs16_32bit_wB]; - mul.lo.s32 %r18, %r10, %r11; - mov.f32 %f1, 0f00000000; // 0 -$Lt_0_2306: - .loc 15 105 0 - ld.param.u64 %rd24, [__cudaparm_matrixMul_bs16_32bit_C]; - mul.lo.s32 %r28, %r11, %r3; - add.s32 %r29, %r1, %r28; - mul.lo.s32 %r30, %r29, 16; - add.s32 %r31, %r18, %r30; - add.s32 %r32, %r9, %r31; - cvt.s64.s32 %rd25, %r32; - mul.wide.s32 %rd26, %r32, 4; - add.u64 %rd27, %rd24, %rd26; - st.global.f32 [%rd27+0], %f1; - .loc 15 112 0 - exit; -$LDWend_matrixMul_bs16_32bit: - } // matrixMul_bs16_32bit - .shared .align 4 .b8 __cuda_local_var_16455_39_non_const_As__4[1024]; - .shared .align 4 .b8 __cuda_local_var_16459_39_non_const_Bs__5[1024]; - - .entry matrixMul_bs16_64bit ( - .param .u64 __cudaparm_matrixMul_bs16_64bit_C, - .param .u64 __cudaparm_matrixMul_bs16_64bit_A, - .param .u64 __cudaparm_matrixMul_bs16_64bit_B, - .param .u64 __cudaparm_matrixMul_bs16_64bit_wA, - .param .u64 __cudaparm_matrixMul_bs16_64bit_wB) - { - .reg .u64 %rd<53>; - .reg .f32 %f<52>; - .reg .pred %p<4>; - .loc 15 113 0 -$LDWbegin_matrixMul_bs16_64bit: - .loc 15 66 0 - cvt.u64.u16 %rd1, %ctaid.x; - mul.lo.u64 %rd2, %rd1, 16; - cvt.u64.u16 %rd3, %ctaid.y; - ld.param.u64 %rd4, [__cudaparm_matrixMul_bs16_64bit_wA]; - mul.lo.u64 %rd5, %rd3, %rd4; - mul.lo.u64 %rd6, %rd5, 16; - mov.s64 %rd7, %rd6; - add.u64 %rd8, %rd6, %rd4; - sub.u64 %rd9, %rd8, 1; - cvt.u64.u16 %rd10, %tid.x; - cvt.u64.u16 %rd11, %tid.y; - ld.param.u64 %rd12, [__cudaparm_matrixMul_bs16_64bit_wB]; - setp.lt.u64 %p1, %rd9, %rd6; - @%p1 bra $Lt_1_3330; - mov.u64 %rd13, __cuda_local_var_16455_39_non_const_As__4; - mov.u64 %rd14, __cuda_local_var_16459_39_non_const_Bs__5; - ld.param.u64 %rd4, [__cudaparm_matrixMul_bs16_64bit_wA]; - add.u64 %rd15, %rd4, 15; - shr.s64 %rd16, %rd15, 63; - mov.s64 %rd17, 15; - and.b64 %rd18, %rd16, %rd17; - add.s64 %rd19, %rd18, %rd15; - shr.s64 %rd20, %rd19, 4; - ld.param.u64 %rd12, [__cudaparm_matrixMul_bs16_64bit_wB]; - mul.lo.u64 %rd21, %rd11, %rd12; - mul.lo.u64 %rd22, %rd11, 64; - add.u64 %rd23, %rd13, %rd22; - mul.lo.u64 %rd24, %rd10, 4; - add.u64 %rd25, %rd14, %rd24; - mul.lo.u64 %rd26, %rd11, 16; - add.u64 %rd27, %rd10, %rd26; - mul.lo.u64 %rd28, %rd27, 4; - mul.lo.u64 %rd29, %rd12, 64; - add.u64 %rd30, %rd28, %rd13; - add.u64 %rd31, %rd28, %rd14; - ld.param.u64 %rd32, [__cudaparm_matrixMul_bs16_64bit_B]; - add.u64 %rd33, %rd21, %rd2; - add.u64 %rd34, %rd10, %rd33; - mul.lo.u64 %rd35, %rd34, 4; - add.u64 %rd36, %rd32, %rd35; - ld.param.u64 %rd37, [__cudaparm_matrixMul_bs16_64bit_A]; - mul.lo.u64 %rd38, %rd11, %rd4; - add.u64 %rd39, %rd6, %rd38; - add.u64 %rd40, %rd10, %rd39; - mul.lo.u64 %rd41, %rd40, 4; - add.u64 %rd42, %rd37, %rd41; - mov.f32 %f1, 0f00000000; // 0 - mov.s64 %rd43, %rd20; -$Lt_1_2818: - // Loop body line 66, nesting depth: 1, estimated iterations: unknown - .loc 15 82 0 - ld.global.f32 %f2, [%rd42+0]; - st.shared.f32 [%rd30+0], %f2; - .loc 15 83 0 - ld.global.f32 %f3, [%rd36+0]; - st.shared.f32 [%rd31+0], %f3; - .loc 15 86 0 - bar.sync 0; - .loc 15 94 0 - ld.shared.f32 %f4, [%rd23+0]; - ld.shared.f32 %f5, [%rd25+0]; - mad.f32 %f6, %f4, %f5, %f1; - ld.shared.f32 %f7, [%rd23+4]; - ld.shared.f32 %f8, [%rd25+64]; - mad.f32 %f9, %f7, %f8, %f6; - ld.shared.f32 %f10, [%rd23+8]; - ld.shared.f32 %f11, [%rd25+128]; - mad.f32 %f12, %f10, %f11, %f9; - ld.shared.f32 %f13, [%rd23+12]; - ld.shared.f32 %f14, [%rd25+192]; - mad.f32 %f15, %f13, %f14, %f12; - ld.shared.f32 %f16, [%rd23+16]; - ld.shared.f32 %f17, [%rd25+256]; - mad.f32 %f18, %f16, %f17, %f15; - ld.shared.f32 %f19, [%rd23+20]; - ld.shared.f32 %f20, [%rd25+320]; - mad.f32 %f21, %f19, %f20, %f18; - ld.shared.f32 %f22, [%rd23+24]; - ld.shared.f32 %f23, [%rd25+384]; - mad.f32 %f24, %f22, %f23, %f21; - ld.shared.f32 %f25, [%rd23+28]; - ld.shared.f32 %f26, [%rd25+448]; - mad.f32 %f27, %f25, %f26, %f24; - ld.shared.f32 %f28, [%rd23+32]; - ld.shared.f32 %f29, [%rd25+512]; - mad.f32 %f30, %f28, %f29, %f27; - ld.shared.f32 %f31, [%rd23+36]; - ld.shared.f32 %f32, [%rd25+576]; - mad.f32 %f33, %f31, %f32, %f30; - ld.shared.f32 %f34, [%rd23+40]; - ld.shared.f32 %f35, [%rd25+640]; - mad.f32 %f36, %f34, %f35, %f33; - ld.shared.f32 %f37, [%rd23+44]; - ld.shared.f32 %f38, [%rd25+704]; - mad.f32 %f39, %f37, %f38, %f36; - ld.shared.f32 %f40, [%rd23+48]; - ld.shared.f32 %f41, [%rd25+768]; - mad.f32 %f42, %f40, %f41, %f39; - ld.shared.f32 %f43, [%rd23+52]; - ld.shared.f32 %f44, [%rd25+832]; - mad.f32 %f45, %f43, %f44, %f42; - ld.shared.f32 %f46, [%rd23+56]; - ld.shared.f32 %f47, [%rd25+896]; - mad.f32 %f48, %f46, %f47, %f45; - ld.shared.f32 %f49, [%rd23+60]; - ld.shared.f32 %f50, [%rd25+960]; - mad.f32 %f1, %f49, %f50, %f48; - .loc 15 99 0 - bar.sync 0; - .loc 15 66 0 - add.u64 %rd36, %rd29, %rd36; - add.u64 %rd7, %rd7, 16; - add.u64 %rd42, %rd42, 64; - setp.ge.u64 %p2, %rd9, %rd7; - @%p2 bra $Lt_1_2818; - bra.uni $Lt_1_2306; -$Lt_1_3330: - ld.param.u64 %rd12, [__cudaparm_matrixMul_bs16_64bit_wB]; - mul.lo.u64 %rd21, %rd11, %rd12; - mov.f32 %f1, 0f00000000; // 0 -$Lt_1_2306: - .loc 15 105 0 - ld.param.u64 %rd44, [__cudaparm_matrixMul_bs16_64bit_C]; - mul.lo.u64 %rd45, %rd12, %rd3; - add.u64 %rd46, %rd1, %rd45; - mul.lo.u64 %rd47, %rd46, 16; - add.u64 %rd48, %rd21, %rd47; - add.u64 %rd49, %rd10, %rd48; - mul.lo.u64 %rd50, %rd49, 4; - add.u64 %rd51, %rd44, %rd50; - st.global.f32 [%rd51+0], %f1; - .loc 15 116 0 - exit; -$LDWend_matrixMul_bs16_64bit: - } // matrixMul_bs16_64bit - .shared .align 4 .b8 __cuda_local_var_16455_39_non_const_As__2[4096]; - .shared .align 4 .b8 __cuda_local_var_16459_39_non_const_Bs__3[4096]; - - .entry matrixMul_bs32_32bit ( - .param .u64 __cudaparm_matrixMul_bs32_32bit_C, - .param .u64 __cudaparm_matrixMul_bs32_32bit_A, - .param .u64 __cudaparm_matrixMul_bs32_32bit_B, - .param .s32 __cudaparm_matrixMul_bs32_32bit_wA, - .param .s32 __cudaparm_matrixMul_bs32_32bit_wB) - { - .reg .u32 %r<34>; - .reg .u64 %rd<29>; - .reg .f32 %f<100>; - .reg .pred %p<4>; - .loc 15 117 0 -$LDWbegin_matrixMul_bs32_32bit: - .loc 15 66 0 - cvt.s32.u16 %r1, %ctaid.x; - mul24.lo.s32 %r2, %r1, 32; - cvt.s32.u16 %r3, %ctaid.y; - ld.param.s32 %r4, [__cudaparm_matrixMul_bs32_32bit_wA]; - mul.lo.s32 %r5, %r3, %r4; - mul.lo.s32 %r6, %r5, 32; - add.s32 %r7, %r6, %r4; - sub.s32 %r8, %r7, 1; - cvt.s32.u16 %r9, %tid.x; - cvt.s32.u16 %r10, %tid.y; - ld.param.s32 %r11, [__cudaparm_matrixMul_bs32_32bit_wB]; - setp.lt.s32 %p1, %r8, %r6; - @%p1 bra $Lt_2_3330; - mov.u64 %rd1, __cuda_local_var_16455_39_non_const_As__2; - mov.u64 %rd2, __cuda_local_var_16459_39_non_const_Bs__3; - ld.param.s32 %r4, [__cudaparm_matrixMul_bs32_32bit_wA]; - add.s32 %r12, %r4, 31; - shr.s32 %r13, %r12, 31; - mov.s32 %r14, 31; - and.b32 %r15, %r13, %r14; - add.s32 %r16, %r15, %r12; - shr.s32 %r17, %r16, 5; - ld.param.s32 %r11, [__cudaparm_matrixMul_bs32_32bit_wB]; - mul.lo.s32 %r18, %r10, %r11; - mul.lo.s32 %r19, %r10, %r4; - cvt.s64.s32 %rd3, %r9; - cvt.s64.s32 %rd4, %r10; - add.s32 %r20, %r19, %r6; - add.s32 %r21, %r9, %r20; - mul.wide.s32 %rd5, %r9, 4; - add.u64 %rd6, %rd2, %rd5; - mul.wide.s32 %rd7, %r10, 128; - add.u64 %rd8, %rd1, %rd7; - mul.wide.s32 %rd9, %r10, 32; - add.u64 %rd10, %rd3, %rd9; - mul.lo.u64 %rd11, %rd10, 4; - add.s32 %r22, %r19, %r8; - mul.lo.s32 %r23, %r11, 32; - cvt.s64.s32 %rd12, %r23; - mul.wide.s32 %rd13, %r23, 4; - add.u64 %rd14, %rd11, %rd1; - add.u64 %rd15, %rd11, %rd2; - add.s32 %r24, %r22, %r9; - ld.param.u64 %rd16, [__cudaparm_matrixMul_bs32_32bit_B]; - add.s32 %r25, %r18, %r2; - add.s32 %r26, %r9, %r25; - cvt.s64.s32 %rd17, %r26; - mul.wide.s32 %rd18, %r26, 4; - add.u64 %rd19, %rd16, %rd18; - ld.param.u64 %rd20, [__cudaparm_matrixMul_bs32_32bit_A]; - cvt.s64.s32 %rd21, %r21; - mul.wide.s32 %rd22, %r21, 4; - add.u64 %rd23, %rd20, %rd22; - mov.f32 %f1, 0f00000000; // 0 - mov.s32 %r27, %r17; -$Lt_2_2818: - // Loop body line 66, nesting depth: 1, estimated iterations: unknown - .loc 15 82 0 - ld.global.f32 %f2, [%rd23+0]; - st.shared.f32 [%rd14+0], %f2; - .loc 15 83 0 - ld.global.f32 %f3, [%rd19+0]; - st.shared.f32 [%rd15+0], %f3; - .loc 15 86 0 - bar.sync 0; - .loc 15 94 0 - ld.shared.f32 %f4, [%rd8+0]; - ld.shared.f32 %f5, [%rd6+0]; - mad.f32 %f6, %f4, %f5, %f1; - ld.shared.f32 %f7, [%rd8+4]; - ld.shared.f32 %f8, [%rd6+128]; - mad.f32 %f9, %f7, %f8, %f6; - ld.shared.f32 %f10, [%rd8+8]; - ld.shared.f32 %f11, [%rd6+256]; - mad.f32 %f12, %f10, %f11, %f9; - ld.shared.f32 %f13, [%rd8+12]; - ld.shared.f32 %f14, [%rd6+384]; - mad.f32 %f15, %f13, %f14, %f12; - ld.shared.f32 %f16, [%rd8+16]; - ld.shared.f32 %f17, [%rd6+512]; - mad.f32 %f18, %f16, %f17, %f15; - ld.shared.f32 %f19, [%rd8+20]; - ld.shared.f32 %f20, [%rd6+640]; - mad.f32 %f21, %f19, %f20, %f18; - ld.shared.f32 %f22, [%rd8+24]; - ld.shared.f32 %f23, [%rd6+768]; - mad.f32 %f24, %f22, %f23, %f21; - ld.shared.f32 %f25, [%rd8+28]; - ld.shared.f32 %f26, [%rd6+896]; - mad.f32 %f27, %f25, %f26, %f24; - ld.shared.f32 %f28, [%rd8+32]; - ld.shared.f32 %f29, [%rd6+1024]; - mad.f32 %f30, %f28, %f29, %f27; - ld.shared.f32 %f31, [%rd8+36]; - ld.shared.f32 %f32, [%rd6+1152]; - mad.f32 %f33, %f31, %f32, %f30; - ld.shared.f32 %f34, [%rd8+40]; - ld.shared.f32 %f35, [%rd6+1280]; - mad.f32 %f36, %f34, %f35, %f33; - ld.shared.f32 %f37, [%rd8+44]; - ld.shared.f32 %f38, [%rd6+1408]; - mad.f32 %f39, %f37, %f38, %f36; - ld.shared.f32 %f40, [%rd8+48]; - ld.shared.f32 %f41, [%rd6+1536]; - mad.f32 %f42, %f40, %f41, %f39; - ld.shared.f32 %f43, [%rd8+52]; - ld.shared.f32 %f44, [%rd6+1664]; - mad.f32 %f45, %f43, %f44, %f42; - ld.shared.f32 %f46, [%rd8+56]; - ld.shared.f32 %f47, [%rd6+1792]; - mad.f32 %f48, %f46, %f47, %f45; - ld.shared.f32 %f49, [%rd8+60]; - ld.shared.f32 %f50, [%rd6+1920]; - mad.f32 %f51, %f49, %f50, %f48; - ld.shared.f32 %f52, [%rd8+64]; - ld.shared.f32 %f53, [%rd6+2048]; - mad.f32 %f54, %f52, %f53, %f51; - ld.shared.f32 %f55, [%rd8+68]; - ld.shared.f32 %f56, [%rd6+2176]; - mad.f32 %f57, %f55, %f56, %f54; - ld.shared.f32 %f58, [%rd8+72]; - ld.shared.f32 %f59, [%rd6+2304]; - mad.f32 %f60, %f58, %f59, %f57; - ld.shared.f32 %f61, [%rd8+76]; - ld.shared.f32 %f62, [%rd6+2432]; - mad.f32 %f63, %f61, %f62, %f60; - ld.shared.f32 %f64, [%rd8+80]; - ld.shared.f32 %f65, [%rd6+2560]; - mad.f32 %f66, %f64, %f65, %f63; - ld.shared.f32 %f67, [%rd8+84]; - ld.shared.f32 %f68, [%rd6+2688]; - mad.f32 %f69, %f67, %f68, %f66; - ld.shared.f32 %f70, [%rd8+88]; - ld.shared.f32 %f71, [%rd6+2816]; - mad.f32 %f72, %f70, %f71, %f69; - ld.shared.f32 %f73, [%rd8+92]; - ld.shared.f32 %f74, [%rd6+2944]; - mad.f32 %f75, %f73, %f74, %f72; - ld.shared.f32 %f76, [%rd8+96]; - ld.shared.f32 %f77, [%rd6+3072]; - mad.f32 %f78, %f76, %f77, %f75; - ld.shared.f32 %f79, [%rd8+100]; - ld.shared.f32 %f80, [%rd6+3200]; - mad.f32 %f81, %f79, %f80, %f78; - ld.shared.f32 %f82, [%rd8+104]; - ld.shared.f32 %f83, [%rd6+3328]; - mad.f32 %f84, %f82, %f83, %f81; - ld.shared.f32 %f85, [%rd8+108]; - ld.shared.f32 %f86, [%rd6+3456]; - mad.f32 %f87, %f85, %f86, %f84; - ld.shared.f32 %f88, [%rd8+112]; - ld.shared.f32 %f89, [%rd6+3584]; - mad.f32 %f90, %f88, %f89, %f87; - ld.shared.f32 %f91, [%rd8+116]; - ld.shared.f32 %f92, [%rd6+3712]; - mad.f32 %f93, %f91, %f92, %f90; - ld.shared.f32 %f94, [%rd8+120]; - ld.shared.f32 %f95, [%rd6+3840]; - mad.f32 %f96, %f94, %f95, %f93; - ld.shared.f32 %f97, [%rd8+124]; - ld.shared.f32 %f98, [%rd6+3968]; - mad.f32 %f1, %f97, %f98, %f96; - .loc 15 99 0 - bar.sync 0; - .loc 15 66 0 - add.u64 %rd19, %rd13, %rd19; - add.s32 %r21, %r21, 32; - add.u64 %rd23, %rd23, 128; - setp.le.s32 %p2, %r21, %r24; - @%p2 bra $Lt_2_2818; - bra.uni $Lt_2_2306; -$Lt_2_3330: - ld.param.s32 %r11, [__cudaparm_matrixMul_bs32_32bit_wB]; - mul.lo.s32 %r18, %r10, %r11; - mov.f32 %f1, 0f00000000; // 0 -$Lt_2_2306: - .loc 15 105 0 - ld.param.u64 %rd24, [__cudaparm_matrixMul_bs32_32bit_C]; - mul.lo.s32 %r28, %r11, %r3; - add.s32 %r29, %r1, %r28; - mul.lo.s32 %r30, %r29, 32; - add.s32 %r31, %r18, %r30; - add.s32 %r32, %r9, %r31; - cvt.s64.s32 %rd25, %r32; - mul.wide.s32 %rd26, %r32, 4; - add.u64 %rd27, %rd24, %rd26; - st.global.f32 [%rd27+0], %f1; - .loc 15 120 0 - exit; -$LDWend_matrixMul_bs32_32bit: - } // matrixMul_bs32_32bit - .shared .align 4 .b8 __cuda_local_var_16455_39_non_const_As__0[4096]; - .shared .align 4 .b8 __cuda_local_var_16459_39_non_const_Bs__1[4096]; - - .entry matrixMul_bs32_64bit ( - .param .u64 __cudaparm_matrixMul_bs32_64bit_C, - .param .u64 __cudaparm_matrixMul_bs32_64bit_A, - .param .u64 __cudaparm_matrixMul_bs32_64bit_B, - .param .u64 __cudaparm_matrixMul_bs32_64bit_wA, - .param .u64 __cudaparm_matrixMul_bs32_64bit_wB) - { - .reg .u64 %rd<53>; - .reg .f32 %f<100>; - .reg .pred %p<4>; - .loc 15 121 0 -$LDWbegin_matrixMul_bs32_64bit: - .loc 15 66 0 - cvt.u64.u16 %rd1, %ctaid.x; - mul.lo.u64 %rd2, %rd1, 32; - cvt.u64.u16 %rd3, %ctaid.y; - ld.param.u64 %rd4, [__cudaparm_matrixMul_bs32_64bit_wA]; - mul.lo.u64 %rd5, %rd3, %rd4; - mul.lo.u64 %rd6, %rd5, 32; - mov.s64 %rd7, %rd6; - add.u64 %rd8, %rd6, %rd4; - sub.u64 %rd9, %rd8, 1; - cvt.u64.u16 %rd10, %tid.x; - cvt.u64.u16 %rd11, %tid.y; - ld.param.u64 %rd12, [__cudaparm_matrixMul_bs32_64bit_wB]; - setp.lt.u64 %p1, %rd9, %rd6; - @%p1 bra $Lt_3_3330; - mov.u64 %rd13, __cuda_local_var_16455_39_non_const_As__0; - mov.u64 %rd14, __cuda_local_var_16459_39_non_const_Bs__1; - ld.param.u64 %rd4, [__cudaparm_matrixMul_bs32_64bit_wA]; - add.u64 %rd15, %rd4, 31; - shr.s64 %rd16, %rd15, 63; - mov.s64 %rd17, 31; - and.b64 %rd18, %rd16, %rd17; - add.s64 %rd19, %rd18, %rd15; - shr.s64 %rd20, %rd19, 5; - ld.param.u64 %rd12, [__cudaparm_matrixMul_bs32_64bit_wB]; - mul.lo.u64 %rd21, %rd11, %rd12; - mul.lo.u64 %rd22, %rd11, 128; - add.u64 %rd23, %rd13, %rd22; - mul.lo.u64 %rd24, %rd10, 4; - add.u64 %rd25, %rd14, %rd24; - mul.lo.u64 %rd26, %rd11, 32; - add.u64 %rd27, %rd10, %rd26; - mul.lo.u64 %rd28, %rd27, 4; - mul.lo.u64 %rd29, %rd12, 128; - add.u64 %rd30, %rd28, %rd13; - add.u64 %rd31, %rd28, %rd14; - ld.param.u64 %rd32, [__cudaparm_matrixMul_bs32_64bit_B]; - add.u64 %rd33, %rd21, %rd2; - add.u64 %rd34, %rd10, %rd33; - mul.lo.u64 %rd35, %rd34, 4; - add.u64 %rd36, %rd32, %rd35; - ld.param.u64 %rd37, [__cudaparm_matrixMul_bs32_64bit_A]; - mul.lo.u64 %rd38, %rd11, %rd4; - add.u64 %rd39, %rd6, %rd38; - add.u64 %rd40, %rd10, %rd39; - mul.lo.u64 %rd41, %rd40, 4; - add.u64 %rd42, %rd37, %rd41; - mov.f32 %f1, 0f00000000; // 0 - mov.s64 %rd43, %rd20; -$Lt_3_2818: - // Loop body line 66, nesting depth: 1, estimated iterations: unknown - .loc 15 82 0 - ld.global.f32 %f2, [%rd42+0]; - st.shared.f32 [%rd30+0], %f2; - .loc 15 83 0 - ld.global.f32 %f3, [%rd36+0]; - st.shared.f32 [%rd31+0], %f3; - .loc 15 86 0 - bar.sync 0; - .loc 15 94 0 - ld.shared.f32 %f4, [%rd23+0]; - ld.shared.f32 %f5, [%rd25+0]; - mad.f32 %f6, %f4, %f5, %f1; - ld.shared.f32 %f7, [%rd23+4]; - ld.shared.f32 %f8, [%rd25+128]; - mad.f32 %f9, %f7, %f8, %f6; - ld.shared.f32 %f10, [%rd23+8]; - ld.shared.f32 %f11, [%rd25+256]; - mad.f32 %f12, %f10, %f11, %f9; - ld.shared.f32 %f13, [%rd23+12]; - ld.shared.f32 %f14, [%rd25+384]; - mad.f32 %f15, %f13, %f14, %f12; - ld.shared.f32 %f16, [%rd23+16]; - ld.shared.f32 %f17, [%rd25+512]; - mad.f32 %f18, %f16, %f17, %f15; - ld.shared.f32 %f19, [%rd23+20]; - ld.shared.f32 %f20, [%rd25+640]; - mad.f32 %f21, %f19, %f20, %f18; - ld.shared.f32 %f22, [%rd23+24]; - ld.shared.f32 %f23, [%rd25+768]; - mad.f32 %f24, %f22, %f23, %f21; - ld.shared.f32 %f25, [%rd23+28]; - ld.shared.f32 %f26, [%rd25+896]; - mad.f32 %f27, %f25, %f26, %f24; - ld.shared.f32 %f28, [%rd23+32]; - ld.shared.f32 %f29, [%rd25+1024]; - mad.f32 %f30, %f28, %f29, %f27; - ld.shared.f32 %f31, [%rd23+36]; - ld.shared.f32 %f32, [%rd25+1152]; - mad.f32 %f33, %f31, %f32, %f30; - ld.shared.f32 %f34, [%rd23+40]; - ld.shared.f32 %f35, [%rd25+1280]; - mad.f32 %f36, %f34, %f35, %f33; - ld.shared.f32 %f37, [%rd23+44]; - ld.shared.f32 %f38, [%rd25+1408]; - mad.f32 %f39, %f37, %f38, %f36; - ld.shared.f32 %f40, [%rd23+48]; - ld.shared.f32 %f41, [%rd25+1536]; - mad.f32 %f42, %f40, %f41, %f39; - ld.shared.f32 %f43, [%rd23+52]; - ld.shared.f32 %f44, [%rd25+1664]; - mad.f32 %f45, %f43, %f44, %f42; - ld.shared.f32 %f46, [%rd23+56]; - ld.shared.f32 %f47, [%rd25+1792]; - mad.f32 %f48, %f46, %f47, %f45; - ld.shared.f32 %f49, [%rd23+60]; - ld.shared.f32 %f50, [%rd25+1920]; - mad.f32 %f51, %f49, %f50, %f48; - ld.shared.f32 %f52, [%rd23+64]; - ld.shared.f32 %f53, [%rd25+2048]; - mad.f32 %f54, %f52, %f53, %f51; - ld.shared.f32 %f55, [%rd23+68]; - ld.shared.f32 %f56, [%rd25+2176]; - mad.f32 %f57, %f55, %f56, %f54; - ld.shared.f32 %f58, [%rd23+72]; - ld.shared.f32 %f59, [%rd25+2304]; - mad.f32 %f60, %f58, %f59, %f57; - ld.shared.f32 %f61, [%rd23+76]; - ld.shared.f32 %f62, [%rd25+2432]; - mad.f32 %f63, %f61, %f62, %f60; - ld.shared.f32 %f64, [%rd23+80]; - ld.shared.f32 %f65, [%rd25+2560]; - mad.f32 %f66, %f64, %f65, %f63; - ld.shared.f32 %f67, [%rd23+84]; - ld.shared.f32 %f68, [%rd25+2688]; - mad.f32 %f69, %f67, %f68, %f66; - ld.shared.f32 %f70, [%rd23+88]; - ld.shared.f32 %f71, [%rd25+2816]; - mad.f32 %f72, %f70, %f71, %f69; - ld.shared.f32 %f73, [%rd23+92]; - ld.shared.f32 %f74, [%rd25+2944]; - mad.f32 %f75, %f73, %f74, %f72; - ld.shared.f32 %f76, [%rd23+96]; - ld.shared.f32 %f77, [%rd25+3072]; - mad.f32 %f78, %f76, %f77, %f75; - ld.shared.f32 %f79, [%rd23+100]; - ld.shared.f32 %f80, [%rd25+3200]; - mad.f32 %f81, %f79, %f80, %f78; - ld.shared.f32 %f82, [%rd23+104]; - ld.shared.f32 %f83, [%rd25+3328]; - mad.f32 %f84, %f82, %f83, %f81; - ld.shared.f32 %f85, [%rd23+108]; - ld.shared.f32 %f86, [%rd25+3456]; - mad.f32 %f87, %f85, %f86, %f84; - ld.shared.f32 %f88, [%rd23+112]; - ld.shared.f32 %f89, [%rd25+3584]; - mad.f32 %f90, %f88, %f89, %f87; - ld.shared.f32 %f91, [%rd23+116]; - ld.shared.f32 %f92, [%rd25+3712]; - mad.f32 %f93, %f91, %f92, %f90; - ld.shared.f32 %f94, [%rd23+120]; - ld.shared.f32 %f95, [%rd25+3840]; - mad.f32 %f96, %f94, %f95, %f93; - ld.shared.f32 %f97, [%rd23+124]; - ld.shared.f32 %f98, [%rd25+3968]; - mad.f32 %f1, %f97, %f98, %f96; - .loc 15 99 0 - bar.sync 0; - .loc 15 66 0 - add.u64 %rd36, %rd29, %rd36; - add.u64 %rd7, %rd7, 32; - add.u64 %rd42, %rd42, 128; - setp.ge.u64 %p2, %rd9, %rd7; - @%p2 bra $Lt_3_2818; - bra.uni $Lt_3_2306; -$Lt_3_3330: - ld.param.u64 %rd12, [__cudaparm_matrixMul_bs32_64bit_wB]; - mul.lo.u64 %rd21, %rd11, %rd12; - mov.f32 %f1, 0f00000000; // 0 -$Lt_3_2306: - .loc 15 105 0 - ld.param.u64 %rd44, [__cudaparm_matrixMul_bs32_64bit_C]; - mul.lo.u64 %rd45, %rd12, %rd3; - add.u64 %rd46, %rd1, %rd45; - mul.lo.u64 %rd47, %rd46, 32; - add.u64 %rd48, %rd21, %rd47; - add.u64 %rd49, %rd10, %rd48; - mul.lo.u64 %rd50, %rd49, 4; - add.u64 %rd51, %rd44, %rd50; - st.global.f32 [%rd51+0], %f1; - .loc 15 124 0 - exit; -$LDWend_matrixMul_bs32_64bit: - } // matrixMul_bs32_64bit - diff --git a/Rapid-DemoApp/jni/Android.mk b/Rapid-DemoApp/jni/Android.mk deleted file mode 100755 index 215f8a5..0000000 --- a/Rapid-DemoApp/jni/Android.mk +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (C) 2009 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_CFLAGS := -DANDROID_NDK - -LOCAL_MODULE := hello-jni -LOCAL_SRC_FILES := hello-jni.c - -include $(BUILD_SHARED_LIBRARY) - -#include $(CLEAR_VARS) - -#LOCAL_CFLAGS := -DANDROID_NDK - -#LOCAL_MODULE := jpargmp -#LOCAL_SRC_FILES := GmpUtil.c - -#include $(BUILD_SHARED_LIBRARY) diff --git a/Rapid-DemoApp/jni/Application.mk b/Rapid-DemoApp/jni/Application.mk deleted file mode 100644 index dcd8641..0000000 --- a/Rapid-DemoApp/jni/Application.mk +++ /dev/null @@ -1 +0,0 @@ -APP_ABI := armeabi armeabi-v7a x86 x86_64 \ No newline at end of file diff --git a/Rapid-DemoApp/jni/GmpUtil.c b/Rapid-DemoApp/jni/GmpUtil.c deleted file mode 100755 index 29383ea..0000000 --- a/Rapid-DemoApp/jni/GmpUtil.c +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - *******************************************************************************/ -#include "GmpUtil.h" -#include "gmp.h" - -/* - * Class: GmpUtil - * Method: mpz_init - * Signature: ()J - */ -JNIEXPORT jlong JNICALL Java_GmpUtil_mpz_1init - (JNIEnv *x, jclass y) -{ - mpz_t *p = malloc( sizeof(__mpz_struct) ); - __gmpz_init( *p ); - - return (jlong)p; -} - -/* - * Class: GmpUtil - * Method: mpz_clear - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1clear - (JNIEnv *x, jclass y, jlong o) -{ - mpz_t* p = (mpz_t*)o; - __gmpz_clear( *p ); - free( p ); -} - -/* - * Class: GmpUtil - * Method: mpz_set_si - * Signature: (JI)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1set_1si - (JNIEnv *x, jclass y, jlong dest, jint val) -{ - __gmpz_set_si( *((mpz_t*)dest), (long) val); -} - -/* - * Class: GmpUtil - * Method: mpz_get_si - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_GmpUtil_mpz_1get_1si - (JNIEnv *x, jclass y, jlong dest) -{ - return (jint)__gmpz_get_si( *((mpz_t*)dest)); -} - -/* - * Class: GmpUtil - * Method: mpz_cmp - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL Java_GmpUtil_mpz_1cmp - (JNIEnv *x, jclass y, jlong op1, jlong op2) -{ - return (jint) __gmpz_cmp( *((mpz_t*)op1), *((mpz_t*)op2) ); -} - -/* - * Class: GmpUtil - * Method: mpz_add - * Signature: (JJJ)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1add - (JNIEnv *x, jclass y, jlong dest, jlong src, jlong val) -{ - __gmpz_add( *((mpz_t*)dest), *((mpz_t*)src), *((mpz_t*)val) ); -} - -/* - * Class: GmpUtil - * Method: mpz_sub - * Signature: (JJJ)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1sub - (JNIEnv *x, jclass y, jlong dest, jlong src, jlong val) -{ - __gmpz_sub( *((mpz_t*)dest), *((mpz_t*)src), *((mpz_t*)val) ); -} - -/* - * Class: GmpUtil - * Method: mpz_mul_si - * Signature: (JJI)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1mul_1si - (JNIEnv *x, jclass y, jlong dest, jlong src, jint val) -{ - __gmpz_mul_si( *((mpz_t*)dest), *((mpz_t*)src), (long) val); -} - -/* - * Class: GmpUtil - * Method: mpz_addmul_ui - * Signature: (JJI)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1addmul_1ui - (JNIEnv *x, jclass y, jlong dest, jlong a, jint b) -{ - __gmpz_addmul_ui( *((mpz_t*)dest), *((mpz_t*)a), (long)b); -} - -/* - * Class: GmpUtil - * Method: mpz_submul_ui - * Signature: (JJI)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1submul_1ui - (JNIEnv *x, jclass y, jlong dest, jlong a, jint b) -{ - __gmpz_submul_ui( *((mpz_t*)dest), *((mpz_t*)a), (long)b); -} - -/* - * Class: GmpUtil - * Method: mpz_divexact - * Signature: (JJJ)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1divexact - (JNIEnv *x, jclass y, jlong quot, jlong n, jlong d) -{ - __gmpz_divexact( *((mpz_t*)quot), *((mpz_t*)n), *((mpz_t*)d)); -} - -/* - * Class: GmpUtil - * Method: mpz_tdiv_qr - * Signature: (JJJJ)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1tdiv_1qr - (JNIEnv *x, jclass y, jlong q, jlong r, jlong n, jlong d) -{ - __gmpz_tdiv_qr( *((mpz_t*)q), *((mpz_t*)r), *((mpz_t*)n), *((mpz_t*)d) ); -} - -/* - * Class: GmpUtil - * Method: mpz_gcd - * Signature: (JJJ)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1gcd - (JNIEnv *x, jclass y, jlong r, jlong a, jlong b) -{ - __gmpz_gcd( *((mpz_t*)r), *((mpz_t*)a), *((mpz_t*)b) ); -} diff --git a/Rapid-DemoApp/jni/GmpUtil.h b/Rapid-DemoApp/jni/GmpUtil.h deleted file mode 100755 index 80b9b5e..0000000 --- a/Rapid-DemoApp/jni/GmpUtil.h +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - *******************************************************************************/ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class GmpUtil */ - -#ifndef _Included_GmpUtil -#define _Included_GmpUtil -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: GmpUtil - * Method: mpz_init - * Signature: ()J - */ -JNIEXPORT jlong JNICALL Java_GmpUtil_mpz_1init - (JNIEnv *, jclass); - -/* - * Class: GmpUtil - * Method: mpz_clear - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1clear - (JNIEnv *, jclass, jlong); - -/* - * Class: GmpUtil - * Method: mpz_set_si - * Signature: (JI)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1set_1si - (JNIEnv *, jclass, jlong, jint); - -/* - * Class: GmpUtil - * Method: mpz_get_si - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_GmpUtil_mpz_1get_1si - (JNIEnv *, jclass, jlong); - -/* - * Class: GmpUtil - * Method: mpz_cmp - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL Java_GmpUtil_mpz_1cmp - (JNIEnv *, jclass, jlong, jlong); - -/* - * Class: GmpUtil - * Method: mpz_add - * Signature: (JJJ)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1add - (JNIEnv *, jclass, jlong, jlong, jlong); - -/* - * Class: GmpUtil - * Method: mpz_sub - * Signature: (JJJ)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1sub - (JNIEnv *, jclass, jlong, jlong, jlong); - -/* - * Class: GmpUtil - * Method: mpz_mul_si - * Signature: (JJI)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1mul_1si - (JNIEnv *, jclass, jlong, jlong, jint); - -/* - * Class: GmpUtil - * Method: mpz_addmul_ui - * Signature: (JJI)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1addmul_1ui - (JNIEnv *x, jclass y, jlong dest, jlong a, jint b); - -/* - * Class: GmpUtil - * Method: mpz_submul_ui - * Signature: (JJI)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1submul_1ui - (JNIEnv *x, jclass y, jlong dest, jlong a, jint b); - -/* - * Class: GmpUtil - * Method: mpz_divexact - * Signature: (JJJ)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1divexact - (JNIEnv *, jclass, jlong, jlong, jlong); - -/* - * Class: GmpUtil - * Method: mpz_tdiv_qr - * Signature: (JJJJ)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1tdiv_1qr - (JNIEnv *, jclass, jlong, jlong, jlong, jlong); - -/* - * Class: GmpUtil - * Method: mpz_gcd - * Signature: (JJJ)V - */ -JNIEXPORT void JNICALL Java_GmpUtil_mpz_1gcd - (JNIEnv *, jclass, jlong, jlong, jlong); - -#ifdef __cplusplus -} -#endif -#endif \ No newline at end of file diff --git a/Rapid-DemoApp/jni/hello-jni.c b/Rapid-DemoApp/jni/hello-jni.c deleted file mode 100755 index 2a362f9..0000000 --- a/Rapid-DemoApp/jni/hello-jni.c +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2015, 2016 RAPID EU Project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - *******************************************************************************/ -#include -#include - - - -/* This is a trivial JNI example where we use a native method - * to return a new VM String. - */ - -//JavaVM *g_vm; // Can't have globals - SIGSEGV on server - -JNIEXPORT jstring JNICALL -Java_eu_project_rapid_synthBenchmark_JniTest_stringFromJNI( JNIEnv* env, - jobject thiz ) -{ - return (*env)->NewStringUTF(env, "Hello from JNI !"); -} - -jint JNI_OnLoad(JavaVM* vm, void* reserved) -{ - //g_vm = vm; - return JNI_VERSION_1_4; -} diff --git a/Rapid-DemoApp/libs/armeabi-v7a/libhello-jni.so b/Rapid-DemoApp/libs/armeabi-v7a/libhello-jni.so deleted file mode 100755 index 5749b41..0000000 Binary files a/Rapid-DemoApp/libs/armeabi-v7a/libhello-jni.so and /dev/null differ diff --git a/Rapid-DemoApp/libs/armeabi/libhello-jni.so b/Rapid-DemoApp/libs/armeabi/libhello-jni.so deleted file mode 100755 index 6cd0981..0000000 Binary files a/Rapid-DemoApp/libs/armeabi/libhello-jni.so and /dev/null differ diff --git a/Rapid-DemoApp/libs/commons-compress-1.9.jar b/Rapid-DemoApp/libs/commons-compress-1.9.jar deleted file mode 100644 index 14e7e86..0000000 Binary files a/Rapid-DemoApp/libs/commons-compress-1.9.jar and /dev/null differ diff --git a/Rapid-DemoApp/libs/core-1.51.0.0.jar b/Rapid-DemoApp/libs/core-1.51.0.0.jar deleted file mode 100644 index 60b24dd..0000000 Binary files a/Rapid-DemoApp/libs/core-1.51.0.0.jar and /dev/null differ diff --git a/Rapid-DemoApp/libs/prov-1.51.0.0.jar b/Rapid-DemoApp/libs/prov-1.51.0.0.jar deleted file mode 100644 index d5d7899..0000000 Binary files a/Rapid-DemoApp/libs/prov-1.51.0.0.jar and /dev/null differ diff --git a/Rapid-DemoApp/libs/x86/libhello-jni.so b/Rapid-DemoApp/libs/x86/libhello-jni.so deleted file mode 100755 index f31d894..0000000 Binary files a/Rapid-DemoApp/libs/x86/libhello-jni.so and /dev/null differ diff --git a/Rapid-DemoApp/libs/x86_64/libhello-jni.so b/Rapid-DemoApp/libs/x86_64/libhello-jni.so deleted file mode 100755 index 0a0dcb1..0000000 Binary files a/Rapid-DemoApp/libs/x86_64/libhello-jni.so and /dev/null differ diff --git a/Rapid-DemoApp/lint.xml b/Rapid-DemoApp/lint.xml deleted file mode 100644 index 7a77bf7..0000000 --- a/Rapid-DemoApp/lint.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Rapid-DemoApp/project.properties b/Rapid-DemoApp/project.properties deleted file mode 100644 index 3e2b4db..0000000 --- a/Rapid-DemoApp/project.properties +++ /dev/null @@ -1,32 +0,0 @@ -############################################################################### -# Copyright (C) 2015, 2016 RAPID EU Project -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -############################################################################### -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-19 -android.library.reference.1=../AccelerationClient diff --git a/Rapid-DemoApp/res/drawable-hdpi/icon.png b/Rapid-DemoApp/res/drawable-hdpi/icon.png deleted file mode 100644 index 089652d..0000000 Binary files a/Rapid-DemoApp/res/drawable-hdpi/icon.png and /dev/null differ diff --git a/Rapid-DemoApp/res/drawable-hdpi/icon_dark.png b/Rapid-DemoApp/res/drawable-hdpi/icon_dark.png deleted file mode 100644 index f0e99e9..0000000 Binary files a/Rapid-DemoApp/res/drawable-hdpi/icon_dark.png and /dev/null differ diff --git a/Rapid-DemoApp/res/drawable-ldpi/icon.png b/Rapid-DemoApp/res/drawable-ldpi/icon.png deleted file mode 100644 index 089652d..0000000 Binary files a/Rapid-DemoApp/res/drawable-ldpi/icon.png and /dev/null differ diff --git a/Rapid-DemoApp/res/drawable-ldpi/icon_dark.png b/Rapid-DemoApp/res/drawable-ldpi/icon_dark.png deleted file mode 100644 index f0e99e9..0000000 Binary files a/Rapid-DemoApp/res/drawable-ldpi/icon_dark.png and /dev/null differ diff --git a/Rapid-DemoApp/res/drawable-mdpi/icon.png b/Rapid-DemoApp/res/drawable-mdpi/icon.png deleted file mode 100644 index 089652d..0000000 Binary files a/Rapid-DemoApp/res/drawable-mdpi/icon.png and /dev/null differ diff --git a/Rapid-DemoApp/res/drawable-mdpi/icon_dark.png b/Rapid-DemoApp/res/drawable-mdpi/icon_dark.png deleted file mode 100644 index f0e99e9..0000000 Binary files a/Rapid-DemoApp/res/drawable-mdpi/icon_dark.png and /dev/null differ diff --git a/Rapid-DemoApp/res/drawable-xhdpi/icon.png b/Rapid-DemoApp/res/drawable-xhdpi/icon.png deleted file mode 100644 index 089652d..0000000 Binary files a/Rapid-DemoApp/res/drawable-xhdpi/icon.png and /dev/null differ diff --git a/Rapid-DemoApp/res/drawable-xhdpi/icon_dark.png b/Rapid-DemoApp/res/drawable-xhdpi/icon_dark.png deleted file mode 100644 index f0e99e9..0000000 Binary files a/Rapid-DemoApp/res/drawable-xhdpi/icon_dark.png and /dev/null differ diff --git a/Rapid-DemoApp/res/drawable/icon.xcf b/Rapid-DemoApp/res/drawable/icon.xcf deleted file mode 100644 index e884c78..0000000 Binary files a/Rapid-DemoApp/res/drawable/icon.xcf and /dev/null differ diff --git a/Rapid-DemoApp/res/drawable/prove.jpg b/Rapid-DemoApp/res/drawable/prove.jpg deleted file mode 100755 index a3fe258..0000000 Binary files a/Rapid-DemoApp/res/drawable/prove.jpg and /dev/null differ diff --git a/Rapid-DemoApp/res/drawable/prove2.jpg b/Rapid-DemoApp/res/drawable/prove2.jpg deleted file mode 100755 index 3908526..0000000 Binary files a/Rapid-DemoApp/res/drawable/prove2.jpg and /dev/null differ diff --git a/Rapid-DemoApp/res/layout/activity_main.xml b/Rapid-DemoApp/res/layout/activity_main.xml deleted file mode 100644 index a096ecb..0000000 --- a/Rapid-DemoApp/res/layout/activity_main.xml +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -