• 大小: 12KB
    文件类型: .c
    金币: 1
    下载: 0 次
    发布日期: 2021-06-15
  • 语言: 其他
  • 标签: csapp  lab  

资源简介

自己写的csapp上的性能优化实验的kernels.c。

资源截图

代码片段和文件信息

/********************************************************
 * Kernels to be optimized for the CS:APP Performance Lab
 ********************************************************/

#include 
#include 
#include “defs.h“

/* 
 * Please fill in the following team struct 
 */
team_t team = {
    “5120379091“              /* Student ID */

    “Gao Ce“           /* Your Name */
    “gaoce270863799@se.sjtu.edu.cn“  /* First member email address */

    ““                   /* Second member full name (leave blank if none) */
    ““                    /* Second member email addr (leave blank if none) */
};

/***************
 * ROTATE KERNEL
 ***************/

/******************************************************
 * Your different versions of the rotate kernel go here
 ******************************************************/
/*
 *Add the description of your Rotate implementation here!!!
 *1. Brief Intro of method
 *2. CPE Achieved
 *3. other words
 */

/* 
 * naive_rotate - The naive baseline version of rotate 
 */
char naive_rotate_descr[] = “naive_rotate: Naive baseline implementation“;
void naive_rotate(int dim pixel *src pixel *dst) 
{
    int i j;

    for (i = 0; i < dim; i++)
    for (j = 0; j < dim; j++)
        dst[RIDX(dim-1-j i dim)] = src[RIDX(i j dim)];
}

/* 
 * rotate - Your current working version of rotate
 * IMPORTANT: This is the version you will be graded on
 */
char rotate_descr[] = “rotate: Current working version“;
void rotate(int dim pixel *src pixel *dst)
{
    int i j;
    dst += (dim-1)*dim;
    for (i = 0; i < dim; i+=32){ 
            for (j = 0; j < dim; j++){ 
                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
                src+=dim;
                dst+=1;

                *dst=*src;
         

评论

共有 条评论