コード例 #1
0
    def test_open_mp_object_from_basic_file(self):
        """
            To create ccode objects , the given code must follow 
            the following struture

            #include <...>
            #include <...>

            #define ....

            
            function_1(){
        
            }

            int main(){
        
            }

            if the given code do not follow this structure it can 
            not be splited in sections, because the code does not
            have that sections, then an IndexError takes place.
        """
        with self.assertRaises(IndexError):
            omp = parallelizer.OpenMP(file_path=self._basic)
コード例 #2
0
 def test_open_mp_object_from_unsupported_code_1(self):
     """ 
         The C preprocessor used by pycparse for code parsing do not support
         the bool type natively, if the preprocessor find an unknwon type, the
         code parsing cann not take place.
     """
     with self.assertRaises(ParseError):
         omp = parallelizer.OpenMP(file_path=self._unsupported_1)
コード例 #3
0
    def setUp(self):
        # Creating the OpenMP parallelizer
        self._omp = parallelizer.OpenMP(
            raw_code=test_data.SIMPLE_CODE_FUNCTION_LOOP)

        # Creation paralellization metadata object
        self._parallel = metadata.Parallel(
            data=test_data.METADATA_FOR_SIMPLE_CODE_FUNCTION_LOOP)
コード例 #4
0
    def test_openmp_object_from_supported_code(self):
        """

            We place two includes above the stdbool.h

            #include <stdio.h>
            #include <stdlib.h>
            #include <stdbool.h>

            So the first two includes are faked out

            #include <_fake_defines.h>
            #include <_fake_typedefs.h>
            #include <stdbool.h>

            Then, the bool type will be recognized by the following step,
            The C preprocessing.          

        """
        omp = parallelizer.OpenMP(file_path=self._supported)
        self.assertIsInstance(omp, parallelizer.OpenMP)
コード例 #5
0
    def test_open_mp_object_from_unsupported_code_2(self):
        """ 
            We include the stdbool.h header library on which the bool 
            type is defined. Thus, the C preprocessor will recognize
            the bool type.

            But this version of pragcc perform a preprocessing if the
            code called fake_cfile located in pragcc.core.parser.c99.parser
            this step remove the first two headers of the original file.

            #include <stdbool.h>
            #include <stdio.h>

            for fake files

            #include <_fake_defines.h>
            #include <_fake_typedefs.h>

            So, the bool type would not be recognized again. The follwing 
            test show a possible solution.

        """
        with self.assertRaises(ParseError):
            omp = parallelizer.OpenMP(file_path=self._unsupported_2)
コード例 #6
0
 def test_openmp_object_from_empty_code_file(self):
     with self.assertRaises(IndexError):
         omp = parallelizer.OpenMP(file_path=self._empty)
コード例 #7
0
 def test_open_mp_object_from_complex_file(self):
     omp = parallelizer.OpenMP(file_path=self._complex)
     self.assertIsInstance(omp, parallelizer.OpenMP)